-
-
Notifications
You must be signed in to change notification settings - Fork 194
130 lines (116 loc) · 4.82 KB
/
tests.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
name: Tests
on:
pull_request:
push:
branches:
- main
schedule:
# Weekly.
- cron: "0 0 * * 0"
jobs:
track-config:
name: Check track configuration
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# main is needed in addition to HEAD, because the README check only
# checks exercises changed since main. This fetches the entire repo's
# history.
fetch-depth: 0
- name: Ensure practice exercise descriptions are synced
run: bin/ensure-practice-exercise-descriptions-are-synced.sh
- name: Install yq (for stack resolvers)
run: |
sudo add-apt-repository -y ppa:rmescandon/yq
sudo apt-get -q update
sudo apt-get -y install yq
- name: Ensure stack resolvers are synced
run: bin/ensure-stack-resolvers-are-synced.sh
- name: Check for invalid UUIDs
# can be removed once `configlet lint` gains this ability.
# Check issue https://github.com/exercism/configlet/issues/99
# XXX: Consider adding this check for concept exercises.
run: |
uuids=$(jq --raw-output '.exercises.practice | map(.uuid) | .[]' config.json)
bad_uuid=$(echo "$uuids" | grep -vE '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' || true)
if [ -n "$bad_uuid" ]; then
echo "invalid UUIDs found! please correct these to be valid UUIDs:"
echo "$bad_uuid"
exit 1
fi
exercises:
name: Check exercises
runs-on: ubuntu-22.04
strategy:
matrix:
resolver:
# We say lts-from-exercises here instead of a specific version. Reason:
# Required CI checks are designated by their name + matrix values.
#
# If we wrote lts-A.B here,
# then we'd ask an admin to make "Check exercises (lts-A.B)" required.
# But what happens when we update to lts-C.D?
# Then, an admin would need to make "Check exercises (lts-A.B)" not required,
# and "Check exercises (lts-C.D)" required.
#
# We don't want to ask for that much admin intervention.
# So we write lts-from-exercises,
# and an admin only needs to make "Check exercises (lts-from-exercises)" required.
- lts-from-exercises
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install yq (for stack resolvers)
run: |
sudo add-apt-repository -y ppa:rmescandon/yq
sudo apt-get -q update
sudo apt-get -y install yq
- name: Resolve resolver
id: resolve-resolver
run: |
# We need this in two places:
# 1. cache key
# 2. --resolver arg to installing hlint
# It's unsafe to just use lts-from-exercises as the cache key,
# because that would cause caches from differing LTSes to collide
# (if we have updated the LTS version of all exercises between job runs).
resolver=$(yq eval .resolver "$(ls -1 exercises/practice/*/stack.yaml | head -1)")
echo "::set-output name=resolver::$resolver"
- name: Week number
id: week-no
run: |
# We use this to form part of the cache key.
# This will get us to periodically rebuild from scratch,
# just to make sure that everything still works from scratch.
# Because we also have a weekly build at the start of every week,
# most of the time caches should hit.
echo "::set-output name=week-no::$(date -u +%Y-%U)"
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: cache
with:
path: |
~/.stack
~/.foldercache
~/.local/bin/hlint
key: ${{ steps.resolve-resolver.outputs.resolver }}-${{ steps.week-no.outputs.week-no }}-${{ hashFiles('exercises/**/package.yaml') }}
restore-keys: ${{ steps.resolve-resolver.outputs.resolver }}-${{ steps.week-no.outputs.week-no }}-
- uses: haskell-actions/setup@dd344bc1cec854a369df8814ce17ef337d6e6170
with:
enable-stack: true
stack-version: "latest"
- name: Install hlint
run: |
if [ -x ${HOME}/.local/bin/hlint ]; then
echo already installed
else
stack --resolver ${{ steps.resolve-resolver.outputs.resolver }} install hlint
fi
${HOME}/.local/bin/hlint --version
- name: HLint
run: ${HOME}/.local/bin/hlint ${{ github.workspace }}
- name: Check exercises
run: |
for exercise in ${{ github.workspace }}/exercises/{concept,practice}/*; do
time bin/test-stub $exercise
time bin/test-all-examples $exercise
done