Skip to content

Tests

Tests #2

Workflow file for this run

name: Tests
on:
# Run testing on all push and pull requests for the master branch that have committed changes in PHP files
push:
branches: [ "master" ]
paths:
- '**.php'
pull_request:
branches: [ "master" ]
paths:
- '**.php'
# Make it possible to run the workflow manually
workflow_dispatch:
permissions:
contents: read
env:
LANG: "sl_SI.utf8"
jobs:
test:
runs-on: ${{ matrix.os }}
# Define the matrix of different PHP and dependency versions
strategy:
# Fail the whole workflow if one of the jobs fails
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 7.4, 8.0, 8.1, 8.2 ]
name: ${{ matrix.os }} / PHP ${{ matrix.php }}
steps:
- name: Set up system locales
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y locales
sudo locale-gen ${{ env.LANG }}
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- 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-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
extensions: gettext
- name: Install dependencies
run: composer update --prefer-dist --no-progress --prefer-stable
- name: Run test suite
run: ./vendor/bin/phpunit --coverage-clover ./coverage.xml
- name: Upload coverage reports to Codecov
# Make sure the Codecov action is only executed once
if: matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
verbose: true