|
7 | 7 | pull_request: |
8 | 8 | branches: |
9 | 9 | - '1.x' |
10 | | - |
11 | | -env: |
12 | | - LOCALGOV_DRUPAL_PROJECT: localgovdrupal/localgov_forms |
13 | | - LOCALGOV_DRUPAL_PROJECT_PATH: web/modules/contrib/localgov_forms |
| 10 | + workflow_dispatch: |
14 | 11 |
|
15 | 12 | jobs: |
16 | | - |
17 | | - build: |
18 | | - name: Install LocalGov Drupal |
19 | | - runs-on: ubuntu-latest |
20 | | - |
21 | | - strategy: |
22 | | - fail-fast: false |
23 | | - matrix: |
24 | | - include: |
25 | | - - localgov-version: '2.x' |
26 | | - drupal-version: '~9.4' |
27 | | - php-version: '8.1' |
28 | | - - localgov-version: '3.x' |
29 | | - drupal-version: '~10.0' |
30 | | - php-version: '8.1' |
31 | | - |
32 | | - steps: |
33 | | - |
34 | | - - name: Save git branch and git repo names to env if this is not a pull request |
35 | | - if: github.event_name != 'pull_request' |
36 | | - run: | |
37 | | - echo "GIT_BASE=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV |
38 | | - echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV |
39 | | - echo "HEAD_USER=localgovdrupal" >> $GITHUB_ENV |
40 | | -
|
41 | | - - name: Save git branch and git repo names to env if this is a pull request |
42 | | - if: github.event_name == 'pull_request' |
43 | | - run: | |
44 | | - echo "GIT_BASE=${GITHUB_BASE_REF}" >> $GITHUB_ENV |
45 | | - echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV |
46 | | - export HEAD="${{ github.event.pull_request.head.label }}" |
47 | | - echo "HEAD_USER=${HEAD%%:*}" >> $GITHUB_ENV |
48 | | -
|
49 | | - - name: Set composer branch reference for version branches |
50 | | - if: endsWith(github.ref, '.x') |
51 | | - run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV |
52 | | - |
53 | | - - name: Set composer branch reference for non-version branches |
54 | | - if: endsWith(github.ref, '.x') == false |
55 | | - run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV |
56 | | - |
57 | | - - name: Get the latest tagged release for branch version |
58 | | - run: | |
59 | | - LATEST_RELEASE=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${GIT_BASE%'.x'} | grep -Po '(?<=refs/tags/)[^"]+' | tail -1) |
60 | | - if [ -z $LATEST_RELEASE ]; then LATEST_RELEASE=1; fi |
61 | | - echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV |
62 | | -
|
63 | | - - name: Cached workspace |
64 | | - uses: actions/cache@v2 |
65 | | - with: |
66 | | - path: ./html |
67 | | - key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} |
68 | | - |
69 | | - - name: Setup PHP |
70 | | - uses: shivammathur/setup-php@v2 |
71 | | - with: |
72 | | - php-version: ${{ matrix.php-version }} |
73 | | - |
74 | | - - name: Clone drupal_container |
75 | | - uses: actions/checkout@v2 |
76 | | - with: |
77 | | - repository: localgovdrupal/drupal-container |
78 | | - ref: php${{ matrix.php-version }} |
79 | | - |
80 | | - - name: Create LocalGov Drupal project |
81 | | - run: | |
82 | | - composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}" |
83 | | - composer --working-dir=./html require --no-install localgovdrupal/localgov:${{ matrix.localgov-version }}-dev |
84 | | - composer --working-dir=./html 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 }} |
85 | | - composer --working-dir=./html install |
86 | | -
|
87 | | - - name: Obtain the test target using Composer |
88 | | - if: env.HEAD_USER == 'localgovdrupal' |
89 | | - run: | |
90 | | - composer --working-dir=html config repositories.1 vcs [email protected]:${LOCALGOV_DRUPAL_PROJECT}.git |
91 | | - composer global config github-oauth.github.com ${{ github.token }} |
92 | | - composer --working-dir=./html require --with-all-dependencies ${LOCALGOV_DRUPAL_PROJECT}:"${COMPOSER_REF} as ${LATEST_RELEASE}" |
93 | | - # Obtain test dependency. |
94 | | - composer --working-dir=./html require --dev --with-all-dependencies geocoder-php/nominatim-provider |
95 | | -
|
96 | | - - name: Obtain the test target using Git |
97 | | - if: env.HEAD_USER != 'localgovdrupal' |
98 | | - uses: actions/checkout@v2 |
99 | | - with: |
100 | | - path: ${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }} |
101 | | - |
102 | | - phpcs: |
103 | | - name: Coding standards checks |
104 | | - needs: build |
105 | | - runs-on: ubuntu-latest |
106 | | - |
107 | | - strategy: |
108 | | - fail-fast: false |
109 | | - matrix: |
110 | | - include: |
111 | | - - localgov-version: '2.x' |
112 | | - drupal-version: '~9.4' |
113 | | - php-version: '8.1' |
114 | | - - localgov-version: '3.x' |
115 | | - drupal-version: '~10.0' |
116 | | - php-version: '8.1' |
117 | | - |
118 | | - steps: |
119 | | - |
120 | | - - name: Cached workspace |
121 | | - uses: actions/cache@v2 |
122 | | - with: |
123 | | - path: ./html |
124 | | - key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} |
125 | | - restore-keys: | |
126 | | - localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- |
127 | | -
|
128 | | - - name: Setup PHP |
129 | | - uses: shivammathur/setup-php@v2 |
130 | | - with: |
131 | | - php-version: ${{ matrix.php-version }} |
132 | | - |
133 | | - - name: Run coding standards checks |
134 | | - run: | |
135 | | - cd html |
136 | | - ./bin/phpcs -p ${LOCALGOV_DRUPAL_PROJECT_PATH} |
137 | | -
|
138 | | - phpstan: |
139 | | - name: Deprecated code checks |
140 | | - needs: build |
141 | | - runs-on: ubuntu-latest |
142 | | - |
143 | | - strategy: |
144 | | - fail-fast: false |
145 | | - matrix: |
146 | | - include: |
147 | | - - localgov-version: '2.x' |
148 | | - drupal-version: '~9.4' |
149 | | - php-version: '8.1' |
150 | | - - localgov-version: '3.x' |
151 | | - drupal-version: '~10.0' |
152 | | - php-version: '8.1' |
153 | | - |
154 | | - steps: |
155 | | - |
156 | | - - name: Cached workspace |
157 | | - uses: actions/cache@v2 |
158 | | - with: |
159 | | - path: ./html |
160 | | - key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} |
161 | | - restore-keys: | |
162 | | - localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- |
163 | | -
|
164 | | - - name: Setup PHP |
165 | | - uses: shivammathur/setup-php@v2 |
166 | | - with: |
167 | | - php-version: ${{ matrix.php-version }} |
168 | | - |
169 | | - - name: Run deprecated code checks |
170 | | - run: | |
171 | | - cd html |
172 | | - ./bin/phpstan analyse -c ./phpstan.neon ${LOCALGOV_DRUPAL_PROJECT_PATH} |
173 | | - phpunit: |
174 | | - name: PHPUnit tests |
175 | | - needs: build |
176 | | - runs-on: ubuntu-latest |
177 | | - |
178 | | - strategy: |
179 | | - fail-fast: false |
180 | | - matrix: |
181 | | - include: |
182 | | - - localgov-version: '2.x' |
183 | | - drupal-version: '~9.4' |
184 | | - php-version: '8.1' |
185 | | - - localgov-version: '3.x' |
186 | | - drupal-version: '~10.0' |
187 | | - php-version: '8.1' |
188 | | - |
189 | | - steps: |
190 | | - |
191 | | - - name: Clone Drupal container |
192 | | - uses: actions/checkout@v2 |
193 | | - with: |
194 | | - repository: localgovdrupal/drupal-container |
195 | | - ref: php${{ matrix.php-version }} |
196 | | - |
197 | | - - name: Cached workspace |
198 | | - uses: actions/cache@v2 |
199 | | - with: |
200 | | - path: ./html |
201 | | - key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }} |
202 | | - restore-keys: | |
203 | | - localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}- |
204 | | -
|
205 | | - - name: Start Docker environment |
206 | | - run: docker-compose -f docker-compose.yml up -d |
207 | | - |
208 | | - - name: Run PHPUnit tests |
209 | | - run: | |
210 | | - mkdir -p ./html/web/sites/simpletest && chmod 777 ./html/web/sites/simpletest |
211 | | - sed -i "s#http://localgov.lndo.site#http://drupal#" ./html/phpunit.xml.dist |
212 | | - docker exec -t drupal bash -c 'chown docker:docker -R /var/www/html' |
213 | | - docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/paratest --processes=4 /var/www/html/${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}" |
| 13 | + tests: |
| 14 | + uses: localgovdrupal/localgov_shared_workflows/.github/workflows/[email protected] |
| 15 | + with: |
| 16 | + project: 'localgovdrupal/localgov_forms' |
| 17 | + project_path: 'web/modules/contrib/localgov_forms' |
0 commit comments