-
Notifications
You must be signed in to change notification settings - Fork 12
272 lines (261 loc) · 9.12 KB
/
CI.yml
File metadata and controls
272 lines (261 loc) · 9.12 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Build and Test Zig and Bun
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
zig-build-upload:
strategy:
matrix:
settings:
- os: ubuntu-latest
bun-target: linux-x64-gnu
- os: ubuntu-24.04-arm
bun-target: linux-arm64-gnu
- os: ubuntu-latest
bun-target: linux-x64-musl
- os: ubuntu-24.04-arm
bun-target: linux-arm64-musl
- os: macos-13
bun-target: darwin-x64
- os: macos-latest
bun-target: darwin-arm64
# - os: windows-latest # TODO: https://github.com/ChainSafe/state-transition-z/issues/10
# bun-target: win32-x64-msvc
runs-on: ${{ matrix.settings.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive # Ensures submodules are cloned
fetch-depth: 0 # Fetches the entire history for all branches
- name: Install Zig
uses: mlugg/setup-zig@v1
with:
version: "0.14.0" # Set the required Zig version
- name: Build and Test
run: |
zig build test
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
version: 1.2.13
- name: Bun - Install Dependencies
run: bun install
working-directory: ./bun
- name: Build binary using bun-ffi-z
run: bun ./node_modules/.bin/bun-ffi-z build --target ${{ matrix.settings.bun-target }} --optimize ReleaseSafe
working-directory: ./bun
- name: Upload Zig Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.settings.bun-target }}
path: 'zig-out/lib/*state-transition-utils.*'
if-no-files-found: error
bun-benchmark:
name: run benchmark on ubuntu-latest x86_64
needs: zig-build-upload
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4 # no need zig installation, download artifacts from previous job instead
with:
name: linux-x64-gnu
path: zig-out/lib
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
version: 1.2.13
- name: Bun - Install Dependencies
run: bun install
working-directory: ./bun
- name: Bun - Lint Code
run: bun lint
working-directory: ./bun
- name: Bun - Unit Tests
run: bun test:unit
working-directory: ./bun
- name: Benchmark
run: bun benchmark
working-directory: ./bun
env:
# To write to PRs and commits
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
bun-linux-x64-gnu:
name: Test bindings on linux-x64-gnu
needs: zig-build-upload
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4 # no need zig installation, download artifacts from previous job instead
with:
name: linux-x64-gnu
path: zig-out/lib
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
version: 1.2.13
- name: Bun - Install Dependencies
run: bun install
working-directory: ./bun
- name: Bun - Unit Tests
run: bun test:unit
working-directory: ./bun
bun-linux-arm64-gnu:
name: Test bindings on linux-arm64-gnu
needs: zig-build-upload
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4 # no need zig installation, download artifacts from previous job instead
with:
name: linux-arm64-gnu
path: zig-out/lib # download to the same folder of "zig build -Doptimize=ReleaseSafe"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests using Bun
uses: addnab/docker-run-action@v3
with:
image: oven/bun:1.2.13
options: '--platform linux/arm64 -v ${{ github.workspace }}:/project -w /project/bun'
run: |
bun install
bun test:unit
bun-linux-x64-musl:
name: Test bindings on linux-x64-musl
needs: zig-build-upload
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4 # no need zig installation, download artifacts from previous job instead
with:
name: linux-x64-musl
path: zig-out/lib # download to the same folder of "zig build -Doptimize=ReleaseSafe"
- name: Setup and run tests using Bun
uses: addnab/docker-run-action@v3
with:
image: oven/bun:1.2.13-alpine
options: '-v ${{ github.workspace }}:/project -w /project/bun'
run: | # cannot run committeeIndices.test.ts and shuffle.test.ts due to musl is not available: @chainsafe/pubkey-index-map-linux-x64-musl
bun install
bun test test/unit/pubkeyIndexMap.test.ts
bun-linux-arm64-musl:
name: Test bindings on linux-arm64-musl
needs: zig-build-upload
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4 # no need zig installation, download artifacts from previous job instead
with:
name: linux-arm64-musl
path: zig-out/lib # download to the same folder of "zig build -Doptimize=ReleaseSafe"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests using Bun
uses: addnab/docker-run-action@v3
with:
image: oven/bun:1.2.13-alpine
options: '--platform linux/arm64 -v ${{ github.workspace }}:/project -w /project/bun'
run: | # cannot run committeeIndices.test.ts and shuffle.test.ts due to musl is not available: @chainsafe/pubkey-index-map-linux-x64-musl
bun install
bun test test/unit/pubkeyIndexMap.test.ts
bun-darwin:
name: Test bindings on macos
needs: zig-build-upload
strategy:
matrix:
settings:
- os: macos-13
bun-target: darwin-x64
- os: macos-latest
bun-target: darwin-arm64
# - os: windows-latest # TODO: https://github.com/ChainSafe/state-transition-z/issues/10
# bun-target: win32-x64-msvc
runs-on: ${{ matrix.settings.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4 # no need zig installation, download artifacts from previous job instead
with:
name: ${{ matrix.settings.bun-target }}
path: zig-out/lib # download to the same folder of "zig build -Doptimize=ReleaseSafe"
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
version: 1.2.13
- name: Bun - Install Dependencies
run: bun install
working-directory: ./bun
- name: Bun - Unit Tests
run: bun test:unit
working-directory: ./bun
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- bun-linux-x64-gnu
- bun-linux-arm64-gnu
- bun-linux-x64-musl
- bun-linux-arm64-musl
- bun-darwin
steps:
- name: Opening Release PR
if: github.ref == 'refs/heads/main'
uses: googleapis/release-please-action@v4
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
version: 1.2.13
- name: Bun - Install Dependencies
if: ${{ steps.release.outputs.release_created }}
run: bun install
working-directory: ./bun
- name: Download all artifacts
if: ${{ steps.release.outputs.release_created }}
uses: actions/download-artifact@v4
with:
path: bun/artifacts
- name: List artifacts
if: ${{ steps.release.outputs.release_created }}
run: ls -R ./bun/artifacts
shell: bash
- name: Create targetPackages
if: ${{ steps.release.outputs.release_created }}
run: bun run prepublishOnly
working-directory: ./bun
- name: List targetPackages
if: ${{ steps.release.outputs.release_created }}
run: ls -R ./bun/targetPackages
shell: bash
- name: Publish
if: ${{ steps.release.outputs.release_created }}
run: bun run publish
working-directory: ./bun
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}