3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00
farmOS/.github/workflows/run-tests.yml
Symbioquine 938d80101c Use a test matrix to run tests and site-install against MariaDB/SQLite/Postgres in parallel
**Why?** Detect if things break on specific DBMS' and have ongoing proof
that the top DB options work with farmOS.
2021-01-18 14:31:39 -05:00

58 lines
2.7 KiB
YAML

name: Run 2.x PHPUnit tests
on:
push:
branches:
- '2.x'
- '2.x-**'
pull_request:
branches:
- '2.x'
jobs:
build:
name: Run PHPUnit tests
runs-on: ubuntu-latest
strategy:
matrix:
dbms:
- pgsql
- mariadb
- sqlite
include:
- node: pgsql
DB_URL: pgsql://farm:farm@db/farm
- node: mariadb
DB_URL: mysql://farm:farm@db/farm
- node: sqlite
DB_URL: sqlite://localhost/sites/default/files/db.sqlite
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Set FARMOS_VERSION environment variable
run: echo "FARMOS_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Build farmOS 2.x Docker image
run: docker build --build-arg FARMOS_REPO=https://github.com/${GITHUB_REPOSITORY} --build-arg FARMOS_VERSION=${FARMOS_VERSION} -t farmos/farmos:2.x docker
# This builds the dev Docker image using the specified FARMOS_VERSION,
# but notably it does NOT override the default PROJECT_VERSION, so the
# farmOS Composer project 2.x branch is always used.
- name: Build farmOS 2.x-dev Docker image
run: docker build --build-arg FARMOS_REPO=https://github.com/${GITHUB_REPOSITORY} --build-arg FARMOS_VERSION=${FARMOS_VERSION} --build-arg WWW_DATA_ID=33 -t farmos/farmos:2.x-dev docker/dev
- name: Create docker-compose.yml
run: cp docker/docker-compose.testing.${{ matrix.dbms }}.yml docker-compose.yml
- name: Start containers
env:
DB_URL: ${{ matrix.DB_URL }}
run: docker-compose up -d
- name: Wait until test-runner container is ready
# The test-runner-container-fs-ready file is only created once we expect the containers to be online
# so waiting for that lets us know it is safe to start the tests
run: until [ -f ./www/test-runner-container-fs-ready ]; do sleep 0.1; done
- name: Run PHPUnit tests
# The overridden result printer is needed until Drupal 9.2 when the updated version of HtmlOutputPrinter will be available
# https://github.com/drupal/drupal/blob/74fbb0aabdee3e1a5da7b8e489a725afdc5824fd/core/tests/Drupal/Tests/Listeners/HtmlOutputPrinter.php
run: docker-compose exec -u www-data -T test-runner paratest --functional --passthru='--printer=PHPUnit\\TextUI\\DefaultResultPrinter' --verbose=1 /opt/drupal/web/profiles/farm
- name: Run PHP CodeSniffer
run: docker-compose exec -u www-data -T www phpcs /opt/drupal/web/profiles/farm
- name: Test Drush site install
run: docker-compose exec -u www-data -T www drush site-install --db-url=${{ matrix.DB_URL }}