Skip to content

Commit

Permalink
Refactor castor validation and integrate tasks in workflows
Browse files Browse the repository at this point in the history
The code refactors the validation of the composer configuration and autoload dumping in the 'castor.php' file. It also modifies the '.github/workflows/integrate.yml' to replace previous tasks with equivalent 'castor' commands for validation, testing, static analysis, code style checking, Deptrac analysis, and make rector. Additionally, '.castor.stub.php' is added to the '.gitignore' file to prevent it from being tracked.
  • Loading branch information
Spomky committed Apr 13, 2024
1 parent 13298f1 commit f2db9e4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
with:
php-version: "${{ matrix.php-version }}"
extensions: "ctype, dom, json, libxml, mbstring, openssl, phar, simplexml, tokenizer, xml, xmlwriter"
tools: castor
coverage: "xdebug"

- name: "Checkout code"
Expand All @@ -80,7 +81,7 @@ jobs:
composer-options: "--optimize-autoloader"

- name: "Execute tests (PHP)"
run: "make ci-cc"
run: "castor test --coverage-text"

# - name: Send coverage to Coveralls
# if: "matrix.php-version == '8.1' && matrix.dependencies == 'highest'"
Expand All @@ -102,25 +103,23 @@ jobs:
with:
php-version: "8.3"
extensions: "ctype, dom, json, libxml, mbstring, openssl, phar, simplexml, tokenizer, xml, xmlwriter"
tools: castor
coverage: "none"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Validate Composer configuration"
run: "composer validate --strict"
run: "castor validate"

- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"
composer-options: "--optimize-autoloader"

- name: "Check PSR-4 mapping"
run: "composer dump-autoload --optimize --strict-psr"

- name: "Execute static analysis"
run: "make st"
run: "castor stan"

coding_standards:
name: "4️⃣ Coding Standards"
Expand All @@ -134,6 +133,7 @@ jobs:
with:
php-version: "8.3"
extensions: "ctype, dom, json, libxml, mbstring, openssl, phar, simplexml, tokenizer, xml, xmlwriter"
tools: castor
coverage: "none"

- name: "Checkout code"
Expand All @@ -146,11 +146,10 @@ jobs:
composer-options: "--optimize-autoloader"

- name: "Check coding style"
run: "make ci-cs"
run: "castor cs"

- name: "Deptrac"
run: |
vendor/bin/deptrac analyse --fail-on-uncovered --no-cache
run: 'castor deptrac'

rector_checkstyle:
name: "6️⃣ Rector Checkstyle"
Expand All @@ -164,6 +163,7 @@ jobs:
with:
php-version: "8.3"
extensions: "ctype, dom, json, libxml, mbstring, openssl, phar, simplexml, tokenizer, xml, xmlwriter"
tools: castor
coverage: "xdebug"

- name: "Checkout code"
Expand All @@ -179,7 +179,7 @@ jobs:
composer-options: "--optimize-autoloader"

- name: "Execute Rector"
run: "make rector"
run: "castor rector"

exported_files:
name: "7️⃣ Exported files"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ yarn-error.log
/composer.lock
/vendor
infection.txt
/.castor.stub.php
12 changes: 9 additions & 3 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@ function stan(): void
function validate(): void
{
io()->title('Validating Composer configuration');
$command = ['composer', 'validate'];
$environment = [
'XDEBUG_MODE' => 'off',
$command = ['composer', 'validate', '--strict'];
$environment = ['XDEBUG_MODE' => 'off'];
run($command, environment: $environment);

$command = [
'composer',
'dump-autoload',
'--optimize',
'--strict-psr'
];
run($command, environment: $environment);
}
Expand Down

0 comments on commit f2db9e4

Please sign in to comment.