Skip to content

Tests

Tests #206

Workflow file for this run

name: Tests
on:
schedule: # scheduled to run at 23.00 on Saturday (UTC), means 6.00 on Monday (WIB)
- cron: '0 23 * * 6'
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
jobs:
prepare:
name: Prepare
uses: projek-xyz/actions/.github/workflows/configure.yml@main
with:
php-version: 8.2
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
tests:
name: Test on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: prepare
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.composer-cache }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
- name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress
- name: Run tests
env:
BUILD_MATRIX: PHP ${{ matrix.php }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: |
composer testbench dusk:browserstack-local
composer test -- --coverage
- name: Generate reports for CodeClimate
if: needs.prepare.outputs.has-codeclimate == '1'
id: reports
env:
COVERAGE_FILE: tests/reports/clover.xml
CODECLIMATE_REPORT: tests/reports/codeclimate.${{ matrix.php }}.json
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
run: |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE
- name: Upload tests reports
uses: actions/upload-artifact@v4
if: needs.prepare.outputs.has-codeclimate == '1'
with:
name: test-reports-${{ matrix.php }}
path: tests/reports/codeclimate.*.json
reports:
name: Reports
needs: [prepare, tests]
if: needs.prepare.outputs.should-reports == '1'
uses: projek-xyz/actions/.github/workflows/report.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
has-codeclimate: ${{ needs.prepare.outputs.has-codeclimate == '1' }}