-
-
Notifications
You must be signed in to change notification settings - Fork 49
275 lines (238 loc) · 8.02 KB
/
test.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
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
270
271
272
273
274
275
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
repository_dispatch:
env:
CUSTOM_OUTPUT_RELATIVE_PATH: lychee/custom_output.md
CUSTOM_OUTPUT_ABSOLUTE_PATH: /tmp/report.md
CUSTOM_OUTPUT_DUMP_PATH: /tmp/dump.md
jobs:
lychee-action:
runs-on: ubuntu-latest
name: Test the lychee link checker action
steps:
- name: Checkout
uses: actions/checkout@v4
- name: test defaults
uses: ./
- name: test explicit lychee version
uses: ./
with:
lycheeVersion: v0.15.1
- name: test nightly lychee version
uses: ./
with:
lycheeVersion: nightly
- name: test latest lychee version
uses: ./
with:
lycheeVersion: latest
- name: test globs
uses: ./
with:
args: >-
--exclude-mail
--verbose
--no-progress
'./**/*.md'
'./**/*.html'
'./**/*.rst'
- name: test --base argument
uses: ./
with:
args: >-
--base .
--verbose
--no-progress
'./**/*.md'
'./**/*.html'
'./**/*.rst'
- name: test custom output relative path - creation
uses: ./
with:
output: "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}"
debug: true
- name: test custom output relative path - validation
run: |
echo "Checking custom output file at ${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}"
if [ ! -f "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}" ]; then
echo "Not found"
exit 1
else
echo "Found. Contents:"
cat "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}"
fi
- name: test custom output absolute path - creation
uses: ./
with:
output: "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}"
debug: true
- name: test custom output absolute path - validation
run: |
echo "Checking custom output file at ${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}"
if [ ! -f "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}" ]; then
echo "Not found"
exit 1
else
echo "Found. Contents:"
cat "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}"
fi
- name: test dump with custom output path - creation
uses: ./
with:
args: --dump './**/*.md' './**/*.html' './**/*.rst'
output: "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}"
debug: true
- name: test dump with custom output path - validation
run: |
echo "Checking dump output file at ${{ env.CUSTOM_OUTPUT_DUMP_PATH }}"
if [ ! -f "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}" ]; then
echo "Not found"
exit 1
else
echo "Found. Contents:"
cat "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}"
fi
- name: test output set in args and action input
id: output_set_in_args_and_action_input
uses: ./
with:
args: --output foo -
output: bar
continue-on-error: true
- name: test output set in args and action input should fail - validation
if: steps.output_set_in_args_and_action_input.outcome != 'failure'
run: |
echo "Output set in args and action input should have failed."
exit 1
- name: test fail - a lychee error should fail the pipeline
id: fail_test
uses: ./
with:
args: --verbose --no-progress foo.bar
debug: true
continue-on-error: true
# Explicitly check the exit code of the previous step
# as it's expected to fail
- name: Check fail
if: steps.fail_test.outcome != 'failure'
run: |
echo "Fail should have failed because the URL is invalid."
exit 1
- name: test disable fail - it's okay if lychee throws an error
uses: ./
with:
args: --no-progress foo.bar
fail: false
- name: test failIfEmpty - no links in input should fail the pipeline
id: fail_if_empty_test
uses: ./
with:
args: --verbose --no-progress fixtures/empty.md
debug: true
continue-on-error: true
# Explicitly check the exit code of the previous step
# as it's expected to fail
- name: Check failIfEmpty
if: steps.fail_if_empty_test.outcome != 'failure'
run: |
echo "FailIfEmpty should have failed because no links were found."
exit 1
- name: test disable failIfEmpty - it's okay if no links are found
uses: ./
with:
args: --no-progress fixtures/empty.md
failIfEmpty: false
- name: test disable failIfEmpty - a lychee error should still fail the pipeline
id: fail_but_not_failIfEmpty_test
uses: ./
with:
args: --verbose --no-progress foo.bar
failIfEmpty: false
debug: true
continue-on-error: true
# Explicitly check the exit code of the previous step
# as it's expected to fail
- name: Check fail when failIfEmpty is disabled
if: steps.fail_but_not_failIfEmpty_test.outcome != 'failure'
run: |
echo "Fail should have failed because the URL is invalid, even though failIfEmpty is disabled."
exit 1
- name: test disable fail - no links in input should still fail the pipeline
id: failIfEmpty_but_not_fail_test
uses: ./
with:
args: --verbose --no-progress fixtures/empty.md
fail: false
debug: true
continue-on-error: true
# Explicitly check the exit code of the previous step
# as it's expected to fail
- name: Check failIfEmpty when fail is disabled
if: steps.failIfEmpty_but_not_fail_test.outcome != 'failure'
run: |
echo "FailIfEmpty should have failed because no links were found, even though fail is disabled."
exit 1
- name: Install jq
run: sudo apt-get install jq
- name: test workflow inputs - Markdown
uses: ./
with:
args: -v fixtures/TEST.md
format: json
output: ${{ github.workspace }}/foo_md.json
- name: Validate JSON - Markdown
run: |
if ! jq empty ${{ github.workspace }}/foo_md.json; then
echo "Output file does not exist or is not valid JSON"
exit 1
fi
- name: test workflow inputs - rST
uses: ./
with:
args: -v fixtures/TEST.rst
format: json
output: ${{ github.workspace }}/foo_rst.json
- name: Validate JSON - rST
run: |
if ! jq empty ${{ github.workspace }}/foo_rst.json; then
echo "Output file does not exist or is not valid JSON"
exit 1
fi
- name: directory
uses: ./
with:
args: --exclude-mail .
- name: test format override
uses: ./
with:
args: --format markdown -v fixtures/TEST.md
format: doesnotexist # gets ignored if format set in args
output: ${{ github.workspace }}/foo.txt
- name: test debug
uses: ./
with:
debug: true
- name: test custom GitHub token
uses: ./
with:
token: ${{ secrets.CUSTOM_TOKEN }}
- name: Test exit code set in steps-output
id: lychee_exit_code_test
uses: ./
with:
args: -- inputdoesnotexist
continue-on-error: true
- name: Check exit code in steps.outputs
run: |
echo "Lychee exit code: ${{ steps.lychee_exit_code_test.outputs.exit_code }}"
if [[ "${{ steps.lychee_exit_code_test.outputs.exit_code }}" == "1" ]]; then
echo "Lychee correctly failed with exit code 1"
else
echo "Unexpected exit code: ${{ steps.lychee_exit_code_test.outputs.exit_code }}"
echo "Expected exit code 1"
exit 1
fi