napi-rs/.github/workflows/test.yaml

85 lines
2.1 KiB
YAML
Raw Normal View History

2020-10-14 16:15:20 +08:00
name: macOS/Windows/Linux x64
2020-02-18 21:09:17 +08:00
env:
DEBUG: 'napi:*'
2020-08-17 22:36:09 +08:00
on:
push:
2020-12-03 16:30:14 +08:00
branches:
- main
2020-08-17 22:36:09 +08:00
pull_request:
2020-02-18 21:09:17 +08:00
jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
2021-04-21 17:19:45 +08:00
node: ['12', '14', '16']
2020-07-29 22:04:47 +08:00
os: [ubuntu-latest, macos-latest, windows-latest]
2020-02-18 21:09:17 +08:00
2020-07-29 22:04:47 +08:00
name: stable - ${{ matrix.os }} - node@${{ matrix.node }}
runs-on: ${{ matrix.os }}
2020-02-18 21:09:17 +08:00
steps:
- uses: actions/checkout@v2
2020-02-18 21:09:17 +08:00
- name: Setup node
2021-01-05 23:53:23 +08:00
uses: actions/setup-node@v2
2020-02-18 21:09:17 +08:00
with:
node-version: ${{ matrix.node }}
2020-11-10 11:09:25 +08:00
check-latest: true
2020-07-29 22:04:47 +08:00
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
2020-02-18 21:09:17 +08:00
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
2020-07-29 22:04:47 +08:00
2020-02-18 21:09:17 +08:00
- name: Cache cargo registry
2021-07-30 13:20:40 +08:00
uses: actions/cache@v2
2020-02-18 21:09:17 +08:00
with:
path: ~/.cargo/registry
2020-07-29 22:04:47 +08:00
key: stable-${{ matrix.os }}-node@${{ matrix.node }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
2020-02-18 21:09:17 +08:00
- name: Cache cargo index
2021-07-30 13:20:40 +08:00
uses: actions/cache@v2
2020-02-18 21:09:17 +08:00
with:
path: ~/.cargo/git
2020-07-29 22:04:47 +08:00
key: stable-${{ matrix.os }}gnu-node@${{ matrix.node }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
2021-07-30 13:20:40 +08:00
uses: actions/cache@v2
2020-02-18 21:09:17 +08:00
with:
2020-07-29 22:04:47 +08:00
path: node_modules
key: npm-cache-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
- name: 'Install dependencies'
run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000
2020-07-29 22:04:47 +08:00
- name: 'Build TypeScript'
run: yarn build
2020-02-18 21:09:17 +08:00
- name: Check build
2020-02-18 21:09:17 +08:00
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --examples --tests -vvv
2020-02-18 21:09:17 +08:00
- name: Unit tests
2020-02-18 21:09:17 +08:00
run: |
2020-10-10 14:50:35 +08:00
yarn build:test
yarn test
2020-02-18 23:05:13 +08:00
env:
RUST_BACKTRACE: 1
2020-02-18 21:09:17 +08:00
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache