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

97 lines
2.5 KiB
YAML
Raw Normal View History

2020-07-29 23:04:47 +09:00
name: Test
2020-02-18 22:09:17 +09:00
on: [push, pull_request]
jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
2020-06-17 21:39:30 +09:00
node: ['10', '12', '14']
2020-07-29 23:04:47 +09:00
os: [ubuntu-latest, macos-latest, windows-latest]
2020-02-18 22:09:17 +09:00
2020-07-29 23:04:47 +09:00
name: stable - ${{ matrix.os }} - node@${{ matrix.node }}
runs-on: ${{ matrix.os }}
2020-02-18 22:09:17 +09:00
steps:
- uses: actions/checkout@v2
2020-02-18 22:09:17 +09:00
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
2020-07-29 23:04:47 +09:00
2020-02-18 22:09:17 +09:00
- name: Install llvm
2020-07-29 23:04:47 +09:00
if: matrix.os == 'windows-latest'
run: choco install -y llvm
2020-07-29 23:04:47 +09:00
- name: Set llvm path
if: matrix.os == 'windows-latest'
uses: allenevans/set-env@v1.0.0
2020-02-18 22:09:17 +09:00
with:
LIBCLANG_PATH: 'C:\Program Files\LLVM\bin'
2020-07-29 23:04:47 +09:00
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
2020-02-18 22:09:17 +09:00
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
2020-07-29 23:04:47 +09:00
2020-02-18 22:09:17 +09:00
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
2020-07-29 23:04:47 +09:00
key: stable-${{ matrix.os }}-node@${{ matrix.node }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
2020-02-18 22:09:17 +09:00
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
2020-07-29 23:04:47 +09:00
key: stable-${{ matrix.os }}gnu-node@${{ matrix.node }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache NPM dependencies
2020-02-18 22:09:17 +09:00
uses: actions/cache@v1
with:
2020-07-29 23:04:47 +09:00
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
2020-02-18 22:09:17 +09:00
- name: Check build
2020-02-18 22:09:17 +09:00
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --examples --tests -vvv
2020-02-18 22:09:17 +09:00
- name: Tests
2020-02-18 22:09:17 +09:00
uses: actions-rs/cargo@v1
timeout-minutes: 5
2020-02-18 22:09:17 +09:00
with:
command: test
args: -p napi-sys --lib -- --nocapture
- name: Unit tests
2020-02-18 22:09:17 +09:00
run: |
2020-02-19 00:05:13 +09:00
yarn
yarn --cwd ./test_module build
yarn test
2020-02-19 00:05:13 +09:00
env:
RUST_BACKTRACE: 1
2020-02-18 22:09:17 +09:00
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache