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

81 lines
3.6 KiB
YAML
Raw Normal View History

name: Run 2.x PHPUnit tests
on:
2021-01-30 02:02:05 +01:00
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:
2021-01-19 16:32:55 +01:00
- dbms: pgsql
DB_URL: pgsql://farm:farm@db/farm
processes: auto
2021-01-19 16:32:55 +01:00
- dbms: mariadb
DB_URL: mysql://farm:farm@db/farm
processes: auto
2021-01-19 16:32:55 +01:00
- dbms: sqlite
DB_URL: sqlite://localhost/sites/default/files/db.sqlite
processes: 1
# Allow all three database tests to run even when one fails.
# This is a temporary workaround for Issue #3241653: Occasional test
# failures with SQLite: SQLSTATE[HY000]: General error: 5 database is
# locked
# @todo https://www.drupal.org/project/farm/issues/3241653
fail-fast: false
steps:
2021-01-19 16:32:55 +01:00
- 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
2021-01-15 03:12:59 +01:00
- name: Set FARMOS_VERSION for push event.
if: ${{ !github.event.pull_request }}
run: |
echo "FARMOS_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
2021-01-15 03:12:59 +01:00
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
2021-01-15 03:12:59 +01:00
echo "FARMOS_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
- name: Build farmOS 2.x Docker image
2021-01-15 03:12:59 +01:00
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} -t farmos/farmos:2.x-dev docker/dev
# Build a new docker-compose.yml file from docker-compose.testing.common + docker-compose.testing.{dbms}.yml.
# Copy to the current directory so that farmOS volume mounts don't change to the docker/www folder.
- name: Create docker-compose.yml
env:
DB_URL: ${{ matrix.DB_URL }}
run: |
cp docker/docker-compose.testing.* .
docker-compose -f docker-compose.testing.common.yml -f docker-compose.testing.${{ matrix.dbms }}.yml config > docker-compose.yml
- name: Start containers
run: docker-compose up -d
- name: Wait until www container is ready
# The www-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/www-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
run: docker-compose exec -u www-data -T www paratest --verbose=1 --processes=${{ matrix.processes }} /opt/drupal/web/profiles/farm
- name: Test Drush site install with all modules
2021-03-18 16:51:53 +01:00
run: docker-compose exec -u www-data -T www drush site-install --db-url=${{ matrix.DB_URL }} farm farm.modules='all'