.github/workflows/build.yaml
name: Build and Test
on:
push:
branches:
- "*"
pull_request:
jobs:
unit_tests:
strategy:
fail-fast: true
matrix:
php: ["7.4", "8.0"]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite
run: composer run-script test
coverage:
runs-on: ubuntu-latest
needs: unit_tests
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
coverage: xdebug
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-8.0-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8.0-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run tests with phpunit/phpunit
run: composer run-script coverage
- name: Fix code coverage paths
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' reports/coverage.xml
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: reports/coverage.xml
integration_test:
strategy:
fail-fast: true
matrix:
laravel:
[
"5.1",
"5.2",
"5.3",
"5.4",
"5.5",
"5.6",
"5.7",
"5.8",
"6.0",
"7.0",
"8.0",
]
runs-on: ubuntu-latest
needs: [unit_tests]
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: Create Laravel Project
env:
LARAVEL_VERSION: ${{ matrix.laravel }}
PLUGIN_DIR: $GITHUB_WORKSPACE
run: bash .github/integration_test.sh
publish:
needs: integration_test
if: github.repository == 'RobBrazier/Laravel_Piwik' && (github.ref_name == 'master')
uses: ./.github/workflows/publish.yaml