From 41c6d1ae52cd086502d0f3b1704da6f04239d07c Mon Sep 17 00:00:00 2001 From: Joel Arvidsson Date: Sun, 13 Oct 2024 18:21:38 +0200 Subject: [PATCH] Run tests in CI --- .github/actions/setup/action.yml | 14 ++++++++ .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++ .node-version | 1 + 3 files changed, 75 insertions(+) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .node-version diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..d6af004 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,14 @@ +name: Setup +description: Setup Node.js and install dependencies + +runs: + using: composite + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .node-version + + - name: Install dependencies + run: yarn install --immutable + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..731791d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +# +name: CI + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize] + paths-ignore: + - "**/*.md" + - "**/*.yml" + - "!.github/workflows/ci.yml" + push: + branches: + - main + - test-automation + paths-ignore: + - "**/*.md" + - "**/*.yml" + - "!.github/workflows/ci.yml" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +jobs: + test: + name: Test + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + - os: macos-14 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: Boshen/setup-rust@main + with: + # warm cache factory for all other CI jobs + # cache `target` directory to avoid download crates + save-cache: ${{ github.ref_name == 'main' }} + cache-key: warm + - run: cargo check + - run: cargo test + - run: git diff --exit-code # Must commit everything + + napi: + name: Test NAPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Boshen/setup-rust@main + with: + # warm cache factory for all other CI jobs + # cache `target` directory to avoid download crates + save-cache: ${{ github.ref_name == 'main' }} + cache-key: warm + - uses: ./.github/actions/setup + - run: yarn build + - run: node napi/test/sanity.spec.mjs diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..2a393af --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +20.18.0