-
-
Notifications
You must be signed in to change notification settings - Fork 1
269 lines (219 loc) · 10.2 KB
/
Copy pathtest.yml
File metadata and controls
269 lines (219 loc) · 10.2 KB
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
name: Test
on:
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
yamllint:
name: 'Lint Yaml'
uses: PHPCSStandards/.github/.github/workflows/reusable-yamllint.yml@8ab4abdb86d0a69a15ea85472ab7dd5c44a37759 # v1.2.0
with:
strict: true
markdownlint:
name: 'Lint Markdown'
uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@8ab4abdb86d0a69a15ea85472ab7dd5c44a37759 # v1.2.0
remark:
name: 'QA Markdown'
uses: PHPCSStandards/.github/.github/workflows/reusable-remark.yml@8ab4abdb86d0a69a15ea85472ab7dd5c44a37759 # v1.2.0
# Validate the "valid" XSD files used in the tests.
validate-xsds:
name: 'Validate XSD files'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Validate XSD file [1]
uses: ./
with:
pattern: tests/fixtures/xsd-files/valid-local.xsd
xsd-url: https://www.w3.org/2012/04/XMLSchema.xsd
- name: Validate XSD file [2]
uses: ./
with:
pattern: docs/test-fixtures/valid-remote.xsd
xsd-url: https://www.w3.org/2012/04/XMLSchema.xsd
test:
needs: [yamllint, validate-xsds]
name: "${{ matrix.name }}"
runs-on: ubuntu-latest
strategy:
matrix:
include:
####################################################
# Basic action input handling.
####################################################
# Test input handling: missing required input.
- name: "Test required input missing"
expected: "fail"
####################################################
# Basic well-formedness tests.
####################################################
# Test basic well-formedness validation.
- name: "Test no XSD, valid XML"
pattern: tests/fixtures/valid-basic.xml
expected: success
- name: "Test no XSD, invalid XML"
pattern: tests/fixtures/invalid-basic.xml
expected: fail
# Test that glob patterns are handled correctly.
- name: "Test no XSD, glob, valid XML files"
pattern: ./tests/fixtures/all-valid-basic/*.xml
expected: success
- name: "Test no XSD, glob, invalid XML files"
pattern: ./tests/*/some-valid-basic/*.xml
expected: fail
####################################################
# Validate against a local XSD file.
####################################################
# Test input handling: optional XSD file.
- name: "Test XSD file wrong file extension"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/wrong-extension.notxsd
expected: "fail"
- name: "Test XSD file doesn't exist"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/file-does-not-exist.xsd
expected: "fail"
- name: "Test XSD file empty"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/file-is-empty.xsd
expected: "fail"
# Test validating against a local XSD schema.
- name: "Test XSD file, valid XML + schema"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "success"
- name: "Test XSD file, invalid XML"
pattern: tests/fixtures/invalid-basic.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "fail"
- name: "Test XSD file, valid XML, not schema"
pattern: tests/fixtures/invalid-local.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "fail"
# Test that glob patterns are handled correctly in combination with a local XSD schema.
- name: "Test XSD file, glob, valid XML + schema"
pattern: ./tests/fixtures/all-valid-local-xsd/*.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "success"
- name: "Test XSD file, glob, valid XML, not schema"
pattern: ./tests/fixtures/some-*-local-xsd/*.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
expected: "fail"
####################################################
# Validate against an (originally) remote XSD file.
####################################################
# Test input handling: optional XSD URL.
- name: "Test XSD URL wrong scheme"
pattern: tests/fixtures/valid-local.xml
xsd-url: file://tests/fixtures/valid-local.xml
expected: "fail"
- name: "Test XSD URL wrong file extension"
pattern: tests/fixtures/valid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/wrong-extension.notxsd
expected: "fail"
- name: "Test XSD URL doesn't exist"
pattern: tests/fixtures/valid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/file-does-not-exist.xsd
expected: "fail"
- name: "Test XSD URL empty"
pattern: tests/fixtures/valid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/file-is-empty.xsd
expected: "fail"
# Test validating against a (originally) remote XSD schema.
- name: "Test remote XSD file, valid XML"
pattern: tests/fixtures/valid-remote.xml
xsd-url: http://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "success"
- name: "Test remote XSD file, valid XML, not valid against schema"
pattern: tests/fixtures/invalid-remote.xml
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "fail"
# Safeguard that a local XSD file always takes precedence over a remote XSD URL.
- name: "Test local XSD overrules remote [1]"
pattern: tests/fixtures/valid-local.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "success"
- name: "Test local XSD overrules remote [2]"
pattern: tests/fixtures/valid-remote.xml
xsd-file: tests/fixtures/xsd-files/valid-local.xsd
xsd-url: https://phpcsstandards.github.io/xmllint-validate/test-fixtures/valid-remote.xsd
expected: "fail"
####################################################
# Support "Show in PR".
####################################################
# The default behaviour (enabled, not explicitly passed) is tested via all the other tests.
# Even though we can't safeguard the underlying functionality via CI, it can be
# confirmed the toggle functionality works correctly by looking at the "Annotations" fold-out
# above the logs for the individual jobs which have a "fail" expectation.
# Safeguard that explicitly enabling/disabling the show-in-pr option doesn't break anything.
- name: "Test show-in-pr: bool true"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: true
expected: "fail"
- name: "Test show-in-pr: string true"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: 'true'
expected: "fail"
- name: "Test show-in-pr: bool false"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: false
expected: "fail"
- name: "Test show-in-pr: string false"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: 'false'
expected: "fail"
# Any other value should have no influence and the default behaviour (annotations = on) should prevail.
- name: "Test show-in-pr: unsupported value"
pattern: tests/fixtures/invalid-basic.xml
show-in-pr: somethingElse
expected: "fail"
####################################################
# Verbose vs non-verbose output.
####################################################
# Re-run a few tests with verbosity on to allow for viewing the difference in the output.
# Safeguard that explicitly enabling/disabling the debug option doesn't break anything.
- name: "Debug off, valid XML"
pattern: tests/fixtures/valid-basic.xml
debug: false
expected: "success"
- name: "Debug on, invalid XML"
pattern: ./tests/*/some-valid-basic/*.xml
debug: true
expected: "fail"
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Run the test
id: xmllint-validate
continue-on-error: true
uses: ./
with:
pattern: ${{ matrix.pattern }}
xsd-file: ${{ matrix.xsd-file }}
xsd-url: ${{ matrix.xsd-url }}
show-in-pr: ${{ matrix.show-in-pr }}
debug: ${{ matrix.debug }}
- name: "Check the result of a successful test against expectation"
if: ${{ steps.xmllint-validate.outcome == 'success' }}
run: |
if [ "${{ matrix.expected == 'fail' }}" == "true" ]; then
exit 1
fi
- name: "Check the result of a failed test against expectation"
if: ${{ steps.xmllint-validate.outcome != 'success' }}
run: |
if [ "${{ matrix.expected == 'success' }}" == "true" ]; then
exit 1
fi