-
Notifications
You must be signed in to change notification settings - Fork 5
201 lines (190 loc) · 7.38 KB
/
continuous_integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Continuous Integration
on:
pull_request:
paths-ignore:
- '**.md'
permissions:
pull-requests: write
issues: write
jobs:
# Check whether certain fields exist in the CMS configuration.
check-fields:
name: Check Fields
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Check Corresponding Entity Reference Fields
# See also `composer va:test:check-cer` in composer.json
run: ./tests/scripts/check-cer.sh
- name: Check Revision Log fields
# See also `composer va:test:check-node-revision-logs` in composer.json
# See also `composer va:test:check-taxonomy-revision-logs` in composer.json
run: |
./tests/scripts/check-node-revision-logs.sh
./tests/scripts/check-taxonomy-revision-logs.sh
# Validate that the `composer.lock` hash is up-to-date.
composer-validate:
name: Composer Validate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Composer Validate
run: composer validate
# Check style of ES/JS files with ESLint and ReviewDog.
eslint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Post-Checkout Actions
uses: ./.github/actions/post-checkout
- name: ReviewDog
# See also `composer va:test:eslint` in composer.json
uses: reviewdog/action-eslint@279acb08336462ec76183a2d9ef1dd43e4c6b391 # v1.21.0
with:
reporter: github-pr-review
eslint_flags: '--max-warnings 0 -c .eslintrc.json --no-eslintrc docroot/modules/custom/**/*.es6.js docroot/themes/custom/**/*.es6.js tests/cypress/**/*.js'
fail_on_error: true
# Check for common PHP code smells with PHP_CodeSniffer.
php_codesniffer:
name: PHP_CodeSniffer
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Post-Checkout Actions
uses: ./.github/actions/post-checkout
- name: Run PHP_CodeSniffer and ReviewDog
# See also `composer va:test:php_codesniffer` in composer.json
run: |
export REVIEWDOG_GITHUB_API_TOKEN="${GITHUB_TOKEN}"
bin/phpcs \
--report="checkstyle" \
-q \
| reviewdog \
-name="PHP_CodeSniffer" \
-f=checkstyle \
-reporter=github-pr-review \
-diff='git diff'
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Lint with PHP's built-in linting.
php_lint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Post-Checkout Actions
uses: ./.github/actions/post-checkout
- name: Run PHPLint
# See also `composer va:test:lint-php` in composer.json
run: ./tests/scripts/lint-php.sh
# Analyze the codebase for programming errors with PHPStan.
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Post-Checkout Actions
uses: ./.github/actions/post-checkout
- name: Run PHPStan and ReviewDog
# See also `composer va:test:phpstan` in composer.json
run: |
bin/phpstan analyze \
--no-progress \
--no-interaction \
--error-format=raw \
--memory-limit=1G \
| reviewdog \
-name="PHPStan" \
-f=phpstan \
-reporter=github-pr-review \
-fail-on-error=true \
-diff='git diff' \
-tee
env:
REVIEWDOG_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Run unit tests against codebase with PHPUnit.
phpunit:
name: PHPUnit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Post-Checkout Actions
uses: ./.github/actions/post-checkout
- name: Run PHPUnit (Unit Tests only)
# See also `composer va:test:phpunit-unit` in composer.json
run: bin/phpunit \
--group unit \
--exclude-group disabled \
--coverage-text \
tests/phpunit
# Check styles of modules and themes with Stylelint.
stylelint:
name: Stylelint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Stylelint modules
# See also `composer va:test:stylelint-modules` in composer.json
uses: reviewdog/action-stylelint@548276a94275c7865effa8d72fa8b6983d9f47c4 # v1.18.1
with:
fail_on_error: true
github_token: ${{ secrets.github_token }}
packages: 'stylelint-config-sass-guidelines stylelint-order'
reporter: github-pr-review
stylelint_config: '.stylelintrc'
stylelint_input: 'docroot/modules/custom/**/*.css'
- name: Stylelint themes
# See also `composer va:test:stylelint-themes` in composer.json
uses: reviewdog/action-stylelint@548276a94275c7865effa8d72fa8b6983d9f47c4 # v1.18.1
with:
fail_on_error: true
github_token: ${{ secrets.github_token }}
packages: 'stylelint-config-sass-guidelines stylelint-order'
reporter: github-pr-review
stylelint_config: '.stylelintrc'
stylelint_input: 'docroot/themes/custom/**/*.scss'
# Warn strongly if the `composer.lock` lines changed exceed a threshold.
check-composer-lock-changes:
name: Check composer.lock changes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Delete any existing comment.
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # v2.4.3
continue-on-error: true
with:
comment_tag: check-composer-lock-changes
mode: delete
message: |
Checking composer.lock changes...
- name: Check changes in composer.lock.
run: |
LINES_CHANGED=$(git diff --numstat origin/main..HEAD -- composer.lock | awk '{print $1+$2}')
THRESHOLD=200
>&2 echo "LINES CHANGED=$LINES_CHANGED"
>&2 echo "THRESHOLD=$THRESHOLD"
echo "LINES_CHANGED=$LINES_CHANGED" >> $GITHUB_ENV
echo "THRESHOLD=$THRESHOLD" >> $GITHUB_ENV
- name: Comment if composer.lock changes exceed threshold.
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # v2.4.3
if: env.LINES_CHANGED > env.THRESHOLD
continue-on-error: true
with:
comment_tag: check-composer-lock-changes
message: |
The number of lines changed in composer.lock exceeds the acceptable threshold.
- Lines changed: ${{ env.LINES_CHANGED }}
- Threshold: ${{ env.THRESHOLD }}
This is a warning only. Please review the changes and ensure that they are acceptable.