-
-
Notifications
You must be signed in to change notification settings - Fork 195
154 lines (139 loc) · 6.01 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
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
- nightly
# Discussion seems to indicate that continue-on-error is not exactly equivalent to Travis's allow_failures, but it's the best we can do for now.
# If failures on nightly cause too much confusion in CI status,
# consider just not running against the nightly resolver.
# https://github.com/actions/toolkit/issues/399
continue-on-error: ${{ matrix.resolver == 'nightly' }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- 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).
if [ "${{ matrix.resolver }}" = "lts-from-exercises" ]; then
resolver=$(yq eval .resolver "$(ls -1 exercises/practice/*/stack.yaml | head -1)")
else
resolver=${{ matrix.resolver }}
fi
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@704facf57e6136b1bc63b828d79edcd491f0ee84
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@v2
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: |
# Explicit set exercises' resolver only if it's not the current one.
if [ "${{ matrix.resolver }}" != "lts-from-exercises" ]; then
export SET_RESOLVER="--resolver ${{ matrix.resolver }}"
fi
if [ "${{ matrix.resolver }}" = "nightly" ]; then
# allow nightly to fail - note that continue-on-error is inadequate.
# https://github.com/actions/toolkit/issues/399
for exercise in ${{ github.workspace }}/exercises/{concept,practice}/*; do
bin/warn-on-failure time bin/test-stub $exercise
bin/warn-on-failure time bin/test-all-examples $exercise
done
else
for exercise in ${{ github.workspace }}/exercises/{concept,practice}/*; do
time bin/test-stub $exercise
time bin/test-all-examples $exercise
done
fi