-
Notifications
You must be signed in to change notification settings - Fork 572
149 lines (119 loc) · 4.38 KB
/
build-ironfish-rust-nodejs.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
name: Build @ironfish/rust-nodejs NPM Packages
env:
DEBUG: 'napi:*'
MACOSX_DEPLOYMENT_TARGET: '10.13'
on:
workflow_dispatch:
workflow_call:
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: ubuntu-latest
target: x86_64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
# intentionally macos, needed to cross-compile to lower libc abi
- host: macos-latest
target: x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
- host: ubuntu-latest
target: aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
name: Build ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- name: Record CPU information
run: |
${{ contains(matrix.settings.host, 'ubuntu-') && 'cat /proc/cpuinfo' || '' }}
${{ contains(matrix.settings.host, 'macos-') && 'sysctl -a | grep machdep.cpu' || '' }}
${{ contains(matrix.settings.host, 'windows-') && 'Get-WmiObject -Class Win32_Processor -ComputerName.' || '' }}
- name: Check out Git repository
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
- name: Install Rust
run: |
rustup target add ${{ matrix.settings.target }}
- name: Install ziglang
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.10.0
- name: Install dependencies
run: npm install --no-workspaces
working-directory: ./ironfish-rust-nodejs
- name: Build
run: yarn build ${{ matrix.settings.target != 'x86_64-pc-windows-msvc' && '--zig' || '' }} ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' && '--zig-abi-suffix=2.17' || ''}} --target ${{ matrix.settings.target }}
working-directory: ./ironfish-rust-nodejs
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.settings.target }}
path: ironfish-rust-nodejs/*.node
if-no-files-found: error
test:
needs:
- build
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: node:18-slim
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
docker: node:18-alpine
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs:aarch64-16
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
docker: arm64v8/node:18-alpine
platform: linux/arm64/v8
name: Test bindings for ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up QEMU for Docker
if: ${{ matrix.settings.docker }}
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-${{ matrix.settings.target }}
path: ./ironfish-rust-nodejs
- name: Install dependencies
run: npm install --no-workspaces
working-directory: ./ironfish-rust-nodejs
- name: Run tests in Docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: ${{ matrix.settings.platform && format('--platform {0}', matrix.settings.platform) || ''}} -v ${{ github.workspace }}:/build -w /build/ironfish-rust-nodejs
run: |
set -e
npm run test:slow
- name: Run tests natively
if: ${{ !matrix.settings.docker }}
run: npm run test:slow
working-directory: ./ironfish-rust-nodejs