-
-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (124 loc) · 4 KB
/
haskell.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
name: Haskell CI
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "15 12 * * *"
jobs:
enumerate:
name: Generate Build Matrix Dynamically
runs-on: ubuntu-latest
outputs:
configs: ${{ steps.enumerate.outputs.configs }}
steps:
- uses: actions/checkout@v3
- name: Enumerate Configs
id: enumerate
run: |
set -euxo pipefail
find ci-configs -type f -name 'ghc-*.config' \
| sort -h | jq -ncR '[inputs | {ghc: match("ghc-(.+)\\.config$", .) | .captures[0].string | select(.), plan: .}]' | tee configs.json
echo "configs=$(cat configs.json)" >> "${GITHUB_OUTPUT}"
cabal-check:
name: Cabal Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: haskell-actions/setup@v2
with:
cabal-version: 3.10.2.0
enable-stack: false
- run: cabal check
build:
needs: [enumerate]
continue-on-error: true
strategy:
fail-fast: false
matrix:
include: ${{fromJSON(needs.enumerate.outputs.configs)}}
runs-on: ubuntu-latest
name: Haskell GHC ${{ matrix.ghc }} Build
env:
CABAL: cabal --project-file=${{matrix.plan}}
steps:
- uses: actions/checkout@v3
- uses: haskell-actions/setup@v2
with:
ghc-version: ${{matrix.ghc}}
cabal-version: 3.10.2.0
enable-stack: false
- name: Restore Cache ~/.cabal/store
uses: actions/cache/restore@v3
env:
cache-name: cache-cabal-store
with:
path: ~/.cabal/store
key: build-${{ runner.os }}-${{env.cache-name}}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}
restore-keys: |
build-${{ runner.os }}-${{env.cache-name}}-${{matrix.ghc}}-
- name: Cache dist-newstyle
uses: actions/cache@v3
env:
cache-name: cache-dist-newstyle
with:
path: dist-newstyle
key: build-${{ runner.os }}-${{ env.cache-name }}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
build-${{ runner.os }}-${{ env.cache-name }}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}-
build-${{ runner.os }}-${{ env.cache-name }}-${{matrix.ghc}}-
- name: Configure and Update
run: |
${CABAL} v2-configure --enable-tests --enable-benchmarks
${CABAL} v2-update
- name: Build Dependencies
run: |
${CABAL} v2-build all --only-dependencies
- name: Save Cache ~/.cabal/store
uses: actions/cache/save@v3
env:
cache-name: cache-cabal-store
with:
path: ~/.cabal/store
key: build-${{ runner.os }}-${{env.cache-name}}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}
- name: Build
run: |
${CABAL} v2-build all
- name: Collect binaries
run: ./scripts/collect-artifacts.sh artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: binaries-${{matrix.ghc}}-${{runner.os}}
path: artifacts.tar.zst
retention-days: 3
test:
needs: [enumerate, build]
strategy:
fail-fast: false
matrix:
include: ${{fromJSON(needs.enumerate.outputs.configs)}}
runs-on: ubuntu-latest
name: Haskell GHC ${{ matrix.ghc }} Test
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
id: download
with:
name: binaries-${{matrix.ghc}}-${{runner.os}}
- name: Extract and Run All Tests
run: |
set -euxo pipefail
DL_PATH=${{steps.download.outputs.download-path}}
unzstd "${DL_PATH}/artifacts.tar.zst"
tar xvf "${DL_PATH}/artifacts.tar"
set +x
find artifacts/tests -type f | while read -r TEST; do
echo "Executing: ${TEST}"
"${TEST}"
done
find artifacts/exes -type f | while read -r TEST; do
echo "Executing: ${TEST}"
"${TEST}"
done