Repository navigation
115 lines (113 loc) · 4.14 KB
/
Copy pathtest-validate.yaml
File metadata and controls
115 lines (113 loc) · 4.14 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
name: validate
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
oasdiff_validate_valid:
runs-on: ubuntu-latest
name: Test validate on a valid spec
steps:
- name: checkout
uses: actions/checkout@v7
- 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@v7
- 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@v7
- 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
oasdiff_validate_unresolved_ref:
runs-on: ubuntu-latest
name: Test a failed validation is not reported as clean
steps:
- name: checkout
uses: actions/checkout@v7
- name: Run validate action against a spec that cannot be loaded
id: test_unresolved_ref
continue-on-error: true
uses: ./validate
with:
spec: 'specs/unresolved-ref.yaml'
- name: Assert the step failed and published no finding counts
run: |
if [ "${{ steps.test_unresolved_ref.outcome }}" != "failure" ]; then
echo "Expected the action to fail when the spec cannot be loaded" >&2
exit 1
fi
# A spec that never loaded produces no findings to count. Publishing
# 0 would read as a clean spec to anything gating on these.
if [ "${{ steps.test_unresolved_ref.outputs.findings }}" = "0" ]; then
echo "A failed validation must not report findings=0" >&2
exit 1
fi
if [ "${{ steps.test_unresolved_ref.outputs.error_count }}" = "0" ]; then
echo "A failed validation must not report error_count=0" >&2
exit 1
fi