feat: build and test armv7

This commit is contained in:
LongYinan 2020-12-08 11:23:26 +08:00
parent 70c5a90326
commit d7e727d045
No known key found for this signature in database
GPG key ID: A3FFE134A3E20881
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) ![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) ![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-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) ![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) [![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", "version": "0.0.0",
"description": "A minimal library for building compiled Node add-ons in Rust.", "description": "A minimal library for building compiled Node add-ons in Rust.",
"private": "true", "private": "true",
"workspaces": [ "workspaces": ["cli", "triples"],
"cli",
"triples"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git@github.com:Brooooooklyn/napi-rs.git" "url": "git@github.com:Brooooooklyn/napi-rs.git"
@ -18,6 +15,7 @@
"build:bench": "yarn --cwd ./bench build", "build:bench": "yarn --cwd ./bench build",
"build:test": "yarn --cwd ./test_module build", "build:test": "yarn --cwd ./test_module build",
"build:test:aarch64": "yarn --cwd ./test_module build-aarch64", "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": "run-p format:md format:json format:yaml format:source format:rs",
"format:md": "prettier --parser markdown --write './**/*.md'", "format:md": "prettier --parser markdown --write './**/*.md'",
"format:json": "prettier --parser json --write './**/*.json'", "format:json": "prettier --parser json --write './**/*.json'",
@ -40,18 +38,10 @@
"arrowParens": "always" "arrowParens": "always"
}, },
"lint-staged": { "lint-staged": {
"*.js": [ "*.js": ["prettier --write"],
"prettier --write" "*.@(yml|yaml)": ["prettier --parser yaml --write"],
], "*.json": ["prettier --parser json --write"],
"*.@(yml|yaml)": [ "*.md": ["prettier --parser markdown --write"]
"prettier --parser yaml --write"
],
"*.json": [
"prettier --parser json --write"
],
"*.md": [
"prettier --parser markdown --write"
]
}, },
"husky": { "husky": {
"hooks": { "hooks": {
@ -87,4 +77,4 @@
"tslib": "^2.0.3", "tslib": "^2.0.3",
"typescript": "^4.1.2" "typescript": "^4.1.2"
} }
} }

View file

@ -5,9 +5,10 @@
"build": "node ../cli/scripts/index.js build --features \"latest\"", "build": "node ../cli/scripts/index.js build --features \"latest\"",
"build-napi3": "node ../cli/scripts/index.js build --features \"napi3\"", "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-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": "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-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", "build-release": "node ../cli/scripts/index.js build --features \"latest\" --release",
"test": "node ./index.js" "test": "node ./index.js"
} }
} }