Skip to content

build

build #468

Workflow file for this run

name: "build"
on:
pull_request:
paths-ignore:
- ".docs/**"
push:
branches:
- "master"
schedule:
- cron: "0 8 * * 1" # At 08:00 on Monday
env:
extensions: "json, pdo_mysql, pdo_sqlite, intl"
cache-version: "1"
composer-version: "v1"
composer-install: "composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable"
jobs:
qa:
name: "Quality assurance"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "8.0"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
- name: "Cache PHP dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
restore-keys: "${{ runner.os }}-composer-"
- name: "Validate Composer"
run: "composer validate"
- name: "Install dependencies"
run: "${{ env.composer-install }}"
- name: "Coding Standard"
run: "make cs"
static-analysis:
name: "Static analysis"
runs-on: "ubuntu-latest"
strategy:
matrix:
composer-args: [ "" ]
command: [ "phpstan" ]
include:
- composer-args: "--prefer-lowest"
command: "phpstan-lowest"
fail-fast: false
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "8.1"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
- name: "Cache PHP dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
restore-keys: "${{ runner.os }}-composer-"
- name: "Install dependencies"
run: "${{ env.composer-install }} ${{ matrix.composer-args }}"
- name: "PHPStan"
run: "make ${{ matrix.command}}"
tests:
name: "Tests"
runs-on: "${{ matrix.operating-system }}"
services:
mariadb:
image: "mariadb:10.4"
ports:
- "13306:3306"
env:
MYSQL_DATABASE: "test"
MYSQL_ROOT_PASSWORD: "1234"
options:
--mount type=tmpfs,destination=/var/lib/mysql
--health-cmd="mysqladmin ping"
--health-interval=5s
--health-timeout=2s
--health-retries=3
strategy:
matrix:
php-version: [ "8.0", "8.1", "8.2", "8.3" ]
operating-system: [ "ubuntu-latest" ]
composer-args: [ "" ]
include:
- php-version: "8.0"
operating-system: "ubuntu-latest"
composer-args: "--prefer-lowest"
fail-fast: false
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
- name: "Cache PHP dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
restore-keys: "${{ runner.os }}-composer-"
- name: "Install dependencies"
run: "${{ env.composer-install }} ${{ matrix.composer-args }}"
- name: "Setup problem matchers for PHPUnit"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"'
- name: "Tests"
run: "make tests"
tests-code-coverage:
if: "github.event_name == 'push'"
name: "Tests with code coverage"
runs-on: "ubuntu-latest"
services:
mariadb:
image: "mariadb:10.4"
ports:
- "13306:3306"
env:
MYSQL_DATABASE: "test"
MYSQL_ROOT_PASSWORD: "1234"
options:
--mount type=tmpfs,destination=/var/lib/mysql
--health-cmd="mysqladmin ping"
--health-interval=5s
--health-timeout=2s
--health-retries=3
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "8.0"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"
- name: "Cache PHP extensions"
uses: "actions/cache@v3"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
coverage: "xdebug"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }}"
- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
- name: "Cache PHP dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
restore-keys: "${{ runner.os }}-composer-"
- name: "Install dependencies"
run: "${{ env.composer-install }}"
- name: "Tests"
run: "make coverage"
- name: "Coveralls.io"
env:
CI_NAME: github
CI: true
COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.2/php-coveralls.phar
php php-coveralls.phar --verbose --config tests/.coveralls.yml