Skip to content

Commit ee4a010

Browse files
authored
Updated Github CI to run against 2.x branch (#41)
1 parent 7cc1030 commit ee4a010

File tree

1 file changed

+71
-24
lines changed

1 file changed

+71
-24
lines changed

.github/workflows/test.yml

+71-24
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,103 @@ name: Test LocalGov Drupal Subsites
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- '2.x'
67
pull_request:
7-
branches: [ master ]
8+
branches:
9+
- '2.x'
810

911
jobs:
1012

1113
build:
1214
name: Install LocalGov Drupal
1315
runs-on: ubuntu-latest
1416

17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- localgov-version: "2.x"
22+
drupal-version: "~9.1"
23+
php-version: "7.4"
24+
1525
steps:
1626

27+
- name: Save git branch and git repo names to env if this is not a pull request
28+
if: github.event_name != 'pull_request'
29+
run: |
30+
echo "GIT_BASE=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
31+
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
32+
echo "GIT_REPO=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
33+
34+
- name: Save git branch and git repo names to env if this is a pull request
35+
if: github.event_name == 'pull_request'
36+
run: |
37+
echo "GIT_BASE=${GITHUB_BASE_REF}" >> $GITHUB_ENV
38+
echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
39+
echo "GIT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
40+
41+
- name: Set composer branch reference for version branches
42+
if: endsWith(github.ref, '.x')
43+
run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV
44+
45+
- name: Set composer branch reference for non-version branches
46+
if: endsWith(github.ref, '.x') == false
47+
run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV
48+
1749
- name: Cached workspace
1850
uses: actions/cache@v2
1951
with:
2052
path: ./html
21-
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
53+
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}
2254

2355
- name: Setup PHP
2456
uses: shivammathur/setup-php@v2
2557
with:
26-
php-version: '7.4'
58+
php-version: ${{ matrix.php-version }}
2759

2860
- name: Clone drupal_container
2961
uses: actions/checkout@v2
3062
with:
3163
repository: localgovdrupal/drupal-container
32-
ref: master
64+
ref: php${{ matrix.php-version }}
3365

3466
- name: Create LocalGov Drupal project
35-
run: composer create-project --stability dev localgovdrupal/localgov-project ./html
36-
37-
- name: Save git branch and git repo names to env if this is not a pull request
38-
if: github.event_name != 'pull_request'
3967
run: |
40-
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
41-
echo "GIT_REPO=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
42-
43-
- name: Save git branch and git repo names to env if this is a pull request
44-
if: github.event_name == 'pull_request'
45-
run: |
46-
echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
47-
echo "GIT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV
68+
composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}"
69+
composer require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }}
70+
composer install
4871
4972
- name: Setup package source and authentication for the test target
5073
run: |
5174
composer --working-dir=html config repositories.1 vcs [email protected]:${GIT_REPO}.git
5275
composer global config github-oauth.github.com ${{ github.token }}
5376
5477
- name: Obtain the test target from the repo that triggered this workflow
55-
run: composer --working-dir=html require --with-all-dependencies localgovdrupal/${{ github.event.repository.name }}:"dev-${GIT_BRANCH} as 1.0.x-dev"
78+
run: composer --working-dir=html require --with-all-dependencies localgovdrupal/${{ github.event.repository.name }}:"${COMPOSER_REF} as ${GIT_BASE}-dev"
5679

5780
phpcs:
5881
name: Coding standards checks
5982
needs: build
6083
runs-on: ubuntu-latest
6184

85+
strategy:
86+
fail-fast: false
87+
matrix:
88+
include:
89+
- localgov-version: "2.x"
90+
drupal-version: "~9.1"
91+
php-version: "7.4"
92+
6293
steps:
6394

6495
- name: Cached workspace
6596
uses: actions/cache@v2
6697
with:
6798
path: ./html
68-
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
99+
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}
69100
restore-keys: |
70-
${{ runner.os }}-localgov-build-
101+
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
71102
72103
- name: Setup PHP
73104
uses: shivammathur/setup-php@v2
@@ -84,15 +115,23 @@ jobs:
84115
needs: build
85116
runs-on: ubuntu-latest
86117

118+
strategy:
119+
fail-fast: false
120+
matrix:
121+
include:
122+
- localgov-version: "2.x"
123+
drupal-version: "~9.1"
124+
php-version: "7.4"
125+
87126
steps:
88127

89128
- name: Cached workspace
90129
uses: actions/cache@v2
91130
with:
92131
path: ./html
93-
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
132+
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}
94133
restore-keys: |
95-
${{ runner.os }}-localgov-build-
134+
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
96135
97136
- name: Setup PHP
98137
uses: shivammathur/setup-php@v2
@@ -109,6 +148,14 @@ jobs:
109148
needs: build
110149
runs-on: ubuntu-latest
111150

151+
strategy:
152+
fail-fast: false
153+
matrix:
154+
include:
155+
- localgov-version: "2.x"
156+
drupal-version: "~9.1"
157+
php-version: "7.4"
158+
112159
steps:
113160

114161
- name: Clone drupal_container
@@ -121,9 +168,9 @@ jobs:
121168
uses: actions/cache@v2
122169
with:
123170
path: ./html
124-
key: ${{ runner.os }}-localgov-build-${{ github.run_id }}
171+
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}
125172
restore-keys: |
126-
${{ runner.os }}-localgov-build-
173+
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-
127174
128175
- name: Start Docker environment
129176
run: docker-compose -f docker-compose.yml up -d

0 commit comments

Comments
 (0)