Skip to content

Commit

Permalink
Split GitHub CI tests into separate jobs (localgovdrupal/localgov#178) (
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-cox authored May 4, 2021
1 parent 5606a1e commit 4eaba04
Showing 1 changed file with 109 additions and 17 deletions.
126 changes: 109 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test LocalGov Drupal
name: Test LocalGov Drupal Geo module

on:
push:
Expand All @@ -7,39 +7,131 @@ on:
branches: [ master ]

jobs:
test:

build:
name: Install LocalGov Drupal
runs-on: ubuntu-latest

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Clone drupal_container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: master

- name: Create LocalGov Drupal project
run: composer create-project --stability dev localgovdrupal/localgov-project html
run: composer create-project --stability dev localgovdrupal/localgov-project ./html

- name: Save git branch and git repo names to env if this is not a pull request
if: github.event_name != 'pull_request'
run: |
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_REPO=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
- name: Save git branch and git repo names to env if this is a pull request
if: github.event_name == 'pull_request'
run: |
echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
echo "GIT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
- name: Setup package source for the test target
- name: Setup package source and authentication for the test target
run: |
composer --working-dir=html config repositories.1 vcs git@github.com:${{ github.repository }}.git
composer --working-dir=html config repositories.1 vcs git@github.com:${GIT_REPO}.git
composer global config github-oauth.github.com ${{ github.token }}
- name: Extract Git branch name outside of a pull request
if: github.event_name != 'pull_request'
run: echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Obtain the test target from the repo that triggered this workflow
run: composer --working-dir=html require --with-all-dependencies localgovdrupal/${{ github.event.repository.name }}:"dev-${GIT_BRANCH} as 1.0.x-dev"

- name: Extract Git branch name from a pull request
if: github.event_name == 'pull_request'
run: echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
phpcs:
name: Coding standards checks
needs: build
runs-on: ubuntu-latest

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-localgov-build-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Run coding standards checks
run: |
cd html
./bin/phpcs -p
- name: Grab test target
run: composer --working-dir=html require ${{ github.repository }}:"dev-${GIT_BRANCH} as 1.0.x-dev"
phpstan:
name: Deprecated code checks
needs: build
runs-on: ubuntu-latest

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-localgov-build-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Run deprecated code checks
run: |
cd html
./bin/phpstan analyse -c ./phpstan.neon ./web/profiles/contrib/localgov/ ./web/modules/contrib/localgov_*
phpunit:
name: PHPUnit tests
needs: build
runs-on: ubuntu-latest

steps:

- name: Clone drupal_container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: master

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-localgov-build-
- name: Start Docker environment
run: docker-compose up -d
run: docker-compose -f docker-compose.yml up -d

- name: Run tests
run: ./run-tests.sh
shell: bash
- name: Run PHPUnit tests
run: |
mkdir -p ./html/web/sites/simpletest && chmod 777 ./html/web/sites/simpletest
sed -i "s#http://localgov.lndo.site#http://drupal#; s#mysql://database:database@database/database#sqlite://localhost//dev/shm/test.sqlite#" ./html/phpunit.xml.dist
docker exec -t drupal bash -c 'chown docker:docker -R /var/www/html'
# docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/phpunit --testdox"
docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/paratest --processes=4"

0 comments on commit 4eaba04

Please sign in to comment.