-
Notifications
You must be signed in to change notification settings - Fork 2
162 lines (134 loc) · 4.89 KB
/
test.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: Haskell CI
on:
push:
branches: [master]
pull_request:
types: [opened, reopened, synchronize, labeled]
jobs:
enumerate:
name: Enumerate CI configurations
runs-on: ubuntu-latest
outputs:
configs: ${{ steps.enumerate.outputs.configs }}
steps:
- uses: actions/checkout@v3
- id: enumerate
run: |
ls -1 ci-configs/| grep -o -P '.*(?=.config)'| jq -n -R -c '[inputs]' | tee configs.json
echo "configs=$(cat configs.json)" >> $GITHUB_OUTPUT
build:
needs: enumerate
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
plan: ${{ fromJSON(needs.enumerate.outputs.configs) }}
steps:
- uses: actions/checkout@v3
- name: cache cabal store
uses: actions/cache@v3
with:
key: cabal-store-${{ runner.os }}-${{ matrix.plan }}-${{ github.sha }}
path: ~/.cabal/store
restore-keys: cabal-store-${{ runner.os }}-${{ matrix.plan }}-
- uses: actions/checkout@v3
with:
repository: 'dfinity/candid'
path: candid
ref: a8322be53bfced317bdf4ffff5dbc428d24dc612
- name: Detect GHC version
run: |
ver=$(grep -o -P '(?<=with-compiler: ghc-).*' ci-configs/${{ matrix.plan }}.config)
echo "Detected compiler version $ver in ci-configs/${{ matrix.plan }}.config"
echo "ghc_version=$ver" >> $GITHUB_ENV
- uses: haskell-actions/setup@v2
with:
ghc-version: ${{ env.ghc_version }}
ghcup-release-channel: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml
- name: Fetch cabal-force-upper-bounds
if: matrix.plan == 'upper-bounds'
run: |
curl -L https://github.com/nomeata/cabal-force-upper-bound/releases/latest/download/cabal-force-upper-bound.linux.gz | gunzip > /usr/local/bin/cabal-force-upper-bound
chmod +x /usr/local/bin/cabal-force-upper-bound
- name: Special handling for upper-bounds
if: matrix.plan == 'upper-bounds'
run: |
echo -n "extra_flags=" >> $GITHUB_ENV
cabal-force-upper-bound --allow-newer *.cabal >> $GITHUB_ENV
- name: Build
run: |
cabal --version
ghc --version
cabal update
# build first, so that the .ghc.environment file is written
cabal build --enable-tests --minimize-conflict-set --project-file "ci-configs/${{ matrix.plan }}.config" ${{ env.extra_flags }}
# then the doctest has a chance of succeeding
export CANDID_TESTS=$PWD/candid/test
cabal v2-test --project-file "ci-configs/${{ matrix.plan }}.config" ${{ env.extra_flags }}
- run: mv dist-newstyle/cache/plan.json plan-${{ matrix.plan }}.json
- name: Upload build plan as artifact
uses: actions/upload-artifact@v3
with:
name: plans
path: plan-${{ matrix.plan }}.json
bounds:
runs-on: ubuntu-latest
name: Calculate cabal bounds
needs:
- build
steps:
- uses: actions/checkout@v3
- name: Fetch cabal-plan-bounds
run: |
curl -L https://github.com/nomeata/cabal-plan-bounds/releases/latest/download/cabal-plan-bounds.linux.gz | gunzip > /usr/local/bin/cabal-plan-bounds
chmod +x /usr/local/bin/cabal-plan-bounds
- name: Load plans
uses: actions/download-artifact@v3
with:
name: plans
path: plans
- run: find plans/
- run: cabal-plan-bounds plans/*.json -c candid.cabal
- run: git diff candid.cabal
- name: Push updated .cabal file if labeled update-bounds
if: contains(github.event.pull_request.labels.*.name, 'update-bounds')
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update cabal bounds based on build plans
file_pattern: '*.cabal'
- name: Fail if .cabal file was changed
run: git diff-files --quiet candid.cabal|| exit 1
docs:
strategy:
matrix:
ghc:
- '8.10'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: cache cabal store
uses: actions/cache@v3
with:
key: cabal-store-docs-${{ runner.os }}-${{ github.sha }}
path: ~/.cabal/store
restore-keys: cabal-store-docs-${{ runner.os }}-
- uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
- name: Build
run: |
cabal --version
ghc --version
cabal update
cabal haddock --haddock-hyperlink-source --haddock-quickjump --haddock-html-location='https://hackage.haskell.org/package/$pkg-$version/docs'
mv dist-newstyle/build/*/*/*/doc/html/candid gh-page
touch gh-page/.nojekyll
- name: Deploy to Github Pages
if: github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: gh-page
SINGLE_COMMIT: true