-
Notifications
You must be signed in to change notification settings - Fork 164
218 lines (194 loc) · 7.92 KB
/
stack.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Source: github.com/andreasabel/agda2lagda/.github/workflows/stack.yml
name: Stack build
on:
push:
branches: [ master, 'ci-*' ]
tags: [ 'v*' ]
pull_request:
types: [ opened, synchronize ]
workflow_dispatch:
# For making a release, we need write permissions.
# TODO: if we split out a release job from the build job, we could make permissions more fine-grained.
permissions:
contents: write
jobs:
build:
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Note: check release logic below when changing the matrix!
ghc: ['9.8', '9.6', '9.4', '9.2', '9.0', '8.10', '8.8', '8.6', '8.4', '8.2']
os: [ubuntu-latest]
include:
- os: macOS-latest
ghc: '9.8'
- os: windows-latest
ghc: '9.8'
# Needed for Windows to make piping (... >> ...) and evaluation ( $(...) ) work.
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Setup Haskell
uses: haskell-actions/setup@v2
id: haskell-setup # <-- self-chosen identifier
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
cabal-update: false
- name: Environment settings based on the Haskell setup
shell: bash
run: |
echo "runner.os = ${{ runner.os }}"
echo "ghc-path = ${{ steps.haskell-setup.outputs.ghc-path }}"
echo "cabal-path = ${{ steps.haskell-setup.outputs.cabal-path }}"
echo "stack-path = ${{ steps.haskell-setup.outputs.stack-path }}"
echo "cabal-store = ${{ steps.haskell-setup.outputs.cabal-store }}"
echo "ghc-exe = ${{ steps.haskell-setup.outputs.ghc-exe }}"
echo "cabal-exe = ${{ steps.haskell-setup.outputs.cabal-exe }}"
echo "stack-exe = ${{ steps.haskell-setup.outputs.stack-exe }}"
echo "stack-root = ${{ steps.haskell-setup.outputs.stack-root }}"
GHC_VER=$(ghc --numeric-version)
CABAL_VER=$(cabal --numeric-version)
STACK_VER=$(stack --numeric-version)
STACK_FLAGS="--stack-yaml stack-${{ matrix.ghc }}.yaml --system-ghc --no-terminal --color always"
TARGET=$(if [ "${{ runner.os }}" == "Windows" ]; then echo ":bnfc"; fi)
echo "GHC_VER = ${GHC_VER}"
echo "CABAL_VER = ${CABAL_VER}"
echo "STACK_VER = ${STACK_VER}"
echo "STACK_FLAGS = ${STACK_FLAGS}"
echo "TARGET = ${TARGET}"
echo "GHC_VER=${GHC_VER}" >> "${GITHUB_ENV}"
echo "CABAL_VER=${CABAL_VER}" >> "${GITHUB_ENV}"
echo "STACK_VER=${STACK_VER}" >> "${GITHUB_ENV}"
echo "STACK_FLAGS=${STACK_FLAGS}" >> "${GITHUB_ENV}"
echo "TARGET=${TARGET}" >> "${GITHUB_ENV}"
# Stack build TARGET restriction on Windows as it cannot build the 'testing' package.
# From now on, use env.{GHC|CABAL}_VER rather than matrix.{ghc|cabal}-ver!
- name: Cache dependencies
uses: actions/cache@v4
env:
key: ${{ runner.os }}-stack-${{ env.STACK_VER }}-ghc-${{ env.GHC_VER }}
## Just stack.yaml is actually not correct, better would be stack.yaml.lock,
## but we do not commit this file. As a workaround, one could include the .cabal file,
## which tracks the dependencies (albeit in our case not precisely).
# key: ${{ runner.os }}-${{ env.STACK_VER }}-${{ hashFiles('source/BNFC.cabal', format('stack-{0}.yaml', env.GHC_VER)) }}
with:
path: ${{ steps.haskell-setup.outputs.stack-root }}
key: ${{ env.key }}-resolver-${{ hashFiles(format('stack-{0}.yaml', matrix.ghc)) }}
restore-keys: ${{ env.key }}-
- name: Build dependencies.
run: stack build ${{ env.TARGET }} ${{ env.STACK_FLAGS }} --only-dependencies
- name: Build bnfc w/o tests.
run: stack build ${{ env.TARGET }} ${{ env.STACK_FLAGS }}
- name: Build bnfc and run tests.
run: stack build ${{ env.TARGET }} ${{ env.STACK_FLAGS }} --test
# # matrix.ghc != '8.4.4' &&
# if: >-
# matrix.ghc != '8.2.2'
# Fall back to string comparison as version-comparison does not seem to work.
# Exclude the versions that do not support bnfc-system-tests
- name: Run bnfc.
run: |
BNFC_EXE=$(stack path --local-install-root ${{ env.STACK_FLAGS }})/bin/bnfc
BNFC_VERSION=$("${BNFC_EXE}" --numeric-version)
# Save env variables for the next steps
echo "BNFC_EXE=${BNFC_EXE}" >> "${GITHUB_ENV}"
echo "BNFC_VERSION=${BNFC_VERSION}" >> "${GITHUB_ENV}"
## Release
########################################################################
- name: Source tarball creation.
# Conditional to ensure this deployment is only run once per action.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& matrix.ghc == '9.8'
run: |
DIST_TGZ=$(cabal sdist source | tail -1)
echo "DIST_TGZ=${DIST_TGZ}" >> "${GITHUB_ENV}"
- name: Source tarball release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& matrix.ghc == '9.8'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.DIST_TGZ }}
- name: Linux release preparation.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Linux'
&& matrix.ghc == '9.8'
run: |
BNFC_BIN=bnfc-${BNFC_VERSION}-linux.binary
cp -p "${BNFC_EXE}" "${BNFC_BIN}"
# Save env variables for the next step
echo "BNFC_BIN=${BNFC_BIN}" >> "${GITHUB_ENV}"
- name: Linux release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Linux'
&& matrix.ghc == '9.8'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.BNFC_BIN }}
- name: Mac release preparation.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'macOS'
run: |
BNFC_BIN=bnfc-${BNFC_VERSION}-mac.binary
BNFC_PKG=bnfc-${BNFC_VERSION}-mac.pkg
# Raw Mac binary
cp -p "${BNFC_EXE}" "${BNFC_BIN}"
# Build Mac package
mkdir -p tmp/usr/local/bin
cp -p "${BNFC_EXE}" tmp/usr/local/bin/bnfc
pkgbuild \
--root tmp \
--identifier com.digitalgrammars.bnfc.pkg \
--version "${BNFC_VERSION}" \
--install-location / \
--ownership recommended \
"${BNFC_PKG}"
# Save env variables for the next step
echo "BNFC_BIN=${BNFC_BIN}" >> "${GITHUB_ENV}"
echo "BNFC_PKG=${BNFC_PKG}" >> "${GITHUB_ENV}"
- name: Mac release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'macOS'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.BNFC_BIN }}
${{ env.BNFC_PKG }}
- name: Windows release preparation.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Windows'
shell: bash
run: |
BNFC_VER_EXE=bnfc-${BNFC_VERSION}.exe
cp -p "${BNFC_EXE}.exe" "${BNFC_VER_EXE}"
# Save env variables for the next step
echo "BNFC_VER_EXE=${BNFC_VER_EXE}" >> "${GITHUB_ENV}"
- name: Windows release.
if: >-
startsWith(github.ref, 'refs/tags/v')
&& runner.os == 'Windows'
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
files: |
${{ env.BNFC_VER_EXE }}