-
Notifications
You must be signed in to change notification settings - Fork 50
167 lines (140 loc) · 5.9 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
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
name: Haskell CI
on:
push:
branches: [ "master" ]
pull_request:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["8.10.7", "9.6.5", "9.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
# GHC versions older than ghc-9.2 are not supported on macos-latest
exclude:
- os: macos-latest
ghc: "8.10.7"
steps:
- name: Install Haskell
uses: input-output-hk/actions/haskell@latest
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.12.1.0
- uses: actions/checkout@v4
- name: Cabal update
run: cabal update
- name: Configure build
shell: bash
run: |
cp ".github/workflows/cabal.project.local.ci.$(uname -s)" cabal.project.local
echo "# cabal.project.local"
cat cabal.project.local
# A dry run `build all` operation does *NOT* download anything, it just looks at the package
# indices to generate an install plan.
- name: Build dry run
run: cabal build all --enable-tests --dry-run --minimize-conflict-set
# From the install plan a dependency list is generated here.
- name: Record dependencies
id: record-deps
run: |
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so
# we are very deliberate about only adding msys64 to the path where absolutely necessary.
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
# From the dependency list the cached dependencies is restored.
# The hash of `dependencies.txt` is used as a part of the cache key because that will be stable
# until the `index-state` values in the `cabal.project` file changes.
- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
# The dependencies are installed. If the cache is found and restored in the previous step,
# this should be a no-op. If the cache key is not found the build assets are produced for the
# caching in the next step.
- name: Install dependencies
run: cabal build all --enable-tests --only-dependencies -j --ghc-option=-j4
# Always store the cabal cache.
# This may benignly fail if the cache key is already populated.
- name: Cache Cabal store
uses: actions/cache/save@v4
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
- name: Build Windows
if: runner.os == 'Windows'
id: build-step-windows
run: |
cabal build all --enable-tests -j --ghc-option=-j4
if ( "${{ runner.os }}" -eq "Windows" ) {
echo "exe-location=D:\a\cardano-addresses\cardano-addresses\dist-newstyle\build\x86_64-windows\ghc-${{ matrix.ghc }}\cardano-addresses-4.0.0\x\cardano-address\build\cardano-address\cardano-address.exe" >> $env:GITHUB_OUTPUT
}
- name: Build Linux/Macos
if: runner.os != 'Windows'
run: cabal build all --enable-tests -j --ghc-option=-j4
- name: Running all tests
env:
# these two are msys2 env vars, they have no effect on non-msys2 installs.
MSYS2_PATH_TYPE: inherit
MSYSTEM: MINGW64
run: cabal test all --enable-tests --test-show-details=direct -j1
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: cardano-address-${{ matrix.ghc }}-${{ matrix.os }}
path: ${{ steps.build-step-windows.outputs.exe-location }}
retention-days: 1
- name: Preparing Linux/Macos artifact
if: runner.os != 'Windows'
run: |
mkdir artifacts
for exe in $(cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[] | select(.style == "local" and (."component-name" | startswith("exe:"))) | ."bin-file"'); do
if [ -f $exe ]; then
echo "Including artifact $exe"
artifactName="$(basename $exe).tar.gz"
( cd artifacts
tar -C "$(dirname $exe)" -czf "$(basename $exe).tar.gz" "$(basename $exe)"
)
else
echo "Skipping artifact $exe"
fi
done
echo "artifactPath=artifacts/$(artifactName)" >> $GITHUB_ENV
- name: Upload Linux/Macos artifact
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: cardano-address-${{ matrix.ghc }}-${{ matrix.os }}
path: ${{ env.artifactPath }}
retention-days: 1
release:
name: "Release"
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- name: Pick artifacts to publish and change names
run: |
sha256sums_filename="cardano-address-4.0.0-sha256sums.txt"
sha256sum cardano-address-*/* >> "$sha256sums_filename"
mv cardano-address-9.6.5-windows-latest/cardano-address.exe cardano-address-4.0.0-win64.exe
mv cardano-address-9.6.5-macos-latest/cardano-address.tar.gz cardano-address-4.0.0-macos.tar.gz
mv cardano-address-9.6.5-ubuntu-latest/cardano-address.tar.gz cardano-address-4.0.0-linux.tar.gz
- name: Draft Release
uses: softprops/action-gh-release@v2
with:
draft: true
files: |
cardano-address-*-win64.exe
cardano-address-*-macos.tar.gz
cardano-address-*-linux.tar.gz
cardano-address-*-sha256sums.txt