Composer: avoid writing a lock file #145
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: Test | |
on: | |
pull_request: | |
push: | |
# Allow manually triggering the workflow. | |
workflow_dispatch: | |
# Cancels all previous workflow runs for the same branch that have not yet completed. | |
concurrency: | |
# The concurrency group contains the workflow name and the branch name. | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php: | |
# PHP 5.3 is tested in coverage section | |
- '5.4' | |
- '5.5' | |
- '5.6' | |
- '7.0' | |
- '7.1' | |
- '7.2' | |
- '7.3' | |
- '7.4' | |
- '8.0' | |
- '8.1' | |
- '8.2' | |
# PHP 8.3 is tested in coverage section | |
experimental: [false] | |
include: | |
- php: '8.4' | |
experimental: true | |
name: "Test on PHP ${{ matrix.php }}" | |
continue-on-error: ${{ matrix.experimental }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
ini-values: 'zend.assertions=1, error_reporting=-1, display_errors=On' | |
coverage: none | |
tools: cs2pr | |
# Install dependencies and handle caching in one go. | |
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer | |
- name: Install Composer dependencies - normal | |
if: ${{ matrix.experimental == false }} | |
uses: "ramsey/composer-install@v3" | |
with: | |
# Bust the cache at least once a month - output format: YYYY-MM. | |
custom-cache-suffix: $(date -u "+%Y-%m") | |
# For the PHP "nightly", we need to install with ignore platform reqs as not all dependencies allow it. | |
- name: Install Composer dependencies - with ignore platform | |
if: ${{ matrix.experimental == true }} | |
uses: "ramsey/composer-install@v3" | |
with: | |
composer-options: --ignore-platform-reqs | |
custom-cache-suffix: $(date -u "+%Y-%m") | |
- name: Lint | |
run: composer phplint -- --checkstyle | cs2pr | |
- name: Grab PHPUnit version | |
id: phpunit_version | |
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT | |
- name: "Run unit tests (PHPUnit < 10)" | |
if: ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} | |
run: composer phpunit | |
- name: "Run unit tests (PHPUnit 10+)" | |
if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} | |
run: composer phpunit10 | |
coverage: | |
needs: test | |
# Don't run on forks. | |
if: github.repository_owner == 'php-parallel-lint' && needs.test.result == 'success' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- php: 5.3 | |
- php: 8.3 | |
name: "Coverage on PHP ${{ matrix.php }}" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup ini config | |
id: set_ini | |
run: | | |
# On PHP 5.3, short_open_tag needs to be turned on for short open echo tags to be recognized | |
# a PHP tags. As this only affects PHP 5.3, this is not something of serious concern. | |
if [ ${{ matrix.php }} == "5.3" ]; then | |
echo 'PHP_INI=zend.assertions=1, error_reporting=-1, display_errors=On, short_open_tag=On' >> $GITHUB_OUTPUT | |
else | |
echo 'PHP_INI=zend.assertions=1, error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT | |
fi | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
ini-values: ${{ steps.set_ini.outputs.PHP_INI }} | |
coverage: xdebug | |
tools: cs2pr | |
# Remove the PHPCS standard as it has a minimum PHP requirements of PHP 5.4 and would block install on PHP 5.3. | |
- name: 'Composer: remove PHPCS' | |
if: ${{ matrix.php < 5.4 }} | |
run: composer remove --dev php-parallel-lint/php-code-style --no-update --no-interaction | |
- name: Install Composer dependencies - normal | |
uses: "ramsey/composer-install@v3" | |
with: | |
# Bust the cache at least once a month - output format: YYYY-MM. | |
custom-cache-suffix: $(date -u "+%Y-%m") | |
- name: Lint | |
run: composer phplint -- --checkstyle | cs2pr | |
- name: Grab PHPUnit version | |
id: phpunit_version | |
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT | |
- name: "Run the unit tests with code coverage (PHPUnit < 10)" | |
if: ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} | |
run: composer coverage | |
- name: "Run the unit tests with code coverage (PHPUnit 10+)" | |
if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} | |
run: composer coverage10 | |
- name: Upload coverage results to Coveralls | |
if: ${{ success() }} | |
uses: coverallsapp/github-action@v2 | |
with: | |
format: clover | |
file: build/logs/clover.xml | |
flag-name: php-${{ matrix.php }} | |
parallel: true | |
coveralls-finish: | |
needs: coverage | |
# Don't run on forks. | |
if: github.repository_owner == 'php-parallel-lint' && needs.coverage.result == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Coveralls Finished | |
uses: coverallsapp/github-action@v2 | |
with: | |
parallel-finished: true |