forked from department-of-veterans-affairs/va.gov-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.yml
225 lines (205 loc) · 7.76 KB
/
tests.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# If any of these test names get updated they need to be updated here too
# https://github.com/department-of-veterans-affairs/va.gov-cms/settings/branches
version: '3'
dotenv: ['.env']
output: 'group'
tasks:
# Any changes to test names or additions or removals must be updated in set-all-tests-pending as well for the Pending status to work.
va/tests/behat:
desc: Behat Tests
cmds:
- |
cat <<EOF | bash
: "${SKIP_REPORTING:=0}"
: "${RETURN_EXIT_CODE:=0}"
set -o pipefail
output="\$(mktemp -d)/output"
mkfifo \$output
(cat \$output&)
cd tests/behat
result="\$(time behat --strict --colors 2>&1 | tee \$output)"
exit_code=\$?
if [ "$SKIP_REPORTING" -ne 1 ]; then
if [ "\$exit_code" -eq 0 ]; then
github-status-updater -action=update_state -state=success -context='{{ .TASK }}' -description='Success'
else
github-status-updater -action=update_state -state=failure -context='{{ .TASK }}' -description='Failed'
fi
fi
if [ "$RETURN_EXIT_CODE" -ne 0 ]; then
exit "\$exit_code";
fi
EOF
va/tests/cypress:
desc: Accessibility and Behavioral tests with Cypress
cmds:
- |
cat <<EOF | bash
: "${SKIP_REPORTING:=0}"
: "${RETURN_EXIT_CODE:=0}"
set -o pipefail
output="\$(mktemp -d)/output"
mkfifo \$output
(cat \$output&)
result="\$(time composer va:test:cypress 2>&1 | tee \$output)"
exit_code=\$?
if [ "$SKIP_REPORTING" -ne 1 ]; then
if [ "\$exit_code" -eq 0 ]; then
github-status-updater -action=update_state -state=success -context='{{ .TASK }}' -description='Success'
else
github-status-updater -action=update_state -state=failure -context='{{ .TASK }}' -description='Failed'
fi
fi
if [ "$RETURN_EXIT_CODE" -ne 0 ]; then
exit "\$exit_code";
fi
EOF
va/tests/phplint:
desc: PHP Lint
cmds:
- |
cat <<EOF | bash
: "${SKIP_REPORTING:=0}"
: "${RETURN_EXIT_CODE:=0}"
exit_code=0
result="{{ .TASK }}<br/><br/>"
trap '{ (( exit_code |=\$? )); result+="\$output_text<br/>"; }' ERR
output_text=\$(find docroot/modules/custom docroot/themes -name '*.inc' -o -name '*.php' -o -name '*.module' -o -name '*.install' -print0 | xargs -0 -n1 php -l 2>&1)
trap - ERR
if [ "$SKIP_REPORTING" -ne 1 ]; then
if [ "\$exit_code" -eq 0 ]; then
github-status-updater -action=update_state -state=success -context='{{ .TASK }}' -description='Success'
else
github-status-updater -action=update_state -state=failure -context='{{ .TASK }}' -description='Failed'
[ "\${GITHUB_COMMENT_TYPE}" == "pr" ] && github-commenter -delete-comment-regex="{{ .TASK }}" -comment="\${result}"
fi
fi
if [ "$RETURN_EXIT_CODE" -ne 0 ]; then
exit "\$exit_code";
fi
EOF
va/tests/phpunit:
desc: PHPUnit
cmds:
- |
cat <<EOF | bash
: "${SKIP_REPORTING:=0}"
: "${RETURN_EXIT_CODE:=0}"
set -o pipefail
output="\$(mktemp -d)/output"
mkfifo \$output
(cat \$output&)
result="\$(time phpunit --group functional --exclude-group disabled tests/phpunit --colors=always 2>&1 | tee \$output)"
exit_code=\$?
if [ "$SKIP_REPORTING" -ne 1 ]; then
if [ "\$exit_code" -eq 0 ]; then
github-status-updater -action=update_state -state=success -context='{{ .TASK }}' -description='Success'
else
github-status-updater -action=update_state -state=failure -context='{{ .TASK }}' -description='Failed'
fi
fi
if [ "$RETURN_EXIT_CODE" -ne 0 ]; then
exit "\$exit_code";
fi
EOF
va/tests/status-error:
desc: Check for Drupal status errors
cmds:
- |
cat <<EOF | bash
: "${SKIP_REPORTING:=0}"
: "${RETURN_EXIT_CODE:=0}"
set -o pipefail
output="\$(mktemp -d)/output"
mkfifo \$output
(cat \$output&)
lines=\$(drush $DRUSH_ALIAS core-requirements --format=list --ignore='update_core,update_contrib,"update status"' --severity=2 2>&1 | tee \$output)
line_count=\$(grep -c "\S" <<< \$lines)
if [ "$SKIP_REPORTING" -ne 1 ]; then
if [ "\$line_count" -eq 0 ]; then
github-status-updater -action=update_state -state=success -context='{{ .TASK }}' -description='Success: No Drupal status requirement errors were found.'
else
github-status-updater -action=update_state -state=failure -context='{{ .TASK }}' -description="Failed: \${line_count} Drupal status requirements found."
[ "\${GITHUB_COMMENT_TYPE}" == "pr" ] && github-commenter -delete-comment-regex="{{ .TASK }}" -comment="{{ .TASK }}:<br /><br /><pre>\$(drush $DRUSH_ALIAS core-requirements --severity=2)</pre>"
fi
fi
if [ "$RETURN_EXIT_CODE" -ne 0 ]; then
exit "\$line_count";
fi
EOF
va/tests/content-build-gql:
desc: Ensure that the content build graphql queries succeed
cmds:
- |
cat <<EOF | bash
: "${SKIP_REPORTING:=0}"
: "${RETURN_EXIT_CODE:=0}"
set -o pipefail
output="\$(mktemp -d)/output"
mkfifo \$output
(cat \$output&)
result="\$(composer va:test:content-build-gql 2>&1 | tee \$output)"
exit_code=\$?
if [ "$SKIP_REPORTING" -ne 1 ]; then
if [ "\$exit_code" -eq 0 ]; then
github-status-updater -action=update_state -state=success -context='{{ .TASK }}' -description='Success'
else
github-status-updater -action=update_state -state=failure -context='{{ .TASK }}' -description='Failed'
fi
fi
if [ "$RETURN_EXIT_CODE" -ne 0 ]; then
exit "\$exit_code";
fi
EOF
set-check-status:
cmds:
- |
if [ "$SKIP_REPORTING" -ne 1 ]; then
github-status-updater -action=update_state -state="{{ .STATUS }}" -context="{{ .CONTEXT }}" -description="{{ .DESCRIPTION }}"
fi
set-all-tests-pending:
deps:
# Any changes to test names or additions or removals above must be updated here as well for the Pending status to work.
- task: set-check-status
vars:
STATUS: pending
CONTEXT: va/tests/behat
DESCRIPTION: 'Behat'
- task: set-check-status
vars:
STATUS: pending
CONTEXT: va/tests/cypress
DESCRIPTION: 'Cypress Accessibility/Behavioral'
- task: set-check-status
vars:
STATUS: pending
CONTEXT: va/tests/phplint
DESCRIPTION: 'PHPLint'
- task: set-check-status
vars:
STATUS: pending
CONTEXT: va/tests/phpunit
DESCRIPTION: 'PHPUnit'
- task: set-check-status
vars:
STATUS: pending
CONTEXT: va/tests/status-error
DESCRIPTION: 'Check for Drupal status errors'
- task: set-check-status
vars:
STATUS: pending
CONTEXT: va/tests/content-build-gql
DESCRIPTION: 'Ensure that the content build graphql queries succeed'
default:
cmds:
- task: set-all-tests-pending
- task: va/tests
va/tests:
desc:
deps:
- va/tests/behat
- va/tests/cypress
- va/tests/phplint
- va/tests/phpunit
- va/tests/status-error
- va/tests/content-build-gql