70 lines
3.3 KiB
YAML
70 lines
3.3 KiB
YAML
name: Run 2.x PHPUnit tests
|
|
on:
|
|
schedule:
|
|
- cron: '0 8 * * *' # Run at 8AM UTC.
|
|
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:
|
|
- dbms: pgsql
|
|
DB_URL: pgsql://farm:farm@db/farm
|
|
- dbms: mariadb
|
|
DB_URL: mysql://farm:farm@db/farm
|
|
- dbms: sqlite
|
|
DB_URL: sqlite://localhost/sites/default/files/db.sqlite
|
|
steps:
|
|
- name: Print test matrix variables
|
|
run: echo "matrix.dbms=${{ matrix.dbms }}, matrix.DB_URL=${{ matrix.DB_URL }}"
|
|
- name: Checkout the repository
|
|
uses: actions/checkout@v2
|
|
- name: Set FARMOS_VERSION for push event.
|
|
if: ${{ !github.event.pull_request }}
|
|
run: |
|
|
echo "FARMOS_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
|
|
echo "FARMOS_REPO=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
|
|
- name: Set FARMOS_VERSION for pull request event.
|
|
if: ${{ github.event.pull_request }}
|
|
run: |
|
|
echo "FARMOS_VERSION=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
|
|
echo "FARMOS_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
|
|
- name: Build farmOS 2.x Docker image
|
|
run: docker build --build-arg FARMOS_REPO=https://github.com/${FARMOS_REPO} --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/${FARMOS_REPO} --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 PHP CodeSniffer
|
|
run: docker-compose exec -u www-data -T www phpcs /opt/drupal/web/profiles/farm
|
|
- 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: Test Drush site install with all modules
|
|
run: docker-compose exec -u www-data -T www drush site-install --db-url=${{ matrix.DB_URL }} farm farm.modules='all'
|