Merge pull request #342 from napi-rs/armv7

feat: build and test armv7
This commit is contained in:
LongYinan 2020-12-08 12:12:40 +08:00 committed by GitHub
commit 0df4320ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 94 additions and 18 deletions

84
.github/workflows/linux-armv7.yaml vendored Normal file
View file

@ -0,0 +1,84 @@
name: Linux-armv7
env:
DEBUG: 'napi:*'
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: 'arm-linux-gnueabihf-gcc'
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: stable - aarch64-unknown-linux-gnu - node@14
runs-on: ubuntu-latest
steps:
- run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: 14
check-latest: true
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install armv7 toolchain
run: rustup target add armv7-unknown-linux-gnueabihf
- 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-armv7-gnu-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-linux-armv7-gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: npm-cache-linux-armv7-gnu-node@14-${{ hashFiles('yarn.lock') }}
- name: Install cross compile toolchain
run: sudo apt-get install gcc-arm-linux-gnueabihf -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:armv7
- name: Setup and run tests
uses: docker://multiarch/ubuntu-core:armhf-focal
with:
args: >
sh -c "
apt-get update && \
apt-get install -y ca-certificates gnupg2 curl && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm test
"

View file

@ -17,6 +17,7 @@ A minimal library for building compiled `NodeJS` add-ons in `Rust`.
![Linux musl](https://github.com/napi-rs/napi-rs/workflows/Linux%20musl/badge.svg)
![macOS/Windows/Linux x64](https://github.com/napi-rs/napi-rs/workflows/macOS/Windows/Linux%20x64/badge.svg)
![Linux-aarch64](https://github.com/napi-rs/napi-rs/workflows/Linux-aarch64/badge.svg)
![Linux-armv7](https://github.com/napi-rs/napi-rs/workflows/Linux-armv7/badge.svg)
![Windows i686](https://github.com/napi-rs/napi-rs/workflows/Windows%20i686/badge.svg)
[![FreeBSD](https://api.cirrus-ci.com/github/napi-rs/napi-rs.svg)](https://cirrus-ci.com/github/napi-rs/napi-rs?branch=main)

View file

@ -3,10 +3,7 @@
"version": "0.0.0",
"description": "A minimal library for building compiled Node add-ons in Rust.",
"private": "true",
"workspaces": [
"cli",
"triples"
],
"workspaces": ["cli", "triples"],
"repository": {
"type": "git",
"url": "git@github.com:Brooooooklyn/napi-rs.git"
@ -18,6 +15,7 @@
"build:bench": "yarn --cwd ./bench build",
"build:test": "yarn --cwd ./test_module build",
"build:test:aarch64": "yarn --cwd ./test_module build-aarch64",
"build:test:armv7": "yarn --cwd ./test_module build-armv7",
"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'",
@ -40,18 +38,10 @@
"arrowParens": "always"
},
"lint-staged": {
"*.js": [
"prettier --write"
],
"*.@(yml|yaml)": [
"prettier --parser yaml --write"
],
"*.json": [
"prettier --parser json --write"
],
"*.md": [
"prettier --parser markdown --write"
]
"*.js": ["prettier --write"],
"*.@(yml|yaml)": ["prettier --parser yaml --write"],
"*.json": ["prettier --parser json --write"],
"*.md": ["prettier --parser markdown --write"]
},
"husky": {
"hooks": {
@ -87,4 +77,4 @@
"tslib": "^2.0.3",
"typescript": "^4.1.2"
}
}
}

View file

@ -5,9 +5,10 @@
"build": "node ../cli/scripts/index.js build --features \"latest\"",
"build-napi3": "node ../cli/scripts/index.js build --features \"napi3\"",
"build-aarch64": "node ../cli/scripts/index.js build --features \"latest\" --target aarch64-unknown-linux-gnu",
"build-armv7": "node ../cli/scripts/index.js build --features \"latest\" --target armv7-unknown-linux-gnueabihf",
"build-i686": "node ../cli/scripts/index.js build --features \"latest\" --target i686-pc-windows-msvc",
"build-i686-release": "node ../cli/scripts/index.js build --release --features \"latest\" --target i686-pc-windows-msvc",
"build-release": "node ../cli/scripts/index.js build --features \"latest\" --release",
"test": "node ./index.js"
}
}
}