From 2877ca0e3dac3851befe17c075e3c7de5bb02ae3 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 30 Aug 2024 11:22:06 +0200 Subject: [PATCH 01/14] ARM64 build on native runner --- .github/workflows/build-and-test-snap.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 61d8d68..5d060cf 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -93,27 +93,21 @@ jobs: needs: test-amd64 outputs: snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: ubuntu-latest + runs-on: Ubuntu_ARM64_4C_16G_01 steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 - - - name: Build snap - uses: diddlesnaps/snapcraft-multiarch-action@v1 + - name: Build Snap + uses: snapcore/action-build@v1 id: snapcraft - with: - architecture: arm64 - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ env.ARTIFACT_ARM64 }} path: ${{ steps.snapcraft.outputs.snap }} + if-no-files-found: error publish-arm64: # Only publish if we are on the main branch From 63272676e49a2da3862fe8b9621088c3f4149d98 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 30 Aug 2024 11:30:58 +0200 Subject: [PATCH 02/14] Run arm64 and amd64 builds in parallel --- .github/workflows/build-and-test-snap.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 5d060cf..ae4dd2e 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -89,8 +89,6 @@ jobs: release: latest/edge build-arm64: - # We do not start the long running arm64 build unless the amd64 tests have passed. - needs: test-amd64 outputs: snap: ${{ steps.snapcraft.outputs.snap }} runs-on: Ubuntu_ARM64_4C_16G_01 @@ -112,7 +110,8 @@ jobs: publish-arm64: # Only publish if we are on the main branch if: github.ref == 'refs/heads/main' - needs: [build-arm64] + # For now depend on the amd64 tests to gate arm64 publishing + needs: [build-arm64, test-amd64] runs-on: ubuntu-latest steps: - name: Download locally built snap From d2c21dc8c2158098dff66e6ea399e5504cd706ec Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 30 Aug 2024 13:02:44 +0200 Subject: [PATCH 03/14] Switch to Canonical hosted runners --- .github/workflows/build-and-test-snap.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index ae4dd2e..7baf358 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -91,7 +91,7 @@ jobs: build-arm64: outputs: snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: Ubuntu_ARM64_4C_16G_01 + runs-on: [self-hosted, ARM64, Linux] steps: - name: Checkout code uses: actions/checkout@v4 From 542d26db717031539482fd8572d767289b0423b5 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 30 Aug 2024 17:13:52 +0200 Subject: [PATCH 04/14] Split workflows into separate files for arm and x86 --- ...uild-and-test-snap.yml => build-amd64.yml} | 107 +++++++---------- .github/workflows/build-arm64.yml | 108 ++++++++++++++++++ 2 files changed, 152 insertions(+), 63 deletions(-) rename .github/workflows/{build-and-test-snap.yml => build-amd64.yml} (54%) create mode 100644 .github/workflows/build-arm64.yml diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-amd64.yml similarity index 54% rename from .github/workflows/build-and-test-snap.yml rename to .github/workflows/build-amd64.yml index 7baf358..a0c2a57 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-amd64.yml @@ -2,20 +2,19 @@ name: Build, test and publish snap on: schedule: - - cron: "20 2 * * 1" # Monday morning 02:20 UTC + - cron: "20 2 * * 1" # Monday morning 02:20 UTC push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] # Allow manual trigger workflow_dispatch: env: ARTIFACT_AMD64: chip-tool_${{ github.run_number}}_amd64 - ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64 jobs: - build-amd64: + build: outputs: snap: ${{ steps.snapcraft.outputs.snap }} runs-on: ubuntu-latest @@ -33,16 +32,34 @@ jobs: name: ${{ env.ARTIFACT_AMD64 }} path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error - - test-amd64: - needs: build-amd64 + + publish-edge: + # Only publish if we are on the main branch + # if: github.ref == 'refs/heads/main' + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Download locally built snap + uses: actions/download-artifact@v4 + with: + name: ${{ env.ARTIFACT_AMD64 }} + + - uses: snapcore/action-publish@v1 + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + with: + snap: ${{ needs.build.outputs.snap }} + release: latest/edge/test + + test: + needs: build runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: lfs: true - + - name: Download locally built snap uses: actions/download-artifact@v4 with: @@ -51,7 +68,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.*' + go-version: "1.*" cache: false - name: Run tests @@ -59,69 +76,33 @@ jobs: working-directory: tests env: SKIP_TEARDOWN_REMOVAL: true - LOCAL_SERVICE_SNAP: ../${{ needs.build-amd64.outputs.snap }} + LOCAL_SERVICE_SNAP: ../${{ needs.build.outputs.snap }} run: | go test -failfast -p 1 -timeout 30m -v - name: Upload snap logs - if: always() + if: always() uses: actions/upload-artifact@v4 with: name: logs path: tests/logs/*.log - publish-amd64: - # Only publish if we are on the main branch - if: github.ref == 'refs/heads/main' - needs: [build-amd64, test-amd64] + promote-beta: + # Only promote if we are on the main branch + # if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest + needs: [test, publish-edge] steps: - - name: Download locally built snap - uses: actions/download-artifact@v4 - with: - name: ${{ env.ARTIFACT_AMD64 }} - - - uses: snapcore/action-publish@v1 - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - with: - snap: ${{ needs.build-amd64.outputs.snap }} - release: latest/edge - - build-arm64: - outputs: - snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: [self-hosted, ARM64, Linux] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build Snap - uses: snapcore/action-build@v1 - id: snapcraft - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.ARTIFACT_ARM64 }} - path: ${{ steps.snapcraft.outputs.snap }} - if-no-files-found: error - - publish-arm64: - # Only publish if we are on the main branch - if: github.ref == 'refs/heads/main' - # For now depend on the amd64 tests to gate arm64 publishing - needs: [build-arm64, test-amd64] - runs-on: ubuntu-latest - steps: - - name: Download locally built snap - uses: actions/download-artifact@v4 - with: - name: ${{ env.ARTIFACT_ARM64 }} + - name: Install Snapcraft + # Install snapcraft and add it to PATH + run: | + sudo snap install snapcraft --classic + echo /snap/bin >> $GITHUB_PATH + shell: bash - - uses: snapcore/action-publish@v1 - env: + - name: Promote Snap + env: # Workaround for https://github.com/snapcore/snapcraft/issues/4439 + SNAPCRAFT_HAS_TTY: "true" SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - with: - snap: ${{ needs.build-arm64.outputs.snap }} - release: latest/edge + run: | + yes | snapcraft promote chip-tool --from-channel latest/edge/test --to-channel latest/beta/test diff --git a/.github/workflows/build-arm64.yml b/.github/workflows/build-arm64.yml new file mode 100644 index 0000000..e75709d --- /dev/null +++ b/.github/workflows/build-arm64.yml @@ -0,0 +1,108 @@ +name: Build, test and publish snap + +on: + schedule: + - cron: "20 2 * * 1" # Monday morning 02:20 UTC + push: + branches: [main] + pull_request: + branches: [main] + # Allow manual trigger + workflow_dispatch: + +env: + ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64 + +jobs: + build: + outputs: + snap: ${{ steps.snapcraft.outputs.snap }} + runs-on: [self-hosted, ARM64, Linux] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build Snap + uses: snapcore/action-build@v1 + id: snapcraft + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTIFACT_ARM64 }} + path: ${{ steps.snapcraft.outputs.snap }} + if-no-files-found: error + + publish-edge: + # Only publish if we are on the main branch + # if: github.ref == 'refs/heads/main' + needs: [build] + runs-on: [self-hosted, ARM64, Linux] + steps: + - name: Download locally built snap + uses: actions/download-artifact@v4 + with: + name: ${{ env.ARTIFACT_ARM64 }} + + - uses: snapcore/action-publish@v1 + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + with: + snap: ${{ needs.build.outputs.snap }} + release: latest/edge/test + + test: + needs: build + runs-on: [self-hosted, ARM64, Linux] + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + lfs: true + + - name: Download locally built snap + uses: actions/download-artifact@v4 + with: + name: ${{ env.ARTIFACT_ARM64 }} + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.*" + cache: false + + - name: Run tests + shell: bash + working-directory: tests + env: + SKIP_TEARDOWN_REMOVAL: true + LOCAL_SERVICE_SNAP: ../${{ needs.build.outputs.snap }} + run: | + go test -failfast -p 1 -timeout 30m -v + + - name: Upload snap logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs + path: tests/logs/*.log + + promote-beta: + # Only promote if we are on the main branch + # if: github.ref == 'refs/heads/main' + runs-on: [self-hosted, ARM64, Linux] + needs: [test, publish-edge] + steps: + - name: Install Snapcraft + # Install snapcraft and add it to PATH + run: | + sudo snap install snapcraft --classic + echo /snap/bin >> $GITHUB_PATH + shell: bash + + - name: Promote Snap + env: # Workaround for https://github.com/snapcore/snapcraft/issues/4439 + SNAPCRAFT_HAS_TTY: "true" + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + run: | + yes | snapcraft promote chip-tool --from-channel latest/edge/test --to-channel latest/beta/test From 7c9db29a5585ce15e58f8ccde95abdefc0def434 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 30 Aug 2024 17:15:54 +0200 Subject: [PATCH 05/14] Rename workflows --- .github/workflows/build-amd64.yml | 2 +- .github/workflows/build-arm64.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-amd64.yml b/.github/workflows/build-amd64.yml index a0c2a57..952cbfa 100644 --- a/.github/workflows/build-amd64.yml +++ b/.github/workflows/build-amd64.yml @@ -1,4 +1,4 @@ -name: Build, test and publish snap +name: Snap CI AMD64 on: schedule: diff --git a/.github/workflows/build-arm64.yml b/.github/workflows/build-arm64.yml index e75709d..890e691 100644 --- a/.github/workflows/build-arm64.yml +++ b/.github/workflows/build-arm64.yml @@ -1,4 +1,4 @@ -name: Build, test and publish snap +name: Snap CI ARM64 on: schedule: From 351a09fc3d6ee8b1f754c56f28042286be48a911 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 2 Sep 2024 09:17:49 +0200 Subject: [PATCH 06/14] Test without lfs --- .github/workflows/build-amd64.yml | 2 -- .github/workflows/build-arm64.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/build-amd64.yml b/.github/workflows/build-amd64.yml index 952cbfa..7817113 100644 --- a/.github/workflows/build-amd64.yml +++ b/.github/workflows/build-amd64.yml @@ -57,8 +57,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - lfs: true - name: Download locally built snap uses: actions/download-artifact@v4 diff --git a/.github/workflows/build-arm64.yml b/.github/workflows/build-arm64.yml index 890e691..e84500e 100644 --- a/.github/workflows/build-arm64.yml +++ b/.github/workflows/build-arm64.yml @@ -57,8 +57,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - lfs: true - name: Download locally built snap uses: actions/download-artifact@v4 From 45eae107918b8cc6c16c44f7f849bceeacb965e2 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 30 Sep 2024 09:38:36 +0200 Subject: [PATCH 07/14] Disable separate workflows. Add test matrix wf --- .github/workflows/build-amd64.yml | 12 ++++---- .github/workflows/build-arm64.yml | 12 ++++---- .github/workflows/snap-ci.yaml | 46 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/snap-ci.yaml diff --git a/.github/workflows/build-amd64.yml b/.github/workflows/build-amd64.yml index 7817113..be3b5ea 100644 --- a/.github/workflows/build-amd64.yml +++ b/.github/workflows/build-amd64.yml @@ -1,12 +1,12 @@ name: Snap CI AMD64 on: - schedule: - - cron: "20 2 * * 1" # Monday morning 02:20 UTC - push: - branches: [main] - pull_request: - branches: [main] + # schedule: + # - cron: "20 2 * * 1" # Monday morning 02:20 UTC + # push: + # branches: [main] + # pull_request: + # branches: [main] # Allow manual trigger workflow_dispatch: diff --git a/.github/workflows/build-arm64.yml b/.github/workflows/build-arm64.yml index e84500e..14ac540 100644 --- a/.github/workflows/build-arm64.yml +++ b/.github/workflows/build-arm64.yml @@ -1,12 +1,12 @@ name: Snap CI ARM64 on: - schedule: - - cron: "20 2 * * 1" # Monday morning 02:20 UTC - push: - branches: [main] - pull_request: - branches: [main] + # schedule: + # - cron: "20 2 * * 1" # Monday morning 02:20 UTC + # push: + # branches: [main] + # pull_request: + # branches: [main] # Allow manual trigger workflow_dispatch: diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml new file mode 100644 index 0000000..3028d6f --- /dev/null +++ b/.github/workflows/snap-ci.yaml @@ -0,0 +1,46 @@ +name: Snap CI + +on: + # schedule: + # - cron: "20 2 * * 1" # Monday morning 02:20 UTC + push: + # branches: [main] + pull_request: + # branches: [main] + # Allow manual trigger + workflow_dispatch: + +env: + ARTIFACT_AMD64: chip-tool_${{ github.run_number}}_amd64 + ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64 + +jobs: + build_matrix: + strategy: + matrix: + runner: ["ubuntu-latest", [self-hosted, ARM64, Linux]] + runs-on: ${{ matrix.runner }} + env: + RUNNER: ${{ matrix.runner }} + + # outputs: + # snap: ${{ steps.snapcraft.outputs.snap }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Debug print + run: | + echo "Running on $RUNNER" + + # - name: Build snap + # uses: snapcore/action-build@v1 + # id: snapcraft + + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.ARTIFACT_AMD64 }} + # path: ${{ steps.snapcraft.outputs.snap }} + # if-no-files-found: error From 2550cd0b17eceaf22fbfc65fb6ded430674a58f4 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 30 Sep 2024 09:58:09 +0200 Subject: [PATCH 08/14] Test matrix --- .github/workflows/snap-ci.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml index 3028d6f..954e1db 100644 --- a/.github/workflows/snap-ci.yaml +++ b/.github/workflows/snap-ci.yaml @@ -15,13 +15,11 @@ env: ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64 jobs: - build_matrix: + matrix-build: strategy: matrix: runner: ["ubuntu-latest", [self-hosted, ARM64, Linux]] runs-on: ${{ matrix.runner }} - env: - RUNNER: ${{ matrix.runner }} # outputs: # snap: ${{ steps.snapcraft.outputs.snap }} @@ -31,8 +29,9 @@ jobs: uses: actions/checkout@v4 - name: Debug print - run: | - echo "Running on $RUNNER" + env: + RUNNER_CONTEXT: ${{ toJson(runner) }} + run: echo "$RUNNER_CONTEXT" # - name: Build snap # uses: snapcore/action-build@v1 @@ -44,3 +43,10 @@ jobs: # name: ${{ env.ARTIFACT_AMD64 }} # path: ${{ steps.snapcraft.outputs.snap }} # if-no-files-found: error + + promote: + needs: [matrix-build] + runs-on: ubuntu-latest + steps: + - name: Promote + run: echo "Promoting" From 3c211652356f3fe5e1dab99ae42cdb1289a793b0 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 30 Sep 2024 10:16:57 +0200 Subject: [PATCH 09/14] Add build, test, promote --- .github/workflows/snap-ci.yaml | 88 +++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml index 954e1db..0bc2341 100644 --- a/.github/workflows/snap-ci.yaml +++ b/.github/workflows/snap-ci.yaml @@ -3,50 +3,84 @@ name: Snap CI on: # schedule: # - cron: "20 2 * * 1" # Monday morning 02:20 UTC - push: +# push: # branches: [main] - pull_request: +# pull_request: # branches: [main] # Allow manual trigger workflow_dispatch: -env: - ARTIFACT_AMD64: chip-tool_${{ github.run_number}}_amd64 - ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64 - jobs: matrix-build: strategy: matrix: - runner: ["ubuntu-latest", [self-hosted, ARM64, Linux]] - runs-on: ${{ matrix.runner }} - - # outputs: - # snap: ${{ steps.snapcraft.outputs.snap }} + runs: + - architecture: amd64 + runner: ubuntu-latest + - architecture: arm64 + runner: [self-hosted, ARM64, Linux] + runs-on: ${{ matrix.runs.runner }} steps: - name: Checkout code uses: actions/checkout@v4 - - name: Debug print + - name: Build snap + uses: snapcore/action-build@v1 + id: snapcraft + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: chip-tool_${{ github.run_number}}_${{matrix.runs.architecture}} + path: ${{ steps.snapcraft.outputs.snap }} + if-no-files-found: error + + - uses: snapcore/action-publish@v1 + # if: github.ref == 'refs/heads/main' env: - RUNNER_CONTEXT: ${{ toJson(runner) }} - run: echo "$RUNNER_CONTEXT" + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + with: + snap: ${{ steps.snapcraft.outputs.snap }} + release: latest/edge/test - # - name: Build snap - # uses: snapcore/action-build@v1 - # id: snapcraft + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.*" + cache: false - # - name: Upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.ARTIFACT_AMD64 }} - # path: ${{ steps.snapcraft.outputs.snap }} - # if-no-files-found: error + - name: Run tests + shell: bash + working-directory: tests + env: + SKIP_TEARDOWN_REMOVAL: true + LOCAL_SERVICE_SNAP: ../${{ steps.snapcraft.outputs.snap }} + run: | + go test -failfast -p 1 -timeout 30m -v - promote: - needs: [matrix-build] + - name: Upload snap logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs + path: tests/logs/*.log + + promote-beta: + # Only promote if we are on the main branch + # if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest + needs: [matrix-build] steps: - - name: Promote - run: echo "Promoting" + - name: Install Snapcraft + run: | + sudo snap install snapcraft --classic + echo /snap/bin >> $GITHUB_PATH + shell: bash + + - name: Promote Snap + env: # Workaround for https://github.com/snapcore/snapcraft/issues/4439 + SNAPCRAFT_HAS_TTY: "true" + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + run: | + yes | snapcraft promote chip-tool --from-channel latest/edge/test --to-channel latest/beta/test From 6083d14b586fac23e3b32e930ab03461e9fc5786 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 30 Sep 2024 10:19:46 +0200 Subject: [PATCH 10/14] Enable push and pr runs --- .github/workflows/snap-ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml index 0bc2341..bf6a098 100644 --- a/.github/workflows/snap-ci.yaml +++ b/.github/workflows/snap-ci.yaml @@ -3,9 +3,9 @@ name: Snap CI on: # schedule: # - cron: "20 2 * * 1" # Monday morning 02:20 UTC -# push: + push: # branches: [main] -# pull_request: + pull_request: # branches: [main] # Allow manual trigger workflow_dispatch: From 02e0d3cd41ec902da903411950448a5fee8b7400 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 30 Sep 2024 13:23:59 +0200 Subject: [PATCH 11/14] Add architecture to log artifact name --- .github/workflows/snap-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml index bf6a098..a0c6495 100644 --- a/.github/workflows/snap-ci.yaml +++ b/.github/workflows/snap-ci.yaml @@ -63,7 +63,7 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: logs + name: logs_${{matrix.runs.architecture}} path: tests/logs/*.log promote-beta: From 96ca3986d47974bfdd4d979385d187815bc215fe Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 30 Sep 2024 14:42:38 +0200 Subject: [PATCH 12/14] Remove old workflows, make ci ready for production --- .github/workflows/build-amd64.yml | 106 ------------------------------ .github/workflows/build-arm64.yml | 106 ------------------------------ .github/workflows/snap-ci.yaml | 18 ++--- 3 files changed, 9 insertions(+), 221 deletions(-) delete mode 100644 .github/workflows/build-amd64.yml delete mode 100644 .github/workflows/build-arm64.yml diff --git a/.github/workflows/build-amd64.yml b/.github/workflows/build-amd64.yml deleted file mode 100644 index be3b5ea..0000000 --- a/.github/workflows/build-amd64.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Snap CI AMD64 - -on: - # schedule: - # - cron: "20 2 * * 1" # Monday morning 02:20 UTC - # push: - # branches: [main] - # pull_request: - # branches: [main] - # Allow manual trigger - workflow_dispatch: - -env: - ARTIFACT_AMD64: chip-tool_${{ github.run_number}}_amd64 - -jobs: - build: - outputs: - snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build snap - uses: snapcore/action-build@v1 - id: snapcraft - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.ARTIFACT_AMD64 }} - path: ${{ steps.snapcraft.outputs.snap }} - if-no-files-found: error - - publish-edge: - # Only publish if we are on the main branch - # if: github.ref == 'refs/heads/main' - needs: [build] - runs-on: ubuntu-latest - steps: - - name: Download locally built snap - uses: actions/download-artifact@v4 - with: - name: ${{ env.ARTIFACT_AMD64 }} - - - uses: snapcore/action-publish@v1 - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - with: - snap: ${{ needs.build.outputs.snap }} - release: latest/edge/test - - test: - needs: build - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download locally built snap - uses: actions/download-artifact@v4 - with: - name: ${{ env.ARTIFACT_AMD64 }} - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: "1.*" - cache: false - - - name: Run tests - shell: bash - working-directory: tests - env: - SKIP_TEARDOWN_REMOVAL: true - LOCAL_SERVICE_SNAP: ../${{ needs.build.outputs.snap }} - run: | - go test -failfast -p 1 -timeout 30m -v - - - name: Upload snap logs - if: always() - uses: actions/upload-artifact@v4 - with: - name: logs - path: tests/logs/*.log - - promote-beta: - # Only promote if we are on the main branch - # if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - needs: [test, publish-edge] - steps: - - name: Install Snapcraft - # Install snapcraft and add it to PATH - run: | - sudo snap install snapcraft --classic - echo /snap/bin >> $GITHUB_PATH - shell: bash - - - name: Promote Snap - env: # Workaround for https://github.com/snapcore/snapcraft/issues/4439 - SNAPCRAFT_HAS_TTY: "true" - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - run: | - yes | snapcraft promote chip-tool --from-channel latest/edge/test --to-channel latest/beta/test diff --git a/.github/workflows/build-arm64.yml b/.github/workflows/build-arm64.yml deleted file mode 100644 index 14ac540..0000000 --- a/.github/workflows/build-arm64.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Snap CI ARM64 - -on: - # schedule: - # - cron: "20 2 * * 1" # Monday morning 02:20 UTC - # push: - # branches: [main] - # pull_request: - # branches: [main] - # Allow manual trigger - workflow_dispatch: - -env: - ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64 - -jobs: - build: - outputs: - snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: [self-hosted, ARM64, Linux] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build Snap - uses: snapcore/action-build@v1 - id: snapcraft - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.ARTIFACT_ARM64 }} - path: ${{ steps.snapcraft.outputs.snap }} - if-no-files-found: error - - publish-edge: - # Only publish if we are on the main branch - # if: github.ref == 'refs/heads/main' - needs: [build] - runs-on: [self-hosted, ARM64, Linux] - steps: - - name: Download locally built snap - uses: actions/download-artifact@v4 - with: - name: ${{ env.ARTIFACT_ARM64 }} - - - uses: snapcore/action-publish@v1 - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - with: - snap: ${{ needs.build.outputs.snap }} - release: latest/edge/test - - test: - needs: build - runs-on: [self-hosted, ARM64, Linux] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download locally built snap - uses: actions/download-artifact@v4 - with: - name: ${{ env.ARTIFACT_ARM64 }} - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: "1.*" - cache: false - - - name: Run tests - shell: bash - working-directory: tests - env: - SKIP_TEARDOWN_REMOVAL: true - LOCAL_SERVICE_SNAP: ../${{ needs.build.outputs.snap }} - run: | - go test -failfast -p 1 -timeout 30m -v - - - name: Upload snap logs - if: always() - uses: actions/upload-artifact@v4 - with: - name: logs - path: tests/logs/*.log - - promote-beta: - # Only promote if we are on the main branch - # if: github.ref == 'refs/heads/main' - runs-on: [self-hosted, ARM64, Linux] - needs: [test, publish-edge] - steps: - - name: Install Snapcraft - # Install snapcraft and add it to PATH - run: | - sudo snap install snapcraft --classic - echo /snap/bin >> $GITHUB_PATH - shell: bash - - - name: Promote Snap - env: # Workaround for https://github.com/snapcore/snapcraft/issues/4439 - SNAPCRAFT_HAS_TTY: "true" - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - run: | - yes | snapcraft promote chip-tool --from-channel latest/edge/test --to-channel latest/beta/test diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml index a0c6495..ed19e89 100644 --- a/.github/workflows/snap-ci.yaml +++ b/.github/workflows/snap-ci.yaml @@ -1,12 +1,12 @@ name: Snap CI on: - # schedule: - # - cron: "20 2 * * 1" # Monday morning 02:20 UTC + schedule: + - cron: "20 2 * * 1" # Monday mornings 02:20 UTC push: - # branches: [main] + branches: [main] pull_request: - # branches: [main] + branches: [main] # Allow manual trigger workflow_dispatch: @@ -37,12 +37,12 @@ jobs: if-no-files-found: error - uses: snapcore/action-publish@v1 - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} with: snap: ${{ steps.snapcraft.outputs.snap }} - release: latest/edge/test + release: latest/edge - name: Setup Go uses: actions/setup-go@v5 @@ -63,12 +63,12 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: logs_${{matrix.runs.architecture}} + name: logs_${{ github.run_number}}_${{matrix.runs.architecture}} path: tests/logs/*.log promote-beta: # Only promote if we are on the main branch - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: [matrix-build] steps: @@ -83,4 +83,4 @@ jobs: SNAPCRAFT_HAS_TTY: "true" SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} run: | - yes | snapcraft promote chip-tool --from-channel latest/edge/test --to-channel latest/beta/test + yes | snapcraft promote chip-tool --from-channel latest/edge --to-channel latest/beta From 865cade06aa61fdebc3f064e2476b45af675ebc3 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Mon, 30 Sep 2024 16:58:31 +0200 Subject: [PATCH 13/14] Pull snap name out into a global variable --- .github/workflows/snap-ci.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml index ed19e89..0e73110 100644 --- a/.github/workflows/snap-ci.yaml +++ b/.github/workflows/snap-ci.yaml @@ -10,6 +10,9 @@ on: # Allow manual trigger workflow_dispatch: +env: + SNAP_NAME: chip-tool + jobs: matrix-build: strategy: @@ -32,7 +35,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: chip-tool_${{ github.run_number}}_${{matrix.runs.architecture}} + name: ${{env.SNAP_NAME}}_${{github.run_number}}_${{matrix.runs.architecture}} path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error @@ -83,4 +86,4 @@ jobs: SNAPCRAFT_HAS_TTY: "true" SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} run: | - yes | snapcraft promote chip-tool --from-channel latest/edge --to-channel latest/beta + yes | snapcraft promote $SNAP_NAME --from-channel latest/edge --to-channel latest/beta From 2432e9c072241a25ab67d8661c18476486a8d762 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 4 Oct 2024 12:27:42 +0200 Subject: [PATCH 14/14] Add suggestions from review --- .github/workflows/snap-ci.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/snap-ci.yaml b/.github/workflows/snap-ci.yaml index 0e73110..0febcf1 100644 --- a/.github/workflows/snap-ci.yaml +++ b/.github/workflows/snap-ci.yaml @@ -14,7 +14,8 @@ env: SNAP_NAME: chip-tool jobs: - matrix-build: + build: + name: Build, Test, Publish strategy: matrix: runs: @@ -39,7 +40,8 @@ jobs: path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error - - uses: snapcore/action-publish@v1 + - name: Publish snap to edge + uses: snapcore/action-publish@v1 if: github.ref == 'refs/heads/main' env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} @@ -57,8 +59,8 @@ jobs: shell: bash working-directory: tests env: - SKIP_TEARDOWN_REMOVAL: true - LOCAL_SERVICE_SNAP: ../${{ steps.snapcraft.outputs.snap }} + TEARDOWN: false + SNAP_PATH: ../${{ steps.snapcraft.outputs.snap }} run: | go test -failfast -p 1 -timeout 30m -v @@ -70,10 +72,11 @@ jobs: path: tests/logs/*.log promote-beta: + name: Promote to Beta # Only promote if we are on the main branch if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest - needs: [matrix-build] + needs: [build] steps: - name: Install Snapcraft run: |