-
Notifications
You must be signed in to change notification settings - Fork 30
81 lines (81 loc) · 2.81 KB
/
test-validate.yaml
File metadata and controls
81 lines (81 loc) · 2.81 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
name: validate
on:
pull_request:
push:
jobs:
oasdiff_validate_valid:
runs-on: ubuntu-latest
name: Test validate on a valid spec
steps:
- name: checkout
uses: actions/checkout@v6
- name: Running validate action on a valid spec
id: test_validate_valid
uses: ./validate
with:
spec: 'specs/valid.yaml'
- name: Test validate reports zero findings
run: |
findings="${{ steps.test_validate_valid.outputs.findings }}"
if [ "$findings" != "0" ]; then
echo "Expected 0 findings, got '$findings'" >&2
exit 1
fi
oasdiff_validate_findings:
runs-on: ubuntu-latest
name: Test validate fails on an invalid spec
steps:
- name: checkout
uses: actions/checkout@v6
- name: Running validate action on an invalid spec
id: test_validate_findings
continue-on-error: true
uses: ./validate
with:
spec: 'specs/invalid.yaml'
- name: Test validate failed and reported findings
run: |
if [ "${{ steps.test_validate_findings.outcome }}" != "failure" ]; then
echo "Expected the validate step to fail on error-level findings" >&2
exit 1
fi
findings="${{ steps.test_validate_findings.outputs.findings }}"
if [ "$findings" = "0" ] || [ -z "$findings" ]; then
echo "Expected findings > 0, got '$findings'" >&2
exit 1
fi
oasdiff_validate_fail_on:
runs-on: ubuntu-latest
name: Test validate severity threshold (--fail-on)
steps:
- name: checkout
uses: actions/checkout@v6
- name: Validate a warning-only spec with the default threshold
id: test_validate_warn_default
uses: ./validate
with:
spec: 'specs/validate-warning.yaml'
- name: Default threshold reports the warning but passes
run: |
if [ "${{ steps.test_validate_warn_default.outcome }}" != "success" ]; then
echo "Expected the step to pass (warnings don't fail by default)" >&2
exit 1
fi
warnings="${{ steps.test_validate_warn_default.outputs.warning_count }}"
if [ "$warnings" != "1" ]; then
echo "Expected warning_count 1, got '$warnings'" >&2
exit 1
fi
- name: Validate the same spec with fail-on WARN
id: test_validate_warn_failon
continue-on-error: true
uses: ./validate
with:
spec: 'specs/validate-warning.yaml'
fail-on: 'WARN'
- name: fail-on WARN escalates the warning to a failure
run: |
if [ "${{ steps.test_validate_warn_failon.outcome }}" != "failure" ]; then
echo "Expected the step to fail with fail-on WARN" >&2
exit 1
fi