From b6b0eab9a2f1a0c939b1a2bfca3f8a65a991277d Mon Sep 17 00:00:00 2001 From: James Sumners Date: Fri, 28 Jun 2024 12:43:57 -0400 Subject: [PATCH] chore: Updated CI to use native arm64 runner --- .github/workflows/ci-workflow.yml | 130 ++++++++++++--------------- .github/workflows/create-release.yml | 67 ++++---------- 2 files changed, 71 insertions(+), 126 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 1f4cd1f..7526d21 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -10,7 +10,7 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: @@ -28,7 +28,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Install Dependencies - run: npm install + run: npm install - name: Run Linting run: npm run lint - name: Inspect Lockfile @@ -44,7 +44,7 @@ jobs: # Ubuntu does not ship x86 builds. - { os: ubuntu-latest, arch: x86 } runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }} + name: "${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }}" steps: - name: Checkout uses: actions/checkout@v4 @@ -56,7 +56,7 @@ jobs: - uses: actions/cache@v4 with: path: ${{ github.workspace }}/node_modules - key: ${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }} + key: "${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }}" - name: Install run: npm install - name: Unit Test @@ -79,39 +79,39 @@ jobs: flags: integration-tests-${{ matrix.node }}-${{ matrix.os }}-${{ matrix.arch }} - test_macos_arm: - strategy: - matrix: - os: [ macos-14 ] - node: [ 16, 18, 20, 22 ] - arch: [ arm64 ] - runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: ${{ github.workspace }}/node_modules - key: ${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }} - - name: Use node ${{ matrix.node }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - architecture: ${{ matrix.arch }} - - name: Install - run: npm install - - name: Unit Test - run: npm run unit - - name: Post Unit Test Coverage - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - directory: ./coverage/unit/ - files: lcov.info - flags: unit-tests-${{ matrix.node }}-${{ matrix.os }}-${{ matrix.arch }} - # Disabled due to the macOS environment in GHA being very inconsistent, - # but also consistently too slow. +# Disabled due to the macOS environment in GHA being very inconsistent, +# but also consistently too slow. +# test_macos_arm: +# strategy: +# matrix: +# os: [ macos-14 ] +# node: [ 16, 18, 20, 22 ] +# arch: [ arm64 ] +# runs-on: ${{ matrix.os }} +# name: "${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }}" +# steps: +# - name: Checkout +# uses: actions/checkout@v4 +# - uses: actions/cache@v4 +# with: +# path: ${{ github.workspace }}/node_modules +# key: "${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }}" +# - name: Use node ${{ matrix.node }} +# uses: actions/setup-node@v4 +# with: +# node-version: ${{ matrix.node }} +# architecture: ${{ matrix.arch }} +# - name: Install +# run: npm install +# - name: Unit Test +# run: npm run unit +# - name: Post Unit Test Coverage +# uses: codecov/codecov-action@v4 +# with: +# token: ${{ secrets.CODECOV_TOKEN }} +# directory: ./coverage/unit/ +# files: lcov.info +# flags: unit-tests-${{ matrix.node }}-${{ matrix.os }}-${{ matrix.arch }} # - name: Integration Test # run: npm run integration # - name: Post Integration Test Coverage @@ -144,43 +144,23 @@ jobs: with: path: ${{ github.workspace }}/node_modules key: linux-arm-node-${{ matrix.node }}-${{ env.CACHE_KEY }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - uses: docker/setup-buildx-action@v3 - - uses: docker/build-push-action@v5 - with: - context: . - build-args: | - NODE_VERSION=${{ matrix.node }} - file: linux_arm.dockerfile - tags: linux_arm:node-${{ matrix.node }} - load: true - push: false - platforms: linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Run test - uses: addnab/docker-run-action@v3 + - name: Install + run: npm install + - name: Unit Test + run: npm run unit + - name: Post Unit Test Coverage + uses: codecov/codecov-action@v4 with: - image: linux_arm:node-${{ matrix.node }} - options: --platform linux/arm64 -v ${{ github.workspace }}:/host - run: | - cp -R /host/node_modules . 2>/dev/null - rm -rf /host/node_modules 2>/dev/null - # npm install will fail on Node 18 every time unless we use this - # very odd fix: - # https://github.com/npm/cli/issues/4652#issuecomment-1126672629 - npm install --verbose --maxsockets 1 - cp -R node_modules /host/ - npm run unit - # Skipping integration until we can get native arm64 runners - # npm run integration - - name: Update modules cache - uses: actions/cache/save@v4 - # We always want to run this step even if the "test" step failed. - if: ${{ steps.cache_restore.outputs.cache-hit != 'true' && !cancelled() }} + token: ${{ secrets.CODECOV_TOKEN }} + directory: ./coverage/unit/ + files: lcov.info + flags: unit-tests-${{ matrix.node }}-linux-arm64 + - name: Integration Test + run: npm run integration + - name: Post Integration Test Coverage + uses: codecov/codecov-action@v4 with: - path: ${{ github.workspace }}/node_modules - key: linux-arm-node-${{ matrix.node }}-${{ env.CACHE_KEY }} + token: ${{ secrets.CODECOV_TOKEN }} + directory: ./coverage/integration + files: lcov.info + flags: integration-tests-${{ matrix.node }}-linux-arm64 diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index c4ea770..2eafd91 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -18,7 +18,7 @@ jobs: # Ubuntu does not ship x86 builds. - { os: ubuntu-latest, arch: x86 } runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }} + name: "${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }}" steps: - name: Checkout uses: actions/checkout@v4 @@ -30,7 +30,7 @@ jobs: - uses: actions/cache@v4 with: path: ${{ github.workspace }}/node_modules - key: ${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }} + key: "${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }}" - name: Install run: npm install - name: Build @@ -38,7 +38,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.node }} + name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.node }}" path: prebuilds build_macos_arm: @@ -48,14 +48,14 @@ jobs: node: [ 16, 18, 20, 22 ] arch: [ arm64 ] runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }} + name: "${{ matrix.os }} / Node ${{ matrix.node }} ${{ matrix.arch }}" steps: - name: Checkout uses: actions/checkout@v4 - uses: actions/cache@v4 with: path: ${{ github.workspace }}/node_modules - key: ${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }} + key: "${{ matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node }}-${{ hashFiles('./package.json') }}" - name: Use node ${{ matrix.node }} uses: actions/setup-node@v4 with: @@ -68,7 +68,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.node }} + name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.node }}" path: prebuilds build_linux_arm: @@ -85,57 +85,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Compute cache key - run: echo -e "CACHE_KEY=$(shasum -a 256 package.json | cut -f1 -d ' ')" >> "$GITHUB_ENV" - - name: Restore modules cache - id: cache_restore - uses: actions/cache/restore@v4 - with: - path: ${{ github.workspace }}/node_modules - key: linux-arm-node-${{ matrix.node }}-${{ env.CACHE_KEY }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - uses: docker/setup-buildx-action@v3 - - uses: docker/build-push-action@v5 - with: - context: . - build-args: | - NODE_VERSION=${{ matrix.node }} - file: linux_arm.dockerfile - tags: linux_arm:node-${{ matrix.node }} - load: true - push: false - platforms: linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Run build - uses: addnab/docker-run-action@v3 + - name: Use node ${{ matrix.node }} + uses: actions/setup-node@v4 with: - image: linux_arm:node-${{ matrix.node }} - options: --platform linux/arm64 -v ${{ github.workspace }}:/host - run: | - cp -R /host/node_modules . 2>/dev/null - rm -rf /host/node_modules 2>/dev/null - # npm install will fail on Node 18 every time unless we use this - # very odd fix: - # https://github.com/npm/cli/issues/4652#issuecomment-1126672629 - npm install --verbose --maxsockets 1 - cp -R node_modules /host/ - npm run build - cp -R prebuilds /host/ - - name: Update modules cache - uses: actions/cache/save@v4 - # We always want to run this step even if the "test" step failed. - if: ${{ steps.cache_restore.outputs.cache-hit != 'true' && !cancelled() }} + node-version: ${{ matrix.node }} + - uses: actions/cache@v4 with: path: ${{ github.workspace }}/node_modules - key: linux-arm-node-${{ matrix.node }}-${{ env.CACHE_KEY }} + key: "linux-arm64-node-${{ matrix.node }}-${{ hashFiles('./package.json') }}" + - name: Install + run: npm install + - name: Build + run: npm run build - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: linux-arm64-${{ matrix.node }} + name: "linux-arm64-${{ matrix.node }}" path: prebuilds package: