From fdd5419fe5e876e24c856f6c3f9dcb759052c9e2 Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 19 Oct 2024 03:24:14 +0800 Subject: [PATCH] Add deno testing --- .github/workflows/run-tests-deno.yml | 30 +++++++++++++++++ .github/workflows/run-tests-node.yml | 48 ++++++++++++++++++++++++++++ .github/workflows/run-tests.yml | 46 ++++---------------------- 3 files changed, 84 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/run-tests-deno.yml create mode 100644 .github/workflows/run-tests-node.yml diff --git a/.github/workflows/run-tests-deno.yml b/.github/workflows/run-tests-deno.yml new file mode 100644 index 0000000..757ed21 --- /dev/null +++ b/.github/workflows/run-tests-deno.yml @@ -0,0 +1,30 @@ + +name: Deno Tests +on: + workflow_call: + +jobs: + + tests-deno: + name: Run Tests with Deno ${{ matrix.deno }} + runs-on: ubuntu-latest + strategy: + matrix: + deno: [ vx.x.x, v2 ] + steps: + + # https://github.com/actions/checkout/releases + - name: Checkout + uses: actions/checkout@v3.6.0 + + # https://github.com/denoland/setup-deno + - name: Setup Deno + uses: denoland/setup-deno@v2.0.0 + with: + deno-version: ${{ matrix.deno }} + + - name: Install Deps + run: deno install + + - name: Run Tests + run: deno task test diff --git a/.github/workflows/run-tests-node.yml b/.github/workflows/run-tests-node.yml new file mode 100644 index 0000000..6b2f57d --- /dev/null +++ b/.github/workflows/run-tests-node.yml @@ -0,0 +1,48 @@ + +name: Node Tests +on: + workflow_call: + +jobs: + + tests: + name: Run Tests with Node.js ${{ matrix.node }} + runs-on: ubuntu-latest + strategy: + matrix: + node: [ lts/*, latest, 16, 18, 20, 22 ] + steps: + + # https://github.com/actions/cache/blob/main/examples.md#node---npm + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + + # https://github.com/actions/cache/releases + - name: Use cache for npm + uses: actions/cache@v3.3.1 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: npm-${{ hashFiles('package.json') }} + restore-keys: npm- + + # https://github.com/actions/checkout/releases + - name: Checkout + uses: actions/checkout@v3.6.0 + + - name: Build package-lock + run: npm i --package-lock-only + + # https://github.com/actions/setup-node/releases + - name: Setup Node.js + uses: actions/setup-node@v3.8.1 + with: + node-version: ${{ matrix.node }} + + - name: Clean & Install Deps + run: npm ci + + - name: Run Tests + run: npm test diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 58f12f2..b478236 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,44 +17,10 @@ on: jobs: - tests: - name: Run Tests with Node.js ${{ matrix.node }} - runs-on: ubuntu-latest - strategy: - matrix: - node: [ lts/*, latest, 16, 18, 20 ] - steps: + run-tests-node: + name: Node Tests + uses: ./.github/workflows/run-tests-node.yml - # https://github.com/actions/cache/blob/main/examples.md#node---npm - - name: Get npm cache directory - id: npm-cache-dir - shell: bash - run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} - - # https://github.com/actions/cache/releases - - name: Use cache for npm - uses: actions/cache@v3.3.1 - id: npm-cache - with: - path: ${{ steps.npm-cache-dir.outputs.dir }} - key: npm-${{ hashFiles('package.json') }} - restore-keys: npm- - - # https://github.com/actions/checkout/releases - - name: Checkout - uses: actions/checkout@v3.6.0 - - - name: Build package-lock - run: npm i --package-lock-only - - # https://github.com/actions/setup-node/releases - - name: Setup Node.js - uses: actions/setup-node@v3.8.1 - with: - node-version: ${{ matrix.node }} - - - name: Clean & Install Deps - run: npm ci - - - name: Run Tests - run: npm test + run-tests-deno: + name: Deno Tests + uses: ./.github/workflows/run-tests-deno.yml