forked from IntersectMBO/cardano-node
-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (207 loc) · 7.88 KB
/
haskell.yml
File metadata and controls
249 lines (207 loc) · 7.88 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Haskell CI
on:
push:
workflow_dispatch:
inputs:
reason:
description: 'Reason'
required: false
default: manual
tests:
description: 'Tests'
required: false
default: some
create:
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
ghc: ["8.10.4"]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Get path to bash
# This is necessary to invoke bash from Haskell in Windows, for example in tests.
# We invoke bash from Haskell in order to test bash scripts in CI to ensure they
# don't break.
if: matrix.os == 'windows-latest'
run: |
echo "BASH_PATH=$(cd $(dirname $(which bash)); pwd -W)/bash.exe" >> $GITHUB_ENV
- uses: haskell/actions/setup@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.4.0.0
- name: Set cache version
run: echo "CACHE_VERSION=grFfw8r" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Add build script path
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH
- name: Install pkgconfiglite
if: matrix.os == 'windows-latest'
run: retry 2 choco install -y pkgconfiglite
- name: Install libsodium (Windows)
if: matrix.os == 'windows-latest'
run: |
curl -Ls \
--connect-timeout 5 \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-mingw.tar.gz -o libsodium-1.0.18-mingw.tar.gz
tar zxvf libsodium-1.0.18-mingw.tar.gz
sed -i "s|/d/a/1/s/|D:/a/cardano-node/cardano-node/|g" libsodium-win64/lib/pkgconfig/libsodium.pc
export PKG_CONFIG_PATH="$(readlink -f libsodium-win64/lib/pkgconfig)"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
export LIBSODIUM_PATH="$(readlink -f libsodium-win64/bin | sed 's|^/d|D:|g' | tr / '\\')"
echo "LIBSODIUM_PATH=$LIBSODIUM_PATH"
echo "$LIBSODIUM_PATH" >> $GITHUB_PATH
- name: Install libsodium (MacOS)
if: matrix.os == 'macos-latest'
run: brew install libsodium
- name: Setup Github Scripts
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH
- name: Configure to use libsodium
run: |
cat >> cabal.project <<EOF
package cardano-crypto-praos
flags: -external-libsodium-vrf
EOF
- name: Haskell versions
run: |
ghc --version
cabal --version
- name: Install build environment
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get -y install libsodium23 libsodium-dev
sudo apt-get -y install libsystemd0 libsystemd-dev
sudo apt-get -y remove --purge software-properties-common
sudo apt-get -y autoremove
- name: Cabal update
run: retry 2 cabal update
- name: Configure build
run: |
if [ "${{github.event.inputs.tests}}" == "all" ]; then
echo "Reconfigure cabal projects to run tests for all dependencies"
cat cabal.project | sed 's|tests: False|tests: True|g' > cabal.project.new
mv cabal.project.new cabal.project
fi
cp .github/workflows/cabal.project.local.$RUNNER_OS cabal.project.local
- name: Record dependencies
run: |
cabal build all --dry-run
cat ${{ env.PLAN_JSON }} | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
date > date.txt
- uses: actions/cache@v2
name: Cache cabal store
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }}
restore-keys: |
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('date.txt') }}
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
- name: Build
run: retry 2 cabal build cardano-node cardano-cli cardano-node-chairman cardano-submit-api plutus-example
- name: Git clone
run: git clone https://github.com/input-output-hk/cardano-mainnet-mirror
- name: Run tests
run: |
if [ "${{github.event.inputs.tests}}" == "all" ]; then
TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test all
fi
- name: "Run tests"
run: |
if [ "${{github.event.inputs.tests}}" != "all" ]; then
TMPDIR="${{ runner.temp }}" TMP="${{ runner.temp }}" KEEP_WORKSPACE=1 cabal test \
cardano-testnet \
cardano-api \
cardano-node \
cardano-node-chairman \
cardano-cli \
cardano-submit-api
fi
- name: Build & Test
run: |
mkdir -p 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"
( cd artifacts
tar -C "$(dirname $exe)" -czf "$(basename $exe).tar.gz" "$(basename $exe)"
)
else
echo "Skipping artifact $exe"
fi
done
- name: Save Artifact
if: matrix.ghc == '8.10.4'
uses: actions/upload-artifact@v1
with:
name: artifacts-${{ matrix.os }}
path: ./artifacts
- name: Delete socket files in preparation for upload artifacts
if: ${{ always() }}
run: |
if [ -d "${{ runner.temp }}/chairman" ]; then
find "${{ runner.temp }}/chairman" -type s -exec rm -f {} \;
fi
- uses: actions/upload-artifact@v2
if: ${{ always() }}
continue-on-error: true
with:
name: chairman-test-artifacts-${{ matrix.os }}-${{ matrix.ghc }}
path: ${{ runner.temp }}/chairman/
release:
needs: [build]
if: ${{ startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2.3.4
- name: Create Release Tag
id: create_release_tag
run: echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false
- name: Download Artifact (linux)
uses: actions/download-artifact@v1
with:
name: artifacts-ubuntu-latest
- name: Download Artifact (macOS)
uses: actions/download-artifact@v1
with:
name: artifacts-macOS-latest
- name: Upload Release Asset (cardano-submit-api, linux)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts-ubuntu-latest/cardano-submit-api.tar.gz
asset_name: cardano-submit-api_${{ steps.create_release_tag.outputs.TAG }}-linux.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset (cardano-submit-api, macOS)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts-macOS-latest/cardano-submit-api.tar.gz
asset_name: cardano-submit-api_${{ steps.create_release_tag.outputs.TAG }}-macOS.tar.gz
asset_content_type: application/gzip