-
Notifications
You must be signed in to change notification settings - Fork 20
199 lines (168 loc) · 5.73 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CI
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
env:
EXE_NAME: fortran-src
jobs:
ubuntu-stack-test:
runs-on: ubuntu-latest
name: Ubuntu / Stack / test
steps:
- uses: actions/checkout@v4
# relative paths are relative to the project directory
- name: Cache Stack build artifacts (user + project)
uses: actions/cache@v4
with:
path: |
~/.stack
.stack-work
# best effort for cache: tie it to Stack resolver and package config
key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml.lock', 'package.yaml') }}
restore-keys: |
${{ runner.os }}-stack
- name: Install project dependencies
run: stack --no-terminal test --only-dependencies
- name: Build and run tests
run: stack --no-terminal haddock --test --no-haddock-deps
- name: Install (to place executable at a known location)
run: stack --no-terminal install
- name: Upload executable
uses: actions/upload-artifact@v4
with:
path: ~/.local/bin/${{ env.EXE_NAME }}
name: ${{ env.EXE_NAME }}-ubuntu-stack-${{ github.sha }}
if-no-files-found: error
ubuntu-cabal-test:
runs-on: ubuntu-latest
name: Ubuntu / GHC ${{ matrix.ghc }}, Cabal / test
strategy:
fail-fast: false # don't stop if one job (= GHC version) fails
matrix:
cabal: [latest]
ghc:
- "9.0"
- "9.2"
- "9.4"
steps:
# TODO: GHC decides to recompile based on timestamp, so cache isn't used
# Preferably GHC would work via hashes instead. Stack had this feature
# merged in Aug 2020.
# Upstream GHC issue: https://gitlab.haskell.org/ghc/ghc/-/issues/16495
# My issue on haskell/actions: https://github.com/haskell/actions/issues/41
# This also requires us to do a deep fetch, else we don't get the Git commit
# history we need to rewrite mod times.
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set all tracked file modification times to the time of their last commit
run: |
rev=HEAD
for f in $(git ls-tree -r -t --full-name --name-only "$rev") ; do
touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f";
done
- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v4
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- run: cabal freeze
- name: Cache Cabal build artifacts
uses: actions/cache@v4
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-cabal-${{ matrix.ghc }}
- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color
mac-cabal-test:
runs-on: macos-latest
name: Mac / GHC ${{ matrix.ghc }}, Cabal / test
strategy:
fail-fast: false # don't stop if one job (= GHC version) fails
matrix:
cabal: [latest]
ghc: ["9.2"]
steps:
# TODO figure out timestamp fixer on Mac (no Mac available to test)
- uses: actions/checkout@v4
- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v4
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- run: cabal freeze
- name: Cache Cabal build artifacts
uses: actions/cache@v4
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-cabal-${{ matrix.ghc }}
- name: Build
run: cabal install
- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color
# note that Cabal uses symlinks -- actions/upload-artifact@v4 apparently
# dereferences for us
- name: Upload executable
uses: actions/upload-artifact@v4
with:
path: ~/.cabal/bin/${{ env.EXE_NAME }}
name: ${{ env.EXE_NAME }}-macos-ghc-${{ matrix.ghc }}-cabal-${{ github.sha }}
if-no-files-found: error
windows-cabal-test:
runs-on: windows-latest
name: Windows / GHC ${{ matrix.ghc }}, Cabal / test
strategy:
fail-fast: false # don't stop if one job (= GHC version) fails
matrix:
cabal: [latest]
ghc: ["9.2"]
steps:
# TODO figure out timestamp fixer on Windows (need Bash)
- uses: actions/checkout@v4
- name: Setup Haskell build environment
id: setup-haskell-build-env
uses: haskell/actions/setup@v4
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- run: cabal freeze
- name: Cache Cabal build artifacts
uses: actions/cache@v4
with:
path: |
${{ steps.setup-haskell-build-env.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-cabal-${{ matrix.ghc }}
- name: Build
run: cabal install
- name: Test
run: cabal test --test-show-details=streaming
env:
HSPEC_OPTIONS: --color
- name: Upload executable
uses: actions/upload-artifact@v4
with:
path: "C:/cabal/bin/${{ env.EXE_NAME }}.exe"
name: ${{ env.EXE_NAME }}-windows-ghc-${{ matrix.ghc }}-cabal-${{ github.sha }}.exe
if-no-files-found: error