-
Notifications
You must be signed in to change notification settings - Fork 20
225 lines (194 loc) · 7.29 KB
/
ci-nix.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
219
220
221
222
223
224
225
# This is a basic workflow to help you get started with Actions
name: "CI (nix)"
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch and release tags
push:
branches: [ "main", "master", "devel", "releases/v*" ]
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [ "main", "master", "devel", "releases/v*" ]
merge_group:
branches: [ "main", "master", "devel", "releases/v*" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
self-care:
name: Flake self-check
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v5
with:
fail-mode: true
nixpkgs-keys: nixpkgs,nixpkgs-unstable
lint:
name: "Lint"
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-22.05
- uses: cachix/cachix-action@v12
with:
name: fedimint
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
continue-on-error: true
# caching ~/.cargo to avoid downloading all (especially git) deps in pre-commit's `cargo update --lock` check
- name: Cache ~/.cargo
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
# run the same check that git `pre-commit` hook would, just in case
- name: Commit check
run: nix develop --ignore-environment .#lint --command ./misc/git-hooks/pre-commit
- name: Check udeps
run: nix build -L .#nightly.test.workspaceCargoUdeps
build:
strategy:
matrix:
host:
- linux
- macos
include:
- host: linux
runs-on: buildjet-8vcpu-ubuntu-2004
build-in-pr: true
timeout: 60
run-tests: true
- host: macos
runs-on: macos-12
build-in-pr: false
# TODO: Too slow; see https://github.com/actions/runner-images/issues/1336
timeout: 60
run-tests: false
name: "Build on ${{ matrix.host }}"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: ${{ matrix.timeout }}
steps:
- uses: actions/checkout@v4
if: github.event_name != 'pull_request' || matrix.build-in-pr
- uses: cachix/install-nix-action@v23
if: github.event_name != 'pull_request' || matrix.build-in-pr
with:
nix_path: nixpkgs=channel:nixos-22.05
- uses: cachix/cachix-action@v12
if: github.event_name != 'pull_request' || matrix.build-in-pr
with:
name: fedimint
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
continue-on-error: true
- name: Build workspace
if: github.event_name != 'pull_request' || matrix.build-in-pr
run: nix build -L .#ci.workspaceBuild
- name: Clippy workspace
if: github.event_name != 'pull_request' || matrix.build-in-pr
run: nix build -L .#ci.workspaceClippy
- name: Run cargo doc
if: (github.event_name != 'pull_request' || matrix.build-in-pr) && (matrix.host != 'macos')
run: nix build -L .#ci.workspaceDoc
- name: Test docs
if: (github.event_name != 'pull_request' || matrix.build-in-pr) && (matrix.host != 'macos')
run: nix build -L .#ci.workspaceTestDoc
- name: Tests
if: (github.event_name != 'pull_request' || matrix.build-in-pr) && matrix.run-tests
run: |
nix build -L .#ci.ciTestAll --keep-failed
- name: Wasm Tests
if: (github.event_name != 'pull_request' || matrix.build-in-pr) && matrix.run-tests && (matrix.host != 'macos')
run: nix build -L .#wasm32-unknown.ci.wasmTest --keep-failed
- name: Prepare failed test build dirs
if: always()
run: |
set -x
# delete source and target artifacts as it is huge and rather useless now
sudo rm -Rf /tmp/nix-build-*/source || true
# chown so actions/upload-artifact can access it
sudo chown -R $USER /tmp/nix-build-* || true
# delete unix sockets, as actions/upload-artifact can't handle them
find /tmp/nix-build-* -type s -print0 | xargs -0 rm || true
- name: Upload failed test build dirs
if: always()
uses: actions/upload-artifact@v3
with:
name: "fedimint-failed-test-logs-${{ github.run_number }}-${{ matrix.host}}"
path: |
/tmp/nix-build-*/
!/tmp/nix-build-*/source/
audit:
if: github.repository == 'fedimint/fedimint'
name: "Audit"
runs-on: buildjet-2vcpu-ubuntu-2004
timeout-minutes: 10
# sometimes we can't fix these immediately, yet
# we don't want to stop the world because of it
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-22.05
- uses: cachix/cachix-action@v12
with:
name: fedimint
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run cargo audit
run: |
nix flake lock --update-input advisory-db
nix build -L .#ci.cargoAudit
- name: Run cargo deny
run: |
nix build -L .#ci.cargoDeny
cross:
name: "Cross-compile on ${{ matrix.host }} to ${{ matrix.toolchain }}"
strategy:
matrix:
host:
- linux
- macos
toolchain:
- aarch64-android
- armv7-android
- x86_64-android
- wasm32-unknown
include:
- host: linux
runs-on: ubuntu-22.04
build-in-pr: true
timeout: 20
- host: macos
runs-on: macos-12
build-in-pr: false
# TODO: Too slow; see https://github.com/actions/runner-images/issues/1336
timeout: 60
exclude:
# there's not enough macos runners available for our CI, so test only the more important cross-compilation toolchains
# if they work, rest probably works as well
- host: macos
toolchain: armv7-linux-androideabi
- host: macos
toolchain: x86_64-linux-android
runs-on: ${{ matrix.runs-on }}
timeout-minutes: ${{ matrix.timeout }}
steps:
- uses: actions/checkout@v4
if: github.event_name != 'pull_request' || matrix.build-in-pr
- uses: cachix/install-nix-action@v23
if: github.event_name != 'pull_request' || matrix.build-in-pr
with:
nix_path: nixpkgs=channel:nixos-22.05
- uses: cachix/cachix-action@v12
if: github.event_name != 'pull_request' || matrix.build-in-pr
with:
name: fedimint
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
continue-on-error: true
- name: Build client packages for ${{ matrix.toolchain }}
if: github.event_name != 'pull_request' || matrix.build-in-pr
run: nix build -L .#${{ matrix.toolchain }}.ci.client-pkgs