From 3486cfb11fb040ad532e697034da54d868fab0e2 Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Mon, 24 Jul 2023 15:26:46 -0400 Subject: [PATCH] ci: use test matrix instead of individual test stages kudos to @t1m0thyj for converting to matrix :) Signed-off-by: Trae Yelovich --- .github/workflows/secrets-sdk.yml | 238 +++++------------------------- 1 file changed, 40 insertions(+), 198 deletions(-) diff --git a/.github/workflows/secrets-sdk.yml b/.github/workflows/secrets-sdk.yml index 8ca158d078..934ed16a59 100644 --- a/.github/workflows/secrets-sdk.yml +++ b/.github/workflows/secrets-sdk.yml @@ -2,15 +2,15 @@ name: Secrets SDK CI env: DEBUG: napi:* APP_NAME: keyring - MACOSX_DEPLOYMENT_TARGET: '10.13' -'on': + MACOSX_DEPLOYMENT_TARGET: "10.13" +"on": push: paths: - - 'packages/secrets/**' - - '.github/workflows/secrets-sdk.yml' + - "packages/secrets/**" + - ".github/workflows/secrets-sdk.yml" pull_request: paths: - - 'packages/secrets/**' + - "packages/secrets/**" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -122,7 +122,7 @@ jobs: if: ${{ matrix.settings.setup }} shell: bash - name: Install dependencies - run: npm install + run: npm ci working-directory: . - name: Setup node x86 uses: actions/setup-node@v3 @@ -137,7 +137,7 @@ jobs: if: ${{ matrix.settings.docker }} with: image: ${{ matrix.settings.docker }} - options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build' + options: "--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build" run: ${{ matrix.settings.build }} - name: Build run: ${{ matrix.settings.build }} @@ -197,7 +197,7 @@ jobs: # name: bindings-freebsd # path: ${{ env.APP_NAME }}.*.node # if-no-files-found: error - test-macOS-windows-binding: + test: defaults: run: working-directory: packages/secrets @@ -212,10 +212,22 @@ jobs: target: x86_64-pc-windows-msvc - host: macos-latest target: x86_64-apple-darwin + - host: ubuntu-latest + target: x86_64-unknown-linux-gnu + - host: ubuntu-latest + target: x86_64-unknown-linux-musl + - host: ubuntu-latest + target: aarch64-unknown-linux-gnu + platform: linux/arm64 + - host: ubuntu-latest + target: aarch64-unknown-linux-musl + platform: linux/arm64 + - host: ubuntu-latest + target: armv7-unknown-linux-gnueabihf + platform: linux/arm/v7 node: - - '14' - - '16' - - '18' + - "16" + - "18" runs-on: ${{ matrix.settings.host }} steps: - uses: actions/checkout@v3 @@ -226,199 +238,33 @@ jobs: check-latest: true cache: npm - name: Install dependencies - run: npm install + run: npm ci + working-directory: . - name: Download artifacts uses: actions/download-artifact@v3 with: name: bindings-${{ matrix.settings.target }} path: . - - name: Test bindings - run: npm run test - test-linux-x64-gnu-binding: - defaults: - run: - working-directory: packages/secrets - name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - '14' - - '16' - - '18' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: npm - - name: Install dependencies - run: npm install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-unknown-linux-gnu - path: . - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: node:${{ matrix.node }}-slim - options: '-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK' - run: | - set -e - apt update -y && apt install -y gnome-keyring - dbus-run-session -- bash linux-test.sh - test-linux-x64-musl-binding: - defaults: - run: - working-directory: packages/secrets - name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - '14' - - '16' - - '18' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: npm - - name: Install dependencies - run: npm install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-unknown-linux-musl - path: . - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: node:${{ matrix.node }}-alpine - options: '-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK' - run: | - set -e - apk add dbus gnome-keyring libsecret - dbus-run-session -- sh linux-test.sh - test-linux-aarch64-gnu-binding: - defaults: - run: - working-directory: packages/secrets - name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - '14' - - '16' - - '18' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-aarch64-unknown-linux-gnu - path: . - - name: Install dependencies - run: npm install - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: ghcr.io/napi-rs/napi-rs/nodejs:aarch64-${{ matrix.node }} - options: '-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK' - run: | - set -e - apt update -y && apt install -y gnome-keyring - dbus-run-session -- bash linux-test.sh - test-linux-aarch64-musl-binding: - defaults: - run: - working-directory: packages/secrets - name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} - needs: - - build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-aarch64-unknown-linux-musl - path: . - - name: Install dependencies - run: npm install - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: multiarch/alpine:aarch64-latest-stable - options: '-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK' - run: | - set -e - apk add dbus nodejs npm gnome-keyring libsecret - dbus-run-session -- sh linux-test.sh - test-linux-arm-gnueabihf-binding: - defaults: - run: - working-directory: packages/secrets - name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - '14' - - '16' - - '18' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-armv7-unknown-linux-gnueabihf - path: . - - name: Install dependencies - run: npm install - name: Set up QEMU uses: docker/setup-qemu-action@v2 + if: ${{ matrix.settings.platform }} with: - platforms: arm + platforms: ${{ matrix.settings.platform }} - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + if: ${{ matrix.settings.platform }} + - name: Test bindings + run: npm run test + if: ${{ matrix.settings.host != 'ubuntu-latest' }} - name: Setup and run tests uses: addnab/docker-run-action@v3 + if: ${{ matrix.settings.host == 'ubuntu-latest' }} with: - image: ghcr.io/napi-rs/napi-rs/nodejs:armhf-${{ matrix.node }} - options: '-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK' + image: ${{ format('node:{0}-{1}', matrix.node, endsWith(matrix.settings.target, 'musl') && 'alpine' || 'slim') }} + options: "-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK ${{ matrix.settings.platform && format('--platform={0}', matrix.settings.platform) }}" run: | set -e - apt update -y && apt install -y gnome-keyring - dbus-run-session -- bash linux-test.sh + ${{ endsWith(matrix.settings.target, 'musl') && 'apk add dbus gnome-keyring libsecret' || 'apt update -y && apt install -y gnome-keyring' }} + dbus-run-session -- source scripts/linux-test.sh publish: defaults: run: @@ -427,12 +273,7 @@ jobs: runs-on: ubuntu-latest needs: # - build-freebsd - - test-macOS-windows-binding - - test-linux-x64-gnu-binding - - test-linux-x64-musl-binding - - test-linux-aarch64-gnu-binding - - test-linux-aarch64-musl-binding - - test-linux-arm-gnueabihf-binding + - test steps: - uses: actions/checkout@v3 - name: Setup node @@ -442,7 +283,8 @@ jobs: check-latest: true cache: npm - name: Install dependencies - run: npm install + run: npm ci + working-directory: . - name: Package run: npm run prepublishOnly && npm pack env: @@ -451,7 +293,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: npm-package - path: '*.tgz' + path: "*.tgz" if-no-files-found: error # - name: Publish # run: |