-
Notifications
You must be signed in to change notification settings - Fork 4
135 lines (134 loc) · 4.23 KB
/
validate.yml
File metadata and controls
135 lines (134 loc) · 4.23 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
name: Dhall Validator
on:
push:
branches:
- "**"
tags-ignore:
- "**"
pull_request_target:
jobs:
good-file:
name: Validate Good File
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
validated: ${{ steps.validate.outcome }}
expected: success
steps:
- name: checkout-merge
if: contains(github.event_name, 'pull_request')
uses: actions/checkout@v6
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: checkout
if: ${{ !contains(github.event_name, 'pull_request') }}
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: dhall-validator-files
id: validate
continue-on-error: true
uses: ./
with:
dhall-files: tests/pass.dhall
verbose: 1
validate-files:
name: Validate Files
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
validated: ${{ steps.validate.outcome }}
expected: failure
steps:
- name: checkout-merge
if: contains(github.event_name, 'pull_request')
uses: actions/checkout@v6
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: checkout
if: ${{ !contains(github.event_name, 'pull_request') }}
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: dhall-validator-files
id: validate
continue-on-error: true
uses: ./
with:
dhall-files: |
tests/missing-env.dhall
tests/fail.dhall
tests/url.dhall
tests/pass.dhall
verbose: 1
validate-list:
name: Validate List
runs-on: ubuntu-latest
outputs:
validated: ${{ steps.validate.outcome }}
expected: failure
steps:
- name: checkout-merge
if: contains(github.event_name, 'pull_request')
uses: actions/checkout@v6
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: checkout
if: ${{ !contains(github.event_name, 'pull_request') }}
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: get tests
uses: actions/checkout@v6
with:
repository: dhall-lang/dhall-lang
path: dhall-lang
- name: build-list
shell: bash
run: |
git -C dhall-lang ls-files 'tests/parser/*/unit/Bool*.dhall' -z |
perl -e '$/="\0"; while (<>) {s#^#dhall-lang/#; print}' > /tmp/dhall-files.list
- name: dhall-validator-list
id: validate
continue-on-error: true
uses: ./
with:
dhall-file-list: /tmp/dhall-files.list
check-results:
name: Check Results
runs-on: ubuntu-latest
needs:
- good-file
- validate-files
- validate-list
if: success() || failure()
steps:
- name: Report
env:
GOOD_ACTUAL: ${{ needs.good-file.outputs.validated }}
GOOD_EXPECTED: ${{ needs.good-file.outputs.expected }}
FILES_ACTUAL: ${{ needs.validate-files.outputs.validated }}
FILES_EXPECTED: ${{ needs.validate-files.outputs.expected }}
LIST_ACTUAL: ${{ needs.validate-list.outputs.validated }}
LIST_EXPECTED: ${{ needs.validate-list.outputs.expected }}
EXPECTED: ${{ needs.good-file.outputs.validated == needs.good-file.outputs.expected && needs.validate-files.outputs.validated == needs.validate-files.outputs.expected && needs.validate-list.outputs.validated == needs.validate-list.outputs.expected }}
run: |
: Check for failing to catch validation errors
github_results_to_emoji() {
perl -pe 's/success/:white_check_mark:/g;s/failure/:x:/g'
}
(
echo '# Results'
echo 'Test|Result|Expected'
echo '-|-|-'
echo "Good Files|$GOOD_ACTUAL|$GOOD_EXPECTED"
echo "Files|$FILES_ACTUAL|$FILES_EXPECTED"
echo "File List|$LIST_ACTUAL|$LIST_EXPECTED"
) | github_results_to_emoji >> "$GITHUB_STEP_SUMMARY"
if [ "$EXPECTED" != true ]; then
echo "::error::Failed to properly perform validation"
exit 1
fi
echo "::notice::Validation properly handled good and bad cases"