generated from napi-rs/package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (145 loc) · 4.26 KB
/
pure-rust-build-on-linux.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
name: Pure Rust project build on Linux
on:
push:
branches:
- main
pull_request:
env:
DEBUG: 'napi:*'
MACOSX_DEPLOYMENT_TARGET: '10.13'
jobs:
build:
strategy:
fail-fast: false
matrix:
targets:
[
'x86_64-apple-darwin',
'aarch64-apple-darwin',
'x86_64-pc-windows-msvc',
'i686-pc-windows-msvc',
'aarch64-pc-windows-msvc',
'x86_64-unknown-linux-gnu',
'aarch64-unknown-linux-gnu',
'x86_64-unknown-linux-musl',
'aarch64-unknown-linux-musl',
'armv7-unknown-linux-gnueabihf',
'aarch64-linux-android',
'armv7-linux-androideabi',
]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.targets }}
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Install ziglang
uses: goto-bus-stop/setup-zig@v1
with:
version: 0.11.0
- run: cargo install cargo-xwin
- run: yarn install
- run: yarn build --target ${{ matrix.targets }}
- uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.targets }}
path: node-printer-rust/*.node
if-no-files-found: error
test-host:
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
host: macos-latest
- target: x86_64-pc-windows-msvc
host: windows-latest
- target: i686-pc-windows-msvc
host: windows-latest
node: ['18', '20']
runs-on: ${{ matrix.settings.host }}
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
- name: Setup node x86
if: matrix.settings.target == 'i686-pc-windows-msvc'
run: yarn config set supportedArchitectures.cpu "ia32"
shell: bash
- name: Install dependencies
run: yarn install
- name: Setup node x86
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 18
cache: yarn
architecture: x86
- name: Download bindings
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: node-printer-rust/
- name: Run tests
run: yarn test
test-docker:
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-unknown-linux-gnu
docker: node:18-slim
args: ''
- target: aarch64-unknown-linux-gnu
docker: node:18-slim
args: '--platform linux/arm64'
- target: x86_64-unknown-linux-musl
docker: node:18-alpine
args: ''
- target: aarch64-unknown-linux-musl
docker: node:18-alpine
args: '--platform linux/arm64'
- target: armv7-unknown-linux-gnueabihf
docker: node:18-bullseye-slim
args: '--platform linux/arm/v7'
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
- name: Install cups
run: apt update && apt install -y cups libcups2-dev
- name: Install dependencies
run: yarn install
- name: Download bindings
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: node-printer-rust/
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,arm
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Run tests
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.settings.docker }}
options: ${{ matrix.settings.args }} -v ${{ github.workspace }}:/build -w /build
run: |
set -e
yarn test