Repository navigation
setup workflows #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f5a939b
b19cd7b
fe108ab
c7302fa
f23273c
fe856fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||||||||||||||||||||||
| name: Github Action for CI4 Settings and Feature Flag Library | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||
| branches: [ "main", "develop" ] | ||||||||||||||||||||||||||
| # Manual runs from the Actions tab | ||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||
| tests: | ||||||||||||||||||||||||||
| name: "PHP ${{ matrix.php }} (deps: ${{ matrix.deps }})" | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||||||
| fail-fast: false | ||||||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||||||
| php: [ "8.2" ] | ||||||||||||||||||||||||||
| deps: [ "stable" ] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||
| # Typical CI4 testing env values | ||||||||||||||||||||||||||
| APP_ENV: testing | ||||||||||||||||||||||||||
| CI_ENVIRONMENT: testing | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| # --- 1. Checkout code --------------------------------------------------- | ||||||||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 2. Setup PHP ------------------------------------------------------- | ||||||||||||||||||||||||||
| - name: Setup PHP | ||||||||||||||||||||||||||
| uses: shivammathur/setup-php@v2 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| php-version: ${{ matrix.php }} | ||||||||||||||||||||||||||
| extensions: mbstring, intl, json, pdo_mysql, sqlite3 | ||||||||||||||||||||||||||
| ini-values: | | ||||||||||||||||||||||||||
| memory_limit=512M | ||||||||||||||||||||||||||
| coverage: none | ||||||||||||||||||||||||||
| tools: composer | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 3. Cache Composer dependencies ------------------------------------ | ||||||||||||||||||||||||||
| - name: Get Composer cache directory | ||||||||||||||||||||||||||
| id: composer-cache | ||||||||||||||||||||||||||
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Cache Composer dependencies | ||||||||||||||||||||||||||
| uses: actions/cache@v4 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| path: ${{ steps.composer-cache.outputs.dir }} | ||||||||||||||||||||||||||
| key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.deps }}-composer-${{ hashFiles('**/composer.lock') }} | ||||||||||||||||||||||||||
| restore-keys: | | ||||||||||||||||||||||||||
| ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.deps }}-composer- | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 4. Install dependencies ------------------------------------------- | ||||||||||||||||||||||||||
| - name: Install Composer dependencies | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ "${{ matrix.deps }}" = "lowest" ]; then | ||||||||||||||||||||||||||
| composer update --prefer-lowest --no-interaction --no-progress | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| composer install --no-interaction --no-progress --prefer-dist | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 5. Prepare .env for CodeIgniter 4---------------------- | ||||||||||||||||||||||||||
| # name it `.env.github-ci` | ||||||||||||||||||||||||||
| - name: Prepare .env | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ -f .env.github-ci ]; then | ||||||||||||||||||||||||||
| cp .env.github-ci .env | ||||||||||||||||||||||||||
| elif [ -f env ]; then | ||||||||||||||||||||||||||
| cp env .env | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 6. Basic PHP syntax check ----------------------------------------- | ||||||||||||||||||||||||||
| - name: PHP syntax check (lint) | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| find src tests app -type f -name "*.php" 2>/dev/null \ | ||||||||||||||||||||||||||
| | xargs -r -n 1 php -l | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 7. Run unit tests (PHPUnit) --------------------------------------- | ||||||||||||||||||||||||||
| - name: Run PHPUnit tests | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ -f vendor/bin/phpunit ]; then | ||||||||||||||||||||||||||
| vendor/bin/phpunit --testdox | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| echo "PHPUnit not found. Did you require it as a dev dependency?" >&2 | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 8. Static analysis (PHPStan) - optional --------------------------- | ||||||||||||||||||||||||||
| - name: Run PHPStan (if configured) | ||||||||||||||||||||||||||
| if: ${{ hashFiles('phpstan.neon*') != '' }} | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ -f vendor/bin/phpstan ]; then | ||||||||||||||||||||||||||
| vendor/bin/phpstan analyse src tests --no-progress | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 9. Coding standards (PHPCS) - optional ---------------------------- | ||||||||||||||||||||||||||
| - name: Run PHPCS (if configured) | ||||||||||||||||||||||||||
| if: ${{ hashFiles('phpcs.xml*') != '' }} | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ -f vendor/bin/phpcs ]; then | ||||||||||||||||||||||||||
| vendor/bin/phpcs | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --- 10. PHP-CBF (dry-run) - optional ----------------------------- | ||||||||||||||||||||||||||
| - name: Run PHP-CBF (dry-run, if configured) | ||||||||||||||||||||||||||
| if: ${{ hashFiles('.php-cs-fixer.dist.php', '.php-cs-fixer.php') != '' }} | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ -f vendor/bin/phpcbf ]; then | ||||||||||||||||||||||||||
| vendor/bin/phpcbf | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
Comment on lines
+106
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mismatch between tool command and config files. The step checks for Apply this diff to use the correct command: - name: Run PHP-CBF (dry-run, if configured)
if: ${{ hashFiles('.php-cs-fixer.dist.php', '.php-cs-fixer.php') != '' }}
run: |
if [ -f vendor/bin/php-cs-fixer ]; then
- vendor/bin/phpcbf fix --dry-run --diff
+ vendor/bin/php-cs-fixer fix --dry-run --diff
fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,10 @@ | ||
| .idea/ | ||
| vendor/ | ||
| var/ | ||
| *.cache | ||
| composer.lock | ||
| .DS_Store | ||
| .vscode/ | ||
| phpunit | ||
| build/ | ||
| phpunit*.xml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use PhpCsFixer\Config; | ||
| use PhpCsFixer\Finder; | ||
| use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; | ||
|
|
||
| return (new Config()) | ||
| ->setParallelConfig(ParallelConfigFactory::detect()) // @TODO 4.0 no need to call this manually | ||
| ->setRiskyAllowed(false) | ||
| ->setRules([ | ||
| '@auto' => true | ||
| ]) | ||
| // 💡 by default, Fixer looks for `*.php` files excluding `./vendor/` - here, you can groom this config | ||
| ->setFinder( | ||
| (new Finder()) | ||
| // 💡 root folder to check | ||
| ->in(__DIR__) | ||
| // 💡 additional files, eg bin entry file | ||
| // ->append([__DIR__.'/bin-entry-file']) | ||
| // 💡 folders to exclude, if any | ||
| // ->exclude([/* ... */]) | ||
| // 💡 path patterns to exclude, if any | ||
| // ->notPath([/* ... */]) | ||
| // 💡 extra configs | ||
| // ->ignoreDotFiles(false) // true by default in v3, false in v4 or future mode | ||
| // ->ignoreVCSIgnored(true) // true by default | ||
| ) | ||
| ; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,40 @@ | |
| "Jide\\Settings\\": "src/" | ||
| } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "Jide\\Settings\\Tests\\": "tests/" | ||
| } | ||
| }, | ||
| "require": { | ||
| "php": "^8.0", | ||
| "codeigniter4/framework": "^4.0" | ||
| } | ||
| "php": "^8.2" | ||
| }, | ||
|
Comment on lines
16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Short answer
Compatibility notes
Sources
Confirm intentional drop of PHP 8.1 support Raising the requirement to 🤖 Prompt for AI Agents |
||
| "require-dev": { | ||
| "codeigniter4/framework": "^4.0", | ||
| "phpunit/phpunit": "^10.0", | ||
| "phpstan/phpstan": "^1.11", | ||
| "phpstan/phpstan-phpunit": "^1.4", | ||
| "squizlabs/php_codesniffer": "^3.9", | ||
| "friendsofphp/php-cs-fixer": "^3.0", | ||
| "systemsdk/phpcpd": "^7.0.1" | ||
| }, | ||
| "scripts": { | ||
| "test": "phpunit --testdox", | ||
| "analyse": "phpstan analyse src tests", | ||
| "deduplicate": "phpcpd src/ tests/", | ||
| "cs": "phpcs", | ||
| "cs-fix": "phpcbf", | ||
| "style": "@cs-fix", | ||
| "ci": [ | ||
| "@cs", | ||
| "@deduplicate", | ||
| "@analyse", | ||
| "@test" | ||
| ] | ||
| }, | ||
|
Comment on lines
+19
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Summary — phpcs and phpcbf (squizlabs/php_codesniffer)
Sources: 🌐 Web query:
💡 Result: Short answer — php-cs-fixer is a CLI PHAR/composer package. Common ways to get the php-cs-fixer executable and how to run it:
Docs/references: [1] Symfony docs (php-cs-fixer installation). [2] PHP-CS-Fixer GitHub. [3] Older install/PHAR instructions and examples. 🏁 Script executed: # Check the current state of composer.json to verify the claims
cat -n composer.json | head -50Repository: olajideolamide/ci4-settings Length of output: 1443 🏁 Script executed: # Look for the CI file mentioned (.github/php-ci.yml)
find . -name "*ci*.yml" -o -name "*ci*.yaml" | head -20Repository: olajideolamide/ci4-settings Length of output: 91 🏁 Script executed: # Check the CI file contents
cat -n ./.github/php-ci.ymlRepository: olajideolamide/ci4-settings Length of output: 4700 🌐 Web query:
💡 Result: Short answer: phpcbf itself does not provide a standard --dry-run/--diff switch to preview changes; use phpcs' diff report or safe phpcbf modes (suffix, STDIN, VCS) to preview changes before applying. Key points + examples
References
If you want, I can give exact commands for your repo (git-aware preview, a one-liner producing diffs, or a small script that runs phpcs -> phpcbf safely). Align code style tools between You require both
This makes
In composer.json at lines 19-41, the repo mixes PHPCS (phpcs/phpcbf) and |
||
| "config": { | ||
| "sort-packages": true | ||
| }, | ||
| "minimum-stability": "stable", | ||
| "prefer-stable": true | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?xml version="1.0"?> | ||
| <ruleset name="CodeIgniter 4 Settings Library Standard"> | ||
| <description> | ||
| Coding standard for the CI4 Settings / Feature Flag library. | ||
| Applies PSR-12 to src/ and tests/ while ignoring vendor and build artifacts. | ||
| </description> | ||
|
Comment on lines
+3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify the library description. The description mentions "CI4 Settings / Feature Flag library", but the PR title and context suggest this is primarily a settings library. If feature flags are a core part of this library, this is fine; otherwise, consider simplifying to "CI4 Settings Library". 🤖 Prompt for AI Agents |
||
|
|
||
| <!-- Directories to scan --> | ||
| <file>src</file> | ||
| <file>tests</file> | ||
|
|
||
| <!-- Exclusions --> | ||
| <exclude-pattern>vendor/*</exclude-pattern> | ||
| <exclude-pattern>var/*</exclude-pattern> | ||
| <exclude-pattern>build/*</exclude-pattern> | ||
| <exclude-pattern>.phpunit.cache/*</exclude-pattern> | ||
| <exclude-pattern>.phpstan/*</exclude-pattern> | ||
|
|
||
| <!-- Global options --> | ||
| <arg name="colors"/> | ||
| <arg name="encoding" value="utf-8"/> | ||
| <arg name="extensions" value="php"/> | ||
| <arg name="parallel" value="4"/> | ||
|
|
||
| <!-- Base standard --> | ||
| <rule ref="PSR12"> | ||
| <!-- Optional relaxations: --> | ||
|
|
||
| <!-- Ignore long lines (useful for long arrays, SQL, etc.) --> | ||
| <exclude name="Generic.Files.LineLength.TooLong"/> | ||
|
|
||
| <!-- Allow tabs in indentation --> | ||
| <!-- <exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed"/> --> | ||
| </rule> | ||
|
|
||
| <!-- Extra generic rules (optional) --> | ||
| <rule ref="Generic.Commenting.Todo"/> | ||
| </ruleset> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| includes: | ||
| # Extra rules for PHPUnit test classes (optional but nice) | ||
| - vendor/phpstan/phpstan-phpunit/extension.neon | ||
|
|
||
| parameters: | ||
| level: 5 | ||
|
|
||
| paths: | ||
| - src | ||
| - tests | ||
|
|
||
| tmpDir: var/phpstan | ||
|
|
||
| # Ensure Composer autoload is loaded so all classes are known | ||
| bootstrapFiles: | ||
| - vendor/autoload.php | ||
| - vendor/codeigniter4/framework/system/Test/bootstrap.php | ||
|
|
||
| # Some stricter checks that are very useful | ||
| checkMissingIterableValueType: true | ||
| checkGenericClassInNonGenericObjectType: true | ||
| checkMissingVarTagTypehint: true | ||
| reportUnmatchedIgnoredErrors: true | ||
|
|
||
| # Option to relax PHPDoc certainty | ||
| treatPhpDocTypesAsCertain: false | ||
|
|
||
| # Prevents CodeIgniter dynamic properties/magic, | ||
| # from causing PHPStan to scream too much | ||
| #ignoreErrors: | ||
| #- '#^Call to an undefined method CodeIgniter\\.*#' | ||
| #- '#^Access to an undefined property CodeIgniter\\.*#' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" | ||
| bootstrap="vendor/autoload.php" | ||
| cacheDirectory=".phpunit.cache" | ||
| colors="true" | ||
| executionOrder="depends,defects" | ||
| beStrictAboutChangesToGlobalState="true" | ||
| displayDetailsOnTestsThatTriggerWarnings="true" | ||
| failOnWarning="false" | ||
| > | ||
| <testsuites> | ||
| <testsuite name="Unit"> | ||
| <directory suffix="Test.php">tests</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
|
|
||
| <source> | ||
| <include> | ||
| <directory suffix=".php">src</directory> | ||
| </include> | ||
| <exclude> | ||
| <directory>vendor</directory> | ||
| <directory>tests</directory> | ||
| </exclude> | ||
| </source> | ||
|
|
||
| <!-- PHP + CI4-related env --> | ||
| <php> | ||
|
|
||
|
|
||
| <!-- common CI4 testing env flags --> | ||
| <env name="APP_ENV" value="testing"/> | ||
| <env name="CI_ENVIRONMENT" value="testing"/> | ||
|
|
||
| <!-- useful if anything --> | ||
| <env name="app.baseURL" value="http://localhost/"/> | ||
|
|
||
| <!-- testDB: | ||
| <env name="database.default.DBDriver" value="SQLite3"/> | ||
| <env name="database.default.database" value=":memory:"/> | ||
| --> | ||
| </php> | ||
|
|
||
| </phpunit> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workflow file location will prevent it from running
This workflow is defined as
.github/php-ci.ymlin the PR, but GitHub Actions only loads workflows from.github/workflows/*.yml. Unless there is a planned move/rename, this file will not be picked up by GitHub, and the CI will never run. Consider moving it to.github/workflows/php-ci.yml(or similar).🤖 Prompt for AI Agents