From d7e727d045519f3a5071ee5b46f319d4b0b3f155 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Tue, 8 Dec 2020 11:23:26 +0800 Subject: [PATCH] feat: build and test armv7 --- .github/workflows/linux-armv7.yaml | 84 ++++++++++++++++++++++++++++++ README.md | 1 + package.json | 24 +++------ test_module/package.json | 3 +- 4 files changed, 94 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/linux-armv7.yaml diff --git a/.github/workflows/linux-armv7.yaml b/.github/workflows/linux-armv7.yaml new file mode 100644 index 00000000..5a833139 --- /dev/null +++ b/.github/workflows/linux-armv7.yaml @@ -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 + " diff --git a/README.md b/README.md index 93518763..183684b7 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/package.json b/package.json index 7c5fad59..12a4cfe1 100644 --- a/package.json +++ b/package.json @@ -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" } -} \ No newline at end of file +} diff --git a/test_module/package.json b/test_module/package.json index 68773df1..cdacb859 100644 --- a/test_module/package.json +++ b/test_module/package.json @@ -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" } -} \ No newline at end of file +}