ci: reduce aarch64 running time by cross compile in host machine
This commit is contained in:
parent
fbd82d4e27
commit
3c3a5b6fdb
9 changed files with 90 additions and 16 deletions
3
.github/workflows/bench.yaml
vendored
3
.github/workflows/bench.yaml
vendored
|
@ -1,5 +1,8 @@
|
|||
name: Benchmark
|
||||
|
||||
env:
|
||||
DEBUG: 'napi:*'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
|
75
.github/workflows/linux-aarch64.yaml
vendored
75
.github/workflows/linux-aarch64.yaml
vendored
|
@ -1,5 +1,10 @@
|
|||
name: Linux-aarch64
|
||||
|
||||
env:
|
||||
DEBUG: 'napi:*'
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: 'aarch64-linux-gnu-gcc'
|
||||
NAPI_RS_INCLUDE_PATH: '/usr/aarch64-linux-gnu/include'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, develop]
|
||||
|
@ -12,25 +17,71 @@ jobs:
|
|||
|
||||
steps:
|
||||
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: 'Setup and run tests'
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14
|
||||
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install aarch64 toolchain
|
||||
run: rustup target add aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Generate Cargo.lock
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: generate-lockfile
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: stable-linux-aarch64-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: stable-linux-aarch64gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache NPM dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: node_modules
|
||||
key: npm-cache-linux-aarch64-node@14-${{ hashFiles('yarn.lock') }}
|
||||
restore-keys: |
|
||||
npm-cache-
|
||||
|
||||
- name: Install cross compile toolchain
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-aarch64-linux-gnu g++-6-aarch64-linux-gnu -y
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org
|
||||
|
||||
- name: 'Build TypeScript'
|
||||
run: yarn build
|
||||
|
||||
- name: Cross build native tests
|
||||
run: yarn build:test:aarch64
|
||||
|
||||
- name: Setup and run tests
|
||||
uses: docker://multiarch/ubuntu-core:arm64-focal
|
||||
with:
|
||||
args: >
|
||||
sh -c "
|
||||
apt-get update && \
|
||||
apt-get install -y ca-certificates gnupg2 llvm clang curl && \
|
||||
apt-get install -y ca-certificates gnupg2 curl && \
|
||||
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
|
||||
apt-get install -y nodejs && \
|
||||
curl https://sh.rustup.rs -sSf --output rustup.sh && \
|
||||
sh rustup.sh -y --profile minimal --default-toolchain stable && \
|
||||
. $HOME/.cargo/env && \
|
||||
npm install -g yarn && \
|
||||
yarn --ignore-optional && \
|
||||
yarn build && \
|
||||
cargo check -vvv && \
|
||||
cargo test -p napi-sys --lib -- --nocapture && \
|
||||
yarn build:test && \
|
||||
yarn test
|
||||
npm test
|
||||
"
|
||||
|
|
3
.github/workflows/linux-musl.yaml
vendored
3
.github/workflows/linux-musl.yaml
vendored
|
@ -1,5 +1,8 @@
|
|||
name: Linux musl
|
||||
|
||||
env:
|
||||
DEBUG: 'napi:*'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, develop]
|
||||
|
|
3
.github/workflows/napi3.yaml
vendored
3
.github/workflows/napi3.yaml
vendored
|
@ -1,5 +1,8 @@
|
|||
name: Linux N-API@3
|
||||
|
||||
env:
|
||||
DEBUG: 'napi:*'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, develop]
|
||||
|
|
3
.github/workflows/test.yaml
vendored
3
.github/workflows/test.yaml
vendored
|
@ -1,5 +1,8 @@
|
|||
name: macOS/Windows/Linux x64
|
||||
|
||||
env:
|
||||
DEBUG: 'napi:*'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, develop]
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"build": "tsc -p tsconfig.json && chmod 777 scripts/index.js",
|
||||
"build:bench": "yarn --cwd ./bench build",
|
||||
"build:test": "yarn --cwd ./test_module build",
|
||||
"build:test:aarch64": "yarn --cwd ./test_module build-aarch64",
|
||||
"format": "run-p format:md format:json format:yaml format:source format:rs",
|
||||
"format:md": "prettier --parser markdown --write './**/*.md'",
|
||||
"format:json": "prettier --parser json --write './**/*.json'",
|
||||
|
|
|
@ -31,6 +31,9 @@ export class BuildCommand extends Command {
|
|||
@Command.String('--cargo-name')
|
||||
cargoName?: string
|
||||
|
||||
@Command.String('--target-triple')
|
||||
targetTripleDir = ''
|
||||
|
||||
@Command.String({
|
||||
required: false,
|
||||
})
|
||||
|
@ -94,7 +97,10 @@ export class BuildCommand extends Command {
|
|||
)
|
||||
}
|
||||
|
||||
const targetDir = this.isRelease ? 'release' : 'debug'
|
||||
const targetDir = join(
|
||||
this.targetTripleDir,
|
||||
this.isRelease ? 'release' : 'debug',
|
||||
)
|
||||
|
||||
if (this.isMusl && !this.appendPlatformToFilename) {
|
||||
throw new TypeError(`Musl flag must be used with platform flag`)
|
||||
|
|
|
@ -47,11 +47,14 @@ fn main() {
|
|||
let mut bindgen_builder = bindgen::Builder::default()
|
||||
.derive_default(true)
|
||||
.header(sys_bindings_path.to_str().unwrap().to_owned())
|
||||
.clang_arg(format!("-I{}", node_include_path));
|
||||
.clang_arg(format!("-I{}", node_include_path))
|
||||
.clang_arg("-target")
|
||||
.clang_arg(env::var("TARGET").unwrap());
|
||||
|
||||
if let Ok(uv_include_path) = env::var("UV_INCLUDE_PATH") {
|
||||
if let Ok(uv_include_path) = env::var("NAPI_RS_INCLUDE_PATH") {
|
||||
bindgen_builder = bindgen_builder.clang_arg(format!("-I{}", uv_include_path));
|
||||
} else if cfg!(target_os = "freebsd") {
|
||||
}
|
||||
if cfg!(target_os = "freebsd") {
|
||||
bindgen_builder = bindgen_builder.clang_arg(format!(
|
||||
"-I{}",
|
||||
node_include_path_buf.parent().unwrap().to_str().unwrap()
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "cargo build && node ../scripts/index.js build",
|
||||
"build-aarch64": "cargo build --target aarch64-unknown-linux-gnu && node ../scripts/index.js build --target-triple aarch64-unknown-linux-gnu",
|
||||
"build-release": "cargo build --release && node ../scripts/index.js build --release",
|
||||
"test": "node ./index.js"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue