Continue project review, fix minor issues #518
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_call: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check-ci-runs: | |
name: Check previous runs | |
if: ${{ github.event_name != 'workflow_call' }} | |
runs-on: ubuntu-latest | |
outputs: | |
ci_required: ${{ steps.check-ci-runs.outputs.ci_required }} | |
steps: | |
- name: Check CI runs | |
id: check-ci-runs | |
uses: lkrms/check-ci-runs@v1 | |
with: | |
ci_workflows: "CI,Release" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
format: | |
name: Check generated files and formatting | |
needs: | |
- check-ci-runs | |
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Composer cache directory | |
id: get-composer-cache | |
shell: bash | |
run: printf 'cache_dir=%s\n' "$(composer config cache-files-dir)" >>"$GITHUB_OUTPUT" | |
- name: Cache PHP dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.get-composer-cache.outputs.cache_dir }} | |
key: composer-cache-${{ runner.os }}-${{ hashFiles('**/composer.json', '**/composer.lock') }} | |
restore-keys: composer-cache-${{ runner.os }}- | |
- name: Install PHP dependencies | |
run: composer install --no-interaction --no-progress | |
- name: Check generated files | |
run: scripts/generate.sh --check | |
- name: Run PHP CS Fixer | |
run: tools/php-cs-fixer check --diff --verbose | |
- name: Run pretty-php | |
run: bin/pretty-php --diff | |
phpstan: | |
name: PHPStan | |
needs: | |
- check-ci-runs | |
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- "8.4" | |
- "7.4" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP and Composer | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
coverage: none | |
- name: Get Composer cache directory | |
id: get-composer-cache | |
shell: bash | |
run: printf 'cache_dir=%s\n' "$(composer config cache-files-dir)" >>"$GITHUB_OUTPUT" | |
- name: Cache PHP dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.get-composer-cache.outputs.cache_dir }} | |
key: composer-cache-${{ runner.os }}-${{ hashFiles('**/composer.json', '**/composer.lock') }} | |
restore-keys: composer-cache-${{ runner.os }}- | |
- name: Persist PHPStan cache | |
uses: actions/cache@v4 | |
with: | |
path: build/cache/phpstan | |
key: phpstan-cache-${{ runner.os }}-${{ matrix.php-version }}-${{ github.run_id }} | |
restore-keys: phpstan-cache-${{ runner.os }}-${{ matrix.php-version }}- | |
- name: Install PHP dependencies | |
run: composer install --no-interaction --no-progress | |
- name: Run PHPStan | |
run: vendor/bin/phpstan | |
unit-tests: | |
name: PHPUnit tests | |
needs: | |
- check-ci-runs | |
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
php-version: | |
- "8.4" | |
include: | |
- os: ubuntu-latest | |
php-version: "8.3" | |
- os: ubuntu-latest | |
php-version: "8.2" | |
- os: ubuntu-latest | |
php-version: "8.1" | |
- os: ubuntu-latest | |
php-version: "8.0" | |
- os: ubuntu-latest | |
php-version: "7.4" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP and Composer | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
extensions: none, ctype, dom, json, mbstring, openssl, tokenizer, xml, xmlwriter | |
coverage: pcov | |
- name: Get Composer cache directory | |
id: get-composer-cache | |
shell: bash | |
run: printf 'cache_dir=%s\n' "$(composer config cache-files-dir)" >>"$GITHUB_OUTPUT" | |
- name: Cache PHP dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.get-composer-cache.outputs.cache_dir }} | |
key: composer-cache-${{ runner.os }}-${{ hashFiles('**/composer.json', '**/composer.lock') }} | |
restore-keys: composer-cache-${{ runner.os }}- | |
- name: Install PHP dependencies | |
run: composer install --no-interaction --no-progress | |
- name: Run PHPUnit tests and generate code coverage report | |
id: run-phpunit-tests | |
shell: bash | |
run: | | |
php -dshort_open_tag=On vendor/bin/phpunit ${RUNNER_DEBUG+--debug} --no-coverage --coverage-clover=coverage.xml --log-junit=junit.xml && status=0 || status=$? | |
printf 'coverage_generated=%d\n' "$([[ -s coverage.xml ]] && echo 1 || echo 0)" >>"$GITHUB_OUTPUT" | |
printf 'results_generated=%d\n' "$([[ -s junit.xml ]] && echo 1 || echo 0)" >>"$GITHUB_OUTPUT" | |
(exit $status) | |
- name: Upload coverage to Codecov | |
if: ${{ !cancelled() && steps.run-phpunit-tests.outputs.coverage_generated == 1 }} | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() && steps.run-phpunit-tests.outputs.results_generated == 1 }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
build: | |
name: Build phar and man page | |
needs: | |
- check-ci-runs | |
- phpstan | |
- unit-tests | |
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }} | |
runs-on: ubuntu-latest | |
outputs: | |
artifact_name: ${{ steps.run-build-script.outputs.artifact_name }} | |
artifact_path: ${{ steps.run-build-script.outputs.artifact_path }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Pandoc | |
run: | | |
sudo apt-get update | |
sudo apt-get install pandoc | |
- name: Setup PHP and Composer | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "8.3" | |
coverage: none | |
- name: Get Composer cache directory | |
id: get-composer-cache | |
shell: bash | |
run: printf 'cache_dir=%s\n' "$(composer config cache-files-dir)" >>"$GITHUB_OUTPUT" | |
- name: Cache PHP dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.get-composer-cache.outputs.cache_dir }} | |
key: composer-cache-${{ runner.os }}-${{ hashFiles('**/composer.json', '**/composer.lock') }} | |
restore-keys: composer-cache-${{ runner.os }}- | |
- name: Install PHP dependencies | |
run: composer install --no-interaction --no-progress | |
# Run the phar and man builds separately and together to test each code | |
# path in the build script | |
- name: Run build script | |
id: run-build-script | |
run: | | |
scripts/build.sh | |
scripts/build.sh man | |
scripts/build.sh man worktree | |
cd build/dist | |
{ printf 'artifact_name=%s-snapshot-phar\n' "${GITHUB_REPOSITORY##*/}" && | |
printf 'artifact_path=%s\n' *.phar | head -n1 && | |
printf 'man_path=%s\n' *.[0-9] | head -n1; } | tee -a "$GITHUB_OUTPUT" >>"$GITHUB_ENV" | |
- name: Upload phar artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.artifact_name }} | |
path: build/dist/${{ env.artifact_path }} | |
- name: Upload man page artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.man_path }} | |
path: build/dist/${{ env.man_path }} | |
test-phar: | |
name: Test phar | |
needs: | |
- check-ci-runs | |
- build | |
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
php-version: | |
- "8.4" | |
include: | |
- os: ubuntu-latest | |
php-version: "8.3" | |
- os: ubuntu-latest | |
php-version: "8.2" | |
- os: ubuntu-latest | |
php-version: "8.1" | |
- os: ubuntu-latest | |
php-version: "8.0" | |
- os: ubuntu-latest | |
php-version: "7.4" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
extensions: none, json, mbstring, tokenizer | |
coverage: none | |
- name: Download phar artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build.outputs.artifact_name }} | |
- name: Run pretty-php | |
env: | |
artifact_path: ${{ needs.build.outputs.artifact_path }} | |
run: php "$artifact_path" --verbose | |
shell: bash | |
integration-tests: | |
name: Integration tests | |
needs: | |
- check-ci-runs | |
- build | |
- test-phar | |
if: ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }} | |
strategy: | |
fail-fast: false | |
matrix: | |
repository: | |
- laravel/framework | |
args: | |
- --include-if-php --preset laravel src tests bin | |
include: | |
- repository: drupal/drupal | |
args: --exclude '/\/(\.git|\.hg|\.svn|_?build|dist|vendor|core\/lib\/Drupal\/Component\/Transliteration\/data)\/$/' --include-if-php=/./ --preset drupal . | |
- repository: symfony/symfony | |
args: --include-if-php --preset symfony . | |
- repository: WordPress/WordPress | |
args: --include-if-php --preset wordpress . | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ matrix.repository }} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ matrix.repository }} | |
- name: Download phar artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build.outputs.artifact_name }} | |
- name: Run pretty-php | |
env: | |
artifact_path: ${{ needs.build.outputs.artifact_path }} | |
run: | | |
php "$artifact_path" --print-config ${{ matrix.args }} | tee .prettyphp | |
php "$artifact_path" --quiet --timers || { status=$? && [[ $status -eq 4 ]] || (exit $status); } |