Skip to content

Commit 3d8c6b6

Browse files
authored
feat: supports more architectures (#88)
1 parent 75d49b5 commit 3d8c6b6

File tree

11 files changed

+151
-50
lines changed

11 files changed

+151
-50
lines changed

.cargo/config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[target.aarch64-unknown-linux-musl]
2+
linker = "aarch64-linux-musl-gcc"
3+
rustflags = ["-C", "target-feature=-crt-static"]
4+
5+
[target.x86_64-pc-windows-msvc]
6+
rustflags = ["-C", "target-feature=+crt-static"]

.github/workflows/ci.yml

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ jobs:
4242
check-latest: true
4343
cache: yarn
4444
- name: Install rust
45-
uses: actions-rust-lang/setup-rust-toolchain@v1
45+
uses: dtolnay/rust-toolchain@stable
4646
with:
47+
toolchain: stable
4748
components: rustfmt
4849
- name: Install taplo
4950
run: cargo install taplo-cli --locked
@@ -59,8 +60,9 @@ jobs:
5960
steps:
6061
- uses: actions/checkout@v4
6162
- name: Install rust
62-
uses: actions-rust-lang/setup-rust-toolchain@v1
63+
uses: dtolnay/rust-toolchain@stable
6364
with:
65+
toolchain: stable
6466
components: clippy
6567
- name: Run clippy
6668
run: cargo clippy
@@ -79,6 +81,9 @@ jobs:
7981
- host: windows-latest
8082
target: x86_64-pc-windows-msvc
8183
build: yarn build --target x86_64-pc-windows-msvc
84+
- host: windows-latest
85+
target: aarch64-pc-windows-msvc
86+
build: yarn build --target aarch64-pc-windows-msvc
8287
- host: ubuntu-latest
8388
target: x86_64-unknown-linux-gnu
8489
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
@@ -91,6 +96,32 @@ jobs:
9196
set -e &&
9297
apk add perl &&
9398
yarn build
99+
- host: ubuntu-latest
100+
target: aarch64-unknown-linux-gnu
101+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
102+
build: |-
103+
# `perl` needs for building openssl
104+
set -e &&
105+
apt-get update &&
106+
apt-get install -y perl &&
107+
unset CC_aarch64_unknown_linux_gnu &&
108+
unset CXX_aarch64_unknown_linux_gnu &&
109+
yarn build --target aarch64-unknown-linux-gnu
110+
- host: ubuntu-latest
111+
target: aarch64-unknown-linux-musl
112+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
113+
build: |-
114+
# `perl` needs for building openssl
115+
set -e &&
116+
apk add perl &&
117+
rustup target add aarch64-unknown-linux-musl &&
118+
yarn build --target aarch64-unknown-linux-musl
119+
- host: ubuntu-latest
120+
target: aarch64-linux-android
121+
build: yarn build --target aarch64-linux-android
122+
- host: ubuntu-latest
123+
target: armv7-linux-androideabi
124+
build: yarn build --target armv7-linux-androideabi
94125
name: stable - ${{ matrix.settings.target }} - node@20
95126
runs-on: ${{ matrix.settings.host }}
96127
steps:
@@ -103,10 +134,11 @@ jobs:
103134
check-latest: true
104135
cache: yarn
105136
- name: Install rust
106-
uses: actions-rust-lang/setup-rust-toolchain@v1
137+
uses: dtolnay/rust-toolchain@stable
107138
if: ${{ !matrix.settings.docker }}
108139
with:
109-
target: ${{ matrix.settings.target }}
140+
toolchain: stable
141+
targets: ${{ matrix.settings.target }}
110142
- name: Cache cargo
111143
uses: actions/cache@v4
112144
with:
@@ -175,8 +207,6 @@ jobs:
175207
shell: bash
176208
- name: Test bindings
177209
run: yarn vitest run
178-
env:
179-
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
180210
test-windows-binding:
181211
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
182212
needs:
@@ -211,8 +241,6 @@ jobs:
211241
shell: bash
212242
- name: Test bindings
213243
run: yarn vitest run
214-
env:
215-
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
216244
test-linux-x64-gnu-binding:
217245
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
218246
needs:
@@ -243,7 +271,7 @@ jobs:
243271
run: ls -R .
244272
shell: bash
245273
- name: Test bindings
246-
run: docker run --rm -e TEST_GITHUB_TOKEN=${{ secrets.TEST_GITHUB_TOKEN }} -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn vitest run
274+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn vitest run
247275
test-linux-x64-musl-binding:
248276
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
249277
needs:
@@ -276,4 +304,43 @@ jobs:
276304
run: ls -R .
277305
shell: bash
278306
- name: Test bindings
279-
run: docker run --rm -e TEST_GITHUB_TOKEN=${{ secrets.TEST_GITHUB_TOKEN }} -v $(pwd):/build -w /build node:${{ matrix.node }}-alpine yarn vitest run
307+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-alpine yarn vitest run
308+
test-linux-aarch64-gnu-binding:
309+
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
310+
needs:
311+
- build
312+
strategy:
313+
fail-fast: false
314+
matrix:
315+
node:
316+
- '18'
317+
- '20'
318+
runs-on: ubuntu-latest
319+
steps:
320+
- uses: actions/checkout@v4
321+
- name: Download artifacts
322+
uses: actions/download-artifact@v4
323+
with:
324+
name: bindings-aarch64-unknown-linux-gnu
325+
path: .
326+
- name: List packages
327+
run: ls -R .
328+
shell: bash
329+
- name: Install dependencies
330+
run: |
331+
yarn config set supportedArchitectures.cpu "arm64"
332+
yarn config set supportedArchitectures.libc "glibc"
333+
yarn install
334+
- name: Set up QEMU
335+
uses: docker/setup-qemu-action@v3
336+
with:
337+
platforms: arm64
338+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
339+
- name: Setup and run tests
340+
uses: addnab/docker-run-action@v3
341+
with:
342+
image: node:${{ matrix.node }}-slim
343+
options: '--user 0:0 --platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
344+
run: |
345+
set -e
346+
yarn vitest run

.github/workflows/release.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ jobs:
2222
target: aarch64-apple-darwin
2323
build: yarn build --target aarch64-apple-darwin
2424
- host: windows-latest
25-
build: yarn build --target x86_64-pc-windows-msvc
2625
target: x86_64-pc-windows-msvc
26+
build: yarn build --target x86_64-pc-windows-msvc
27+
- host: windows-latest
28+
target: aarch64-pc-windows-msvc
29+
build: yarn build --target aarch64-pc-windows-msvc
2730
- host: ubuntu-latest
2831
target: x86_64-unknown-linux-gnu
2932
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
@@ -36,7 +39,33 @@ jobs:
3639
set -e &&
3740
apk add perl &&
3841
yarn build
39-
name: stable - ${{ matrix.settings.target }} - node@20
42+
- host: ubuntu-latest
43+
target: aarch64-unknown-linux-gnu
44+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
45+
build: |-
46+
# `perl` needs for building openssl
47+
set -e &&
48+
apt-get update &&
49+
apt-get install -y perl &&
50+
unset CC_aarch64_unknown_linux_gnu &&
51+
unset CXX_aarch64_unknown_linux_gnu &&
52+
yarn build --target aarch64-unknown-linux-gnu
53+
- host: ubuntu-latest
54+
target: aarch64-unknown-linux-musl
55+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
56+
build: |-
57+
# `perl` needs for building openssl
58+
set -e &&
59+
apk add perl &&
60+
rustup target add aarch64-unknown-linux-musl &&
61+
yarn build --target aarch64-unknown-linux-musl
62+
- host: ubuntu-latest
63+
target: aarch64-linux-android
64+
build: yarn build --target aarch64-linux-android
65+
- host: ubuntu-latest
66+
target: armv7-linux-androideabi
67+
build: yarn build --target armv7-linux-androideabi
68+
name: stable - ${{ matrix.settings.target }}
4069
runs-on: ${{ matrix.settings.host }}
4170
steps:
4271
- uses: actions/checkout@v4
@@ -48,10 +77,11 @@ jobs:
4877
check-latest: true
4978
cache: yarn
5079
- name: Install rust
51-
uses: actions-rust-lang/setup-rust-toolchain@v1
80+
uses: dtolnay/rust-toolchain@stable
5281
if: ${{ !matrix.settings.docker }}
5382
with:
54-
target: ${{ matrix.settings.target }}
83+
toolchain: stable
84+
targets: ${{ matrix.settings.target }}
5585
- name: Cache cargo
5686
uses: actions/cache@v4
5787
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,6 @@ $RECYCLE.BIN/
200200

201201
# npm folders
202202
npm
203+
204+
# tmp
205+
/tmp

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ nodeLinker: node-modules
55
preferReuse: true
66

77
yarnPath: .yarn/releases/yarn-4.6.0.cjs
8+
9+
httpRetry: 10

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ crate-type = ["cdylib"]
1010
bitflags = "2.1.0"
1111
chrono = "0.4"
1212
git2 = { version = "0.20.0", features = ["vendored-libgit2", "vendored-openssl"] }
13-
napi = { version = "2.16.13", default-features = false, features = ["napi6", "chrono_date"] }
14-
napi-derive = "2.16.12"
13+
napi = { version = "2.16.17", default-features = false, features = ["napi6", "chrono_date"] }
14+
napi-derive = "2.16.13"
1515
thiserror = "2.0.3"
1616

1717
[build-dependencies]
18-
napi-build = "2.1.3"
18+
napi-build = "2.1.6"
1919

2020
[profile.release]
2121
lto = true

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
"x86_64-apple-darwin",
2323
"aarch64-apple-darwin",
2424
"x86_64-pc-windows-msvc",
25+
"aarch64-pc-windows-msvc",
2526
"x86_64-unknown-linux-gnu",
26-
"x86_64-unknown-linux-musl"
27+
"x86_64-unknown-linux-musl",
28+
"aarch64-linux-android",
29+
"aarch64-unknown-linux-gnu",
30+
"aarch64-unknown-linux-musl",
31+
"armv7-linux-androideabi"
2732
]
2833
}
2934
},

rust-toolchain.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/repository.spec.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
22
import path from 'node:path';
33
import { describe, expect, it } from 'vitest';
44
import { cloneRepository, initRepository, openRepository } from '../index';
5-
import { isCI, isTarget } from './env';
5+
import { isTarget } from './env';
66
import { useFixture } from './fixtures';
77
import { makeTmpDir } from './tmp';
88

@@ -41,7 +41,7 @@ describe('Repository', () => {
4141

4242
it('error if given path is not git repository', async () => {
4343
const p = await useFixture('notgit');
44-
await expect(openRepository(p)).rejects.toThrowError(/libgit2 error: could not find repository/);
44+
await expect(openRepository(p)).rejects.toThrowError();
4545
});
4646

4747
it('clone from local', async () => {
@@ -57,21 +57,6 @@ describe('Repository', () => {
5757
expect(repo.state()).toBe('Clean');
5858
});
5959

60-
// If an action is executed by another contributor, it will not be authenticate properly.
61-
// So turn off the test.
62-
it('clone from remote with credential', { skip: true }, async () => {
63-
const p = await makeTmpDir('clone');
64-
const repo = await cloneRepository('https://github.com/seokju-na/dummy-repo-private', p, {
65-
fetch: {
66-
credential: {
67-
type: 'Plain',
68-
password: process.env.TEST_GITHUB_TOKEN!,
69-
},
70-
},
71-
});
72-
expect(repo.state()).toBe('Clean');
73-
});
74-
7560
it('get head', async () => {
7661
const p = await useFixture('commits');
7762
const repo = await openRepository(p);

0 commit comments

Comments
 (0)