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 # 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 /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'