Switch to GitHub Actions #2
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: Continuous Integration | |
on: | |
push: | |
branches: [ "develop", "master" ] | |
pull_request: | |
branches: [ "develop", "master" ] | |
permissions: | |
contents: read | |
jobs: | |
compliance: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/[email protected] | |
with: | |
php-version: '8.3' | |
coverage: none | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Check style and compatibility | |
run: composer exec phpcs | |
test-latest: | |
runs-on: ubuntu-latest | |
needs: | |
- compliance | |
services: | |
mysql: | |
image: mariadb:10.11.9 | |
env: | |
MARIADB_USER: wptestuser | |
MARIADB_PASSWORD: wptestpass | |
MARIADB_ROOT_PASSWORD: wptestroot | |
MARIADB_DATABASE: wptest_latest | |
TZ: Europe/Berlin | |
ports: | |
- 3306/tcp | |
options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/[email protected] | |
with: | |
php-version: '8.3' | |
coverage: xdebug | |
extensions: mysqli | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Run unit tests | |
run: composer exec phpunit | |
- name: Set up integration test | |
run: ./bin/install-wp-tests.sh wptest_latest wptestuser wptestpass 127.0.0.1:${{ job.services.mysql.ports['3306'] }} latest true | |
- name: Run integration tests | |
run: composer exec phpunit -- -c phpunit-integration.xml | |
- name: Upload code coverage to Code Climate | |
uses: paambaati/[email protected] | |
env: | |
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} | |
with: | |
coverageLocations: | | |
${{github.workspace}}/build/logs/clover.xml:clover | |
${{github.workspace}}/build/logs/clover-integration.xml:clover | |
- name: Upload code coverage to Codecov (unit) | |
uses: codecov/[email protected] | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
directory: ${{github.workspace}}/build/logs/clover.xml | |
flags: unit | |
- name: Upload code coverage to Codecov (integration) | |
uses: codecov/[email protected] | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
directory: ${{github.workspace}}/build/logs/clover-integration.xml | |
flags: integration | |
test-minimum: | |
runs-on: ubuntu-latest | |
needs: | |
- compliance | |
services: | |
mysql: | |
image: mariadb:10.11.9 | |
env: | |
MARIADB_USER: wptestuser | |
MARIADB_PASSWORD: wptestpass | |
MARIADB_ROOT_PASSWORD: wptestroot | |
MARIADB_DATABASE: wptest_minimum | |
TZ: Europe/Berlin | |
ports: | |
- 3306/tcp | |
options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
id: setup-minimum-php | |
uses: shivammathur/[email protected] | |
with: | |
php-version: '7.4' | |
coverage: none | |
extensions: mysqli | |
- name: Downgrade PHPUnit | |
run: composer require --dev --update-with-all-dependencies --no-install --ignore-platform-req=php "phpunit/phpunit:^7.5" "mockery/mockery:1.3.6" "sebastian/comparator:^3.0" | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php-${{ steps.setup-minimum-php.outputs.php-version }}- | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Set up integration test | |
run: ./bin/install-wp-tests.sh wptest_minimum wptestuser wptestpass 127.0.0.1:${{ job.services.mysql.ports['3306'] }} 5.6 true | |
- name: Run integration tests | |
run: composer exec phpunit -- -c phpunit-integration.xml --no-coverage |