-
-
Notifications
You must be signed in to change notification settings - Fork 545
162 lines (132 loc) · 5.18 KB
/
ci.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
name: CI
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
required-files:
name: All required files are present
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: All required files are present
run: bin/check_required_files_present
immutability:
name: No test has been mutated
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
path: "new"
# Pull Requests
- name: Checkout the target branch
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: "${{ github.base_ref }}"
path: "old"
- name: Check that no test has been mutated
run: |
for oldf in old/exercises/*/canonical-data.json; do
newf=${oldf//old/new}
./new/bin/check-immutability.py "$oldf" "$newf"
done
schema-validation:
name: Schema validation
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Setup nodejs
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Verify that canonical-data.json files adhere to their json schema
run: yarn test
- name: Verify that all UUIDs are indeed unique
run: |
duplicate_uuids=$(cat exercises/*/canonical-data.json |
jq -r '.. |."uuid"? | select(. != null)' | # select all UUIDs
sort | uniq -d) # check for repeated UUIDs
if [ -n "$duplicate_uuids" ]; then
echo "The following UUIDs are not unique:"
echo "$duplicate_uuids"
exit 1
fi
- name: Verify that reimplements-values refer to existing UUID
run: |
fail=0
for f in exercises/*/canonical-data.json; do
# Search for reimplemented test cases
reimplements=$(jq -r '.. |."reimplements"? | select(. != null)' "$f")
# Abort early if the exercise doesn't have reimplemented test cases
[[ -e $reimplements ]] && continue
uuids=$(jq -r '.. |."uuid"? | select(. != null)' "$f")
for reimplemented_uuid in $reimplements; do
if [[ $uuids != *"$reimplemented_uuid"* ]]; then
echo "$f: reimplemented value refers to a test case with UUID $reimplemented_uuid, but the file does not contain any test cases with that UUID."
fail=1
fi
done
done
exit "$fail"
- name: Verify that all scenarios are defined in the schema
run: |
canonical_data_schema_file="canonical-data.schema.json"
scenarios_file="SCENARIOS.txt"
fail=0
while read -r scenario; do
jq -e ".definitions.scenario.enum | index(\"$scenario\")" $canonical_data_schema_file > /dev/null
if [ $? -eq 1 ]; then
echo "$canonical_data_schema_file: scenario '$scenario' is missing from the '.definitions.scenario.enum' field."
fail=1
fi
done < $scenarios_file
exit "$fail"
- name: Verify that all keys are in the correct order
run: ./bin/check_key_order.rb
markdown-lint:
name: Lint markdown files
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Lint markdown
uses: DavidAnson/markdownlint-cli2-action@bb4bb94c73936643d73d345b48fead3e96f90a5e # v10.0.1
with:
globs: |
**/*.md
check-links:
name: Check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Check links
uses: lycheeverse/lychee-action@ec3ed119d4f44ad2673a7232460dc7dff59d2421 # 1.8.0
with:
args: --require-https --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" --no-progress **/*.md **/*.html
fail: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
json-lint:
name: Lint json files
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Setup nodejs
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 16
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Verify that json files are formatted correctly
run: |
yarn format-json && ruby bin/format-array.rb
if ! git diff --quiet --exit-code; then
echo "please format the files with prettier and bin/format-array.rb, or apply the following changes:"
git diff
exit 1
fi