ci: upgrade pipeline

This commit is contained in:
LongYinan 2020-07-29 22:04:47 +08:00
parent 2073f23a91
commit e34b3dc5c2
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
7 changed files with 124 additions and 174 deletions

62
.github/workflows/lint.yaml vendored Normal file
View file

@ -0,0 +1,62 @@
name: Lint
on: [push, pull_request]
jobs:
lint:
name: Lint SourceCode
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: default
override: true
- 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: lint-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: lint-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: lint-${{ hashFiles('yarn.lock') }}
restore-keys: |
npm-cache-
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org
- name: 'Lint JS/TS'
run: yarn lint
- name: 'Lint rust'
run: cargo fmt -- --check
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache

View file

@ -27,6 +27,12 @@ jobs:
docker pull docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts
docker tag docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts builder
- name: 'Install node dependencies'
run: docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/napi-rs -w /napi-rs builder yarn
- name: 'Build TypeScript'
run: docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/napi-rs -w /napi-rs builder yarn build
- name: Run check
run: |
docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/napi-rs -w /napi-rs builder cargo check --all --bins --examples --tests -vvv
@ -37,6 +43,6 @@ jobs:
- name: Unit test
run: |
docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/napi-rs -w /napi-rs builder sh -c "yarn && yarn --cwd ./test_module build && yarn test"
docker run --rm -v $(pwd)/.cargo:/root/.cargo -v $(pwd):/napi-rs -w /napi-rs builder sh -c "yarn --cwd ./test_module build && yarn test"
env:
RUST_BACKTRACE: 1

View file

@ -1,74 +0,0 @@
name: Linux
on: [push, pull_request]
jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
node: ['10', '12', '14']
name: stable - x86_64-unknown-linux-gnu - node@${{ matrix.node }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
profile: minimal
override: true
- 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-x86_64-unknown-linux-gnu-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-x86_64-unknown-linux-gnu-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: stable-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Check build
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --examples --tests -vvv
- name: Tests
uses: actions-rs/cargo@v1
timeout-minutes: 5
with:
command: test
args: -p napi-sys --lib -- --nocapture
- name: Unit tests
run: |
yarn
yarn --cwd ./test_module build
yarn test
env:
RUST_BACKTRACE: 1
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache

View file

@ -1,74 +0,0 @@
name: macOS
on: [push, pull_request]
jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
node: ['10', '12', '14']
name: stable - x86_64-apple-darwin - node@${{ matrix.node }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-apple-darwin
profile: minimal
override: true
- 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-x86_64-apple-darwin-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-x86_64-apple-darwin-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: stable-x86_64-apple-darwin-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Check build
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --examples --tests -vvv
- name: Tests
uses: actions-rs/cargo@v1
timeout-minutes: 5
with:
command: test
args: -p napi-sys --lib -- --nocapture
- name: Unit tests
run: |
yarn
yarn --cwd ./test_module build
yarn test
env:
RUST_BACKTRACE: 1
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache

View file

@ -31,17 +31,31 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: stable-x86_64-unknown-linux-gnu-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
key: stable-napi3-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-x86_64-unknown-linux-gnu-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
key: stable-napi3-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: stable-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
key: stable-napi3-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: node_modules
key: napi3-${{ hashFiles('yarn.lock') }}
restore-keys: |
npm-cache-
- name: 'Install dependencies'
run: yarn add ava@2 --dev --ignore-engines
- name: 'Build TypeScript'
run: yarn build
- name: Check build
uses: actions-rs/cargo@v1
@ -58,7 +72,6 @@ jobs:
- name: Unit tests
run: |
yarn add ava@2 --dev --ignore-engines
yarn --cwd ./test_module build
yarn test
env:

View file

@ -1,4 +1,4 @@
name: Windows
name: Test
on: [push, pull_request]
@ -8,11 +8,10 @@ jobs:
fail-fast: false
matrix:
node: ['10', '12', '14']
target:
- x86_64-pc-windows-msvc
os: [ubuntu-latest, macos-latest, windows-latest]
name: stable - ${{ matrix.target }} - node@${{ matrix.node }}
runs-on: windows-latest
name: stable - ${{ matrix.os }} - node@${{ matrix.node }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
@ -21,37 +20,54 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable-${{ matrix.target }}
profile: minimal
override: true
- name: Install llvm
if: matrix.os == 'windows-latest'
run: choco install -y llvm
- name: set environment variables
uses: allenevans/set-env@v1.1.0
- name: Set llvm path
if: matrix.os == 'windows-latest'
uses: allenevans/set-env@v1.0.0
with:
LIBCLANG_PATH: 'C:\Program Files\LLVM\bin'
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- 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-${{ matrix.target }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
key: stable-${{ matrix.os }}-node@${{ matrix.node }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-${{ matrix.target }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
key: stable-${{ matrix.os }}gnu-node@${{ matrix.node }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
uses: actions/cache@v1
with:
path: target
key: stable-${{ matrix.target }}-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
path: node_modules
key: npm-cache-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
npm-cache-
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --registry https://registry.npmjs.org
- name: 'Build TypeScript'
run: yarn build
- name: Check build
uses: actions-rs/cargo@v1

View file

@ -3,7 +3,7 @@
"version": "0.2.4",
"description": "A minimal library for building compiled Node add-ons in Rust.",
"bin": {
"napi": "scripts/napi.js"
"napi": "scripts/index.js"
},
"repository": {
"type": "git",
@ -18,12 +18,14 @@
],
"license": "MIT",
"scripts": {
"build": "tsc -p tsconfig.json",
"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'",
"format:rs": "cargo fmt",
"format:source": "prettier --config ./package.json --write './**/*.js'",
"format:yaml": "prettier --parser yaml --write './**/*.{yml,yaml}'",
"lint": "eslint -c .eslintrc.yml",
"test": "ava"
},
"bugs": {
@ -33,7 +35,6 @@
"dependencies": {
"clipanion": "^2.4.2",
"inquirer": "^7.3.3",
"minimist": "^1.2.5",
"toml": "^3.0.0"
},
"prettier": {
@ -43,7 +44,7 @@
"trailingComma": "all",
"arrowParens": "always"
},
"files": ["scripts/napi.js", "LICENSE"],
"files": ["scripts", "LICENSE"],
"lint-staged": {
"*.js": ["prettier --write"],
"*.@(yml|yaml)": ["prettier --parser yaml --write"],