Skip to content

Commit 3ba5812

Browse files
authored
First pass at adding arm64 to the build. (#77)
* First pass at adding arm64 to the build. Both node-pre-gyp and rust need different platform and architecture arguments since we have to cross compile. There aren't currently M1 action runners available to do this natively. Uses rust-toolchain to set the default to the current matrix option, need to make sure that works and that the linker used doesn't get messed up for musl builds for ex. * Might be a better matrix setup * Forgot to alter runs-on for docker-test * Didn't patch :/ * :/
1 parent c25eb5b commit 3ba5812

File tree

5 files changed

+68
-37
lines changed

5 files changed

+68
-37
lines changed

.github/typescript-ci-patch.yaml

+22-12
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22
- op: replace
33
path: /jobs/test/strategy/matrix
44
value:
5-
node_version:
6-
- "12"
7-
- "14"
8-
- "16"
9-
rust_version:
5+
rust_version:
106
- 1.56.0
117
- stable
128
- beta
13-
os:
14-
- macos-10.15
15-
- ubuntu-20.04
16-
- windows-2019
9+
node_version:
10+
- 12
11+
- 14
12+
- 16
13+
system:
14+
- os: macos-10.15
15+
target: x86_64-apple-darwin
16+
- os: macos-11
17+
target: aarch64-apple-darwin
18+
- os: ubuntu-20.04
19+
target: x86_64-unknown-linux-gnu
20+
- os: windows-2019
21+
target: x86_64-pc-windows-msvc
1722
- op: add
1823
path: /jobs/test/strategy/fail-fast
1924
value: false
2025
- op: replace
2126
path: /jobs/test/runs-on
22-
value: "${{ matrix.os }}"
27+
value: "${{ matrix.system.os }}"
2328

2429
# These steps are lifted from the Rust CI workflow, cargo-test job.
2530
- op: add
@@ -44,17 +49,22 @@
4449
# Only check coverage in one of the matrix job instances.
4550
- op: add
4651
path: /jobs/test/steps/6/if
47-
value: ${{ contains(matrix.os, 'ubuntu') && matrix.node_version == '16' && matrix.rust_version == 'stable' && github.base_ref != '' }}
52+
value: ${{ contains(matrix.system.os, 'ubuntu') && matrix.node_version == '16' && matrix.rust_version == 'stable' && github.base_ref != '' }}
4853

4954
# Also run on musl. That means we need to run it in a Docker container. To do that, we copy the entire job and modify its
5055
# strategy/matrix.
5156
- op: copy
5257
from: /jobs/test
5358
path: /jobs/test-docker
54-
- op: replace
59+
- op: remove
60+
path: /jobs/test-docker/strategy/matrix/system
61+
- op: add
5562
path: /jobs/test-docker/strategy/matrix/os
5663
value:
5764
- ubuntu-20.04
65+
- op: replace
66+
path: /jobs/test-docker/runs-on
67+
value: "${{ matrix.os }}"
5868
- op: add
5969
path: /jobs/test-docker/container
6070
value:

.github/workflows/publish.yaml

+21-8
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,26 @@ env:
1616

1717
jobs:
1818
publish-github:
19-
runs-on: ${{ matrix.os }}
19+
runs-on: ${{ matrix.system.os }}
2020
strategy:
2121
fail-fast: false
2222
matrix:
2323
node_version:
24-
- '12'
25-
- '14'
26-
- '16'
27-
os:
28-
- macos-10.15
29-
- ubuntu-20.04
30-
- windows-2019
24+
- 12
25+
- 14
26+
- 16
27+
system:
28+
- os: macos-10.15
29+
target: x86_64-apple-darwin
30+
- os: macos-11
31+
target: aarch64-apple-darwin
32+
# only needed in this case, where we're cross compiling until runners with m1 chips exist
33+
pre_gyp_platform: darwin
34+
pre_gyp_arch: arm64
35+
- os: ubuntu-20.04
36+
target: x86_64-unknown-linux-gnu
37+
- os: windows-2019
38+
target: x86_64-pc-windows-msvc
3139
steps:
3240
- uses: actions/checkout@v2
3341
with:
@@ -40,13 +48,18 @@ jobs:
4048
with:
4149
profile: minimal
4250
toolchain: stable
51+
target: ${{ matrix.system.target }}
52+
default: true
4353
override: true
4454
- name: Install modules
4555
run: yarn install --ignore-scripts
4656
- name: Build
4757
id: build
4858
# Use bash, even on Windows.
4959
shell: bash
60+
env:
61+
PRE_GYP_PLATFORM: ${{ matrix.system.pre_gyp_platform }}
62+
PRE_GYP_ARCH: ${{ matrix.system.pre_gyp_arch }}
5063
run: |
5164
node publish.js
5265
cd bin-package

.github/workflows/typescript-ci.yaml

+20-15
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@ name: TypeScript CI
1111
workflow_dispatch: null
1212
jobs:
1313
test:
14-
runs-on: ${{ matrix.os }}
14+
runs-on: ${{ matrix.system.os }}
1515
strategy:
1616
matrix:
17-
node_version:
18-
- '12'
19-
- '14'
20-
- '16'
2117
rust_version:
2218
- 1.56.0
2319
- stable
2420
- beta
25-
os:
26-
- macos-10.15
27-
- ubuntu-20.04
28-
- windows-2019
21+
node_version:
22+
- 12
23+
- 14
24+
- 16
25+
system:
26+
- os: macos-10.15
27+
target: x86_64-apple-darwin
28+
- os: macos-11
29+
target: aarch64-apple-darwin
30+
- os: ubuntu-20.04
31+
target: x86_64-unknown-linux-gnu
32+
- os: windows-2019
33+
target: x86_64-pc-windows-msvc
2934
fail-fast: false
3035
steps:
3136
- uses: actions/checkout@v2
@@ -45,8 +50,8 @@ jobs:
4550
- name: Run tests
4651
run: yarn run test
4752
- name: Check test coverage
48-
if: ${{ contains(matrix.os, 'ubuntu') && matrix.node_version == '16' && matrix.rust_version
49-
== 'stable' && github.base_ref != '' }}
53+
if: ${{ contains(matrix.system.os, 'ubuntu') && matrix.node_version == '16'
54+
&& matrix.rust_version == 'stable' && github.base_ref != '' }}
5055
uses: anuraag016/Jest-Coverage-Diff@V1.3
5156
with:
5257
fullCoverageDiff: false
@@ -56,14 +61,14 @@ jobs:
5661
runs-on: ${{ matrix.os }}
5762
strategy:
5863
matrix:
59-
node_version:
60-
- '12'
61-
- '14'
62-
- '16'
6364
rust_version:
6465
- 1.56.0
6566
- stable
6667
- beta
68+
node_version:
69+
- 12
70+
- 14
71+
- 16
6772
os:
6873
- ubuntu-20.04
6974
fail-fast: false

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"win32"
2121
],
2222
"cpu": [
23-
"x64"
23+
"x64",
24+
"arm64"
2425
],
2526
"scripts": {
2627
"compile": "cargo-cp-artifact -a cdylib recrypt_node ./bin-package/index.node -- cargo build --release --message-format=json-render-diagnostics",

publish.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ fs.writeFileSync("./dist/package.json", JSON.stringify(npmPackageJson, null, 2))
4545

4646
//Use a fully qualified path to pre-gyp binary for Windows support
4747
const cwd = shell.pwd().toString();
48-
shell.exec(`${cwd}/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp package`);
48+
const replacementArch = process.env.PRE_GYP_ARCH ? `--target_arch=${process.env.PRE_GYP_ARCH}` : "";
49+
const replacementPlatform = process.env.PRE_GYP_PLATFORM ? `--target_platform=${process.env.PRE_GYP_PLATFORM}` : "";
50+
shell.exec(`${cwd}/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp package ${replacementArch} ${replacementPlatform}`);
4951
var tgz = shell.exec("find ./build -name *.tar.gz");
5052
shell.cp(tgz, "./bin-package/");
5153
shell.pushd("./dist");

0 commit comments

Comments
 (0)