-
Notifications
You must be signed in to change notification settings - Fork 7
212 lines (202 loc) · 6.46 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
200
201
202
203
204
205
206
207
208
209
210
211
212
name: CI
on:
push:
branches:
- master
pull_request:
env:
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
NIX_BUILD: nix build -L --show-trace
NIX_BUILD_UNCACHED: nix run nixpkgs#nix-build-uncached -- -build-flags -L --show-trace
FLAKE: 'github:homotopy-io/homotopy-rs?rev=${{ github.sha }}'
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
max-jobs = 4
- name: Setup cachix
uses: cachix/cachix-action@v15
with:
name: homotopy-io
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Test
run: |
set -euo pipefail
$NIX_BUILD_UNCACHED https://github.com/homotopy-io/homotopy-rs/archive/$GITHUB_SHA.tar.gz -A checks.x86_64-linux.homotopy-common-tests
$NIX_BUILD_UNCACHED https://github.com/homotopy-io/homotopy-rs/archive/$GITHUB_SHA.tar.gz -A checks.x86_64-linux.homotopy-core-tests
$NIX_BUILD_UNCACHED https://github.com/homotopy-io/homotopy-rs/archive/$GITHUB_SHA.tar.gz -A checks.x86_64-linux.homotopy-model-tests
$NIX_BUILD_UNCACHED https://github.com/homotopy-io/homotopy-rs/archive/$GITHUB_SHA.tar.gz -A checks.x86_64-linux.homotopy-graphics-tests
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
max-jobs = 4
- name: Setup cachix
uses: cachix/cachix-action@v15
with:
name: homotopy-io
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run lint
run: |
nix run .#lint
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
max-jobs = 4
- name: Setup cachix
uses: cachix/cachix-action@v15
with:
name: homotopy-io
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# https://github.com/actions/upload-artifact/issues/92#issuecomment-1080347032
- name: Build
run: |
$NIX_BUILD $FLAKE
echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV
- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: web
path: ${{ env.UPLOAD_PATH }}
shelltest:
name: Shell Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
max-jobs = 4
- name: Setup cachix
uses: cachix/cachix-action@v15
with:
name: homotopy-io
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Test devshell
run: |
nix-shell --command "exit"
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [build, test]
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: web
path: result
- name: Checkout historical benchmarking data
uses: actions/checkout@v4
with:
ref: gh-pages
path: old
- name: Merge historical benchmarking data
run: mv old/dev result/dev
- name: Deploy to GitHub Pages (redundant)
uses: JamesIves/github-pages-deploy-action@v4.7.3
with:
branch: gh-pages
folder: result
- name: Deploy to Firebase (live)
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_HOMOTOPY_IO }}'
channelId: live
projectId: homotopy-io
target: homotopy-rs
benchmark:
name: Benchmark
runs-on: ubuntu-latest
needs: [build, test]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
max-jobs = 4
- name: Setup cachix
uses: cachix/cachix-action@v15
with:
name: homotopy-io
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run cargo bench
run: |
nix run .#bench
- name: Store benchmark result
uses: NickHu/github-action-benchmark@v1
with:
name: Rust Benchmark
tool: 'criterion'
output-file-path: output.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: ${{ github.ref == 'refs/heads/master' }}
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@NickHu,@zrho'
sync-benchmark:
name: Sync benchmark data to Firebase Hosting
runs-on: ubuntu-latest
needs: benchmark
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout GitHub Pages (redundant)
uses: actions/checkout@v4
with:
ref: gh-pages
path: result
- name: Deploy to Firebase (live)
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_HOMOTOPY_IO }}'
channelId: live
projectId: homotopy-io
target: homotopy-rs
preview:
name: Preview
runs-on: ubuntu-latest
needs: build
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: web
path: result
- name: Deploy to Firebase (preview)
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_HOMOTOPY_IO }}'
channelId: '${{ github.event.pull_request.head.label }}'
expires: 30d
projectId: homotopy-io
target: homotopy-rs