From f0a8176fa572e7fc407a67fb00d4f58bebb75e5c Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Tue, 4 Jun 2024 17:35:24 +0200 Subject: [PATCH 01/32] Add publish snap Comment out test and arm64 for now --- .github/workflows/build-and-test-snap.yml | 114 ++++++++++++---------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 89e7599..4cb119b 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -32,62 +32,78 @@ jobs: path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error - test: - needs: build - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - lfs: true + # 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: - name: ${{ env.SNAP_AMD64 }} + # - name: Download locally built snap + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.SNAP_AMD64 }} - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.*' - cache: false + # - 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: ../chip-tool_*.snap - run: | - go test -failfast -p 1 -timeout 30m -v + # - name: Run tests + # shell: bash + # working-directory: tests + # env: + # SKIP_TEARDOWN_REMOVAL: true + # LOCAL_SERVICE_SNAP: ../chip-tool_*.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/*.log + # - name: Upload snap logs + # if: always() + # uses: actions/upload-artifact@v4 + # with: + # name: logs + # path: tests/*.log - build-arm64: - needs: test - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + # build-arm64: + # needs: test + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: arm64 + # - name: Setup QEMU + # uses: docker/setup-qemu-action@v3 + # with: + # platforms: arm64 - - name: Build snap - uses: diddlesnaps/snapcraft-multiarch-action@v1 - id: build + # - name: Build snap + # uses: diddlesnaps/snapcraft-multiarch-action@v1 + # id: build + # with: + # architecture: arm64 + + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.SNAP_ARM64 }} + # path: ${{ steps.build.outputs.snap }} + + publish-snap: + needs: build + runs-on: ubuntu-latest + steps: + + - name: Download locally built snap + uses: actions/download-artifact@v4 with: - architecture: arm64 + name: ${{ env.SNAP_AMD64 }} - - name: Upload artifact - uses: actions/upload-artifact@v4 + - uses: snapcore/action-publish@v1 with: - name: ${{ env.SNAP_ARM64 }} - path: ${{ steps.build.outputs.snap }} + store_login: ${{ secrets.STORE_LOGIN }} + snap: ${{ env.SNAP_AMD64 }} + release: edge/ieng-1057 \ No newline at end of file From f27d6905ca5774a83f99226aabec5df51eaff912 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 08:49:31 +0200 Subject: [PATCH 02/32] Debug asset file name --- .github/workflows/build-and-test-snap.yml | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 4cb119b..b9733cf 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -13,24 +13,24 @@ env: SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap jobs: - build: - outputs: - snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + # 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: Build snap + # uses: snapcore/action-build@v1 + # id: snapcraft - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.SNAP_AMD64 }} - path: ${{ steps.snapcraft.outputs.snap }} - if-no-files-found: error + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.SNAP_AMD64 }} + # path: ${{ steps.snapcraft.outputs.snap }} + # if-no-files-found: error # test: # needs: build @@ -102,6 +102,9 @@ jobs: with: name: ${{ env.SNAP_AMD64 }} + - name: list + run: ls -lah + - uses: snapcore/action-publish@v1 with: store_login: ${{ secrets.STORE_LOGIN }} From f64e66a0a9737bac4b717db496a2366af1c8c853 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 08:50:48 +0200 Subject: [PATCH 03/32] Remove dependency on other jobs --- .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 b9733cf..0b6db3e 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -93,7 +93,7 @@ jobs: # path: ${{ steps.build.outputs.snap }} publish-snap: - needs: build + # needs: build runs-on: ubuntu-latest steps: From b7c76cf92ffe4ad895d754d7805cfaa45102d24a Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 08:52:01 +0200 Subject: [PATCH 04/32] Add build back --- .github/workflows/build-and-test-snap.yml | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 0b6db3e..d4cb1fd 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -13,24 +13,24 @@ env: SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap jobs: - # build: - # outputs: - # snap: ${{ steps.snapcraft.outputs.snap }} - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 + 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: Build snap + uses: snapcore/action-build@v1 + id: snapcraft - # - name: Upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.SNAP_AMD64 }} - # path: ${{ steps.snapcraft.outputs.snap }} - # if-no-files-found: error + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.SNAP_AMD64 }} + path: ${{ steps.snapcraft.outputs.snap }} + if-no-files-found: error # test: # needs: build From 0757036b470dafe0cf80e2e53dd6266585f16974 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 08:52:54 +0200 Subject: [PATCH 05/32] Add back dependency --- .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 d4cb1fd..c99d74f 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -93,7 +93,7 @@ jobs: # path: ${{ steps.build.outputs.snap }} publish-snap: - # needs: build + needs: build runs-on: ubuntu-latest steps: From 9f00fc1323113989cb56c2a5e6083e06831277c5 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 09:05:40 +0200 Subject: [PATCH 06/32] Hardcoded artifact name --- .github/workflows/build-and-test-snap.yml | 37 ++++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index c99d74f..bff35a5 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -13,24 +13,24 @@ env: SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap jobs: - build: - outputs: - snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + # 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: Build snap + # uses: snapcore/action-build@v1 + # id: snapcraft - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.SNAP_AMD64 }} - path: ${{ steps.snapcraft.outputs.snap }} - if-no-files-found: error + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.SNAP_AMD64 }} + # path: ${{ steps.snapcraft.outputs.snap }} + # if-no-files-found: error # test: # needs: build @@ -93,14 +93,15 @@ jobs: # path: ${{ steps.build.outputs.snap }} publish-snap: - needs: build + # needs: build runs-on: ubuntu-latest steps: - name: Download locally built snap uses: actions/download-artifact@v4 with: - name: ${{ env.SNAP_AMD64 }} + # name: ${{ env.SNAP_AMD64 }} + name: chip-tool_77_amd64.snap - name: list run: ls -lah From 1563b0996387c56f0d5098deaafd02d7842e144e Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 09:07:01 +0200 Subject: [PATCH 07/32] Try upload to store with wildcard name --- .github/workflows/build-and-test-snap.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index bff35a5..0fdc420 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -109,5 +109,6 @@ jobs: - uses: snapcore/action-publish@v1 with: store_login: ${{ secrets.STORE_LOGIN }} - snap: ${{ env.SNAP_AMD64 }} + # snap: ${{ env.SNAP_AMD64 }} + snap: chip-tool_*_amd64.snap release: edge/ieng-1057 \ No newline at end of file From 74f8296b0af82df6d722c6f58dd40a6b37ae07d0 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 09:11:56 +0200 Subject: [PATCH 08/32] Build and upload with wildcard --- .github/workflows/build-and-test-snap.yml | 37 +++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 0fdc420..ae13a2d 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -13,24 +13,24 @@ env: SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap jobs: - # build: - # outputs: - # snap: ${{ steps.snapcraft.outputs.snap }} - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 + 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: Build snap + uses: snapcore/action-build@v1 + id: snapcraft - # - name: Upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.SNAP_AMD64 }} - # path: ${{ steps.snapcraft.outputs.snap }} - # if-no-files-found: error + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.SNAP_AMD64 }} + path: ${{ steps.snapcraft.outputs.snap }} + if-no-files-found: error # test: # needs: build @@ -93,15 +93,14 @@ jobs: # path: ${{ steps.build.outputs.snap }} publish-snap: - # needs: build + needs: build runs-on: ubuntu-latest steps: - name: Download locally built snap uses: actions/download-artifact@v4 with: - # name: ${{ env.SNAP_AMD64 }} - name: chip-tool_77_amd64.snap + name: ${{ env.SNAP_AMD64 }} - name: list run: ls -lah From 8153baf349bfc2e77f81ee2924ad2f00222845ee Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 09:42:03 +0200 Subject: [PATCH 09/32] Do a fake build to speed up Do an ls to get real artifact file name --- .github/workflows/build-and-test-snap.yml | 32 ++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index ae13a2d..ddb72ac 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -13,23 +13,41 @@ env: SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap 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.SNAP_AMD64 }} + # path: ${{ steps.snapcraft.outputs.snap }} + # if-no-files-found: error + build: - outputs: - snap: ${{ steps.snapcraft.outputs.snap }} + # fake build runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Build snap - uses: snapcore/action-build@v1 + run: echo "test" > chip-tool_00509948+snap_amd64.snap id: snapcraft - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ env.SNAP_AMD64 }} - path: ${{ steps.snapcraft.outputs.snap }} + path: chip-tool_00509948+snap_amd64.snap if-no-files-found: error # test: @@ -103,11 +121,13 @@ jobs: name: ${{ env.SNAP_AMD64 }} - name: list - run: ls -lah + run: | + FILE_NAME=$(ls chip-tool_*+snap_amd64.snap | head -n 1) + echo "artifact_file_name=$FILE_NAME" >> "$GITHUB_ENV" - uses: snapcore/action-publish@v1 with: store_login: ${{ secrets.STORE_LOGIN }} # snap: ${{ env.SNAP_AMD64 }} - snap: chip-tool_*_amd64.snap + snap: $artifact_file_name release: edge/ieng-1057 \ No newline at end of file From 39a7652c94c02bb013ac5cfe1edd05252d77fc8c Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 09:50:33 +0200 Subject: [PATCH 10/32] Use output variable from build step --- .github/workflows/build-and-test-snap.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index ddb72ac..4d26619 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -34,13 +34,17 @@ jobs: build: # fake build + outputs: + snap: ${{ steps.snapcraft.outputs.snap }} runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Build snap - run: echo "test" > chip-tool_00509948+snap_amd64.snap + run: | + echo "test" > chip-tool_00509948+snap_amd64.snap + echo "snap=chip-tool_00509948+snap_amd64.snap" >> "$GITHUB_ENV" id: snapcraft - name: Upload artifact @@ -120,14 +124,15 @@ jobs: with: name: ${{ env.SNAP_AMD64 }} - - name: list - run: | - FILE_NAME=$(ls chip-tool_*+snap_amd64.snap | head -n 1) - echo "artifact_file_name=$FILE_NAME" >> "$GITHUB_ENV" + # - name: list + # id: get-file-name + # run: | + # FILE_NAME=$(ls chip-tool_*+snap_amd64.snap | head -n 1) + # echo "ARTIFACT_FILE_NAME=$FILE_NAME" >> "$GITHUB_ENV" - uses: snapcore/action-publish@v1 with: store_login: ${{ secrets.STORE_LOGIN }} # snap: ${{ env.SNAP_AMD64 }} - snap: $artifact_file_name + snap: ${{ needs.build.outputs.snap }} release: edge/ieng-1057 \ No newline at end of file From 5b11e9d156619fb15c0ccfc550f21980311af890 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 09:56:46 +0200 Subject: [PATCH 11/32] Write variable to outputs file --- .github/workflows/build-and-test-snap.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 4d26619..c91f7eb 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -44,14 +44,14 @@ jobs: - name: Build snap run: | echo "test" > chip-tool_00509948+snap_amd64.snap - echo "snap=chip-tool_00509948+snap_amd64.snap" >> "$GITHUB_ENV" + echo "snap=chip-tool_00509948+snap_amd64.snap" >> "$GITHUB_OUTPUT" id: snapcraft - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ env.SNAP_AMD64 }} - path: chip-tool_00509948+snap_amd64.snap + path: steps.snapcraft.outputs.snap if-no-files-found: error # test: From 00d37b06077f42b6e60c654c626818e11e8f9ad0 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 09:58:27 +0200 Subject: [PATCH 12/32] Correct use of variable --- .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 c91f7eb..d990b1e 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -51,7 +51,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ env.SNAP_AMD64 }} - path: steps.snapcraft.outputs.snap + path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error # test: From 2bd20e72955f3fec3eb3cdcfb2ccfc6732beabb2 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 10:01:37 +0200 Subject: [PATCH 13/32] Use git hash in snap version --- snap/snapcraft.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 27d810d..39000ed 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -28,7 +28,8 @@ parts: scripts/checkout_submodules.py --shallow --platform linux # set the snap version - craftctl set version=$TAG+snap + GIT_HASH=$(git rev-parse --short HEAD) + craftctl set version=$GIT_HASH+snap chip-tool: after: [connectedhomeip] From a577164396ae1c027c224058f6294c1644edf66d Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 10:01:52 +0200 Subject: [PATCH 14/32] Re-enable real build --- .github/workflows/build-and-test-snap.yml | 55 ++++++++++------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index d990b1e..e053f78 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -13,27 +13,7 @@ env: SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap 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.SNAP_AMD64 }} - # path: ${{ steps.snapcraft.outputs.snap }} - # if-no-files-found: error - build: - # fake build outputs: snap: ${{ steps.snapcraft.outputs.snap }} runs-on: ubuntu-latest @@ -42,9 +22,7 @@ jobs: uses: actions/checkout@v4 - name: Build snap - run: | - echo "test" > chip-tool_00509948+snap_amd64.snap - echo "snap=chip-tool_00509948+snap_amd64.snap" >> "$GITHUB_OUTPUT" + uses: snapcore/action-build@v1 id: snapcraft - name: Upload artifact @@ -53,6 +31,28 @@ jobs: name: ${{ env.SNAP_AMD64 }} path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error + + # build: + # # fake build + # outputs: + # snap: ${{ steps.snapcraft.outputs.snap }} + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + + # - name: Build snap + # run: | + # echo "test" > chip-tool_00509948+snap_amd64.snap + # echo "snap=chip-tool_00509948+snap_amd64.snap" >> "$GITHUB_OUTPUT" + # id: snapcraft + + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.SNAP_AMD64 }} + # path: ${{ steps.snapcraft.outputs.snap }} + # if-no-files-found: error # test: # needs: build @@ -124,15 +124,8 @@ jobs: with: name: ${{ env.SNAP_AMD64 }} - # - name: list - # id: get-file-name - # run: | - # FILE_NAME=$(ls chip-tool_*+snap_amd64.snap | head -n 1) - # echo "ARTIFACT_FILE_NAME=$FILE_NAME" >> "$GITHUB_ENV" - - uses: snapcore/action-publish@v1 with: store_login: ${{ secrets.STORE_LOGIN }} - # snap: ${{ env.SNAP_AMD64 }} snap: ${{ needs.build.outputs.snap }} - release: edge/ieng-1057 \ No newline at end of file + release: edge/ieng-1057 From 6720055fdf197e09a4fcef9591a1408677f2038e Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 10:21:38 +0200 Subject: [PATCH 15/32] Check file before upload --- .github/workflows/build-and-test-snap.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index e053f78..a22fbbe 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -124,6 +124,14 @@ jobs: with: name: ${{ env.SNAP_AMD64 }} + - name: Check file + env: + FILENAME: ${{needs.build.outputs.snap}} + run: | + echo "Looking for $FILENAME" + ls -lah + cat $FILENAME + - uses: snapcore/action-publish@v1 with: store_login: ${{ secrets.STORE_LOGIN }} From 3a543ac8e4c23f96d088ff2d7b8c44cac1c405bf Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 11:23:43 +0200 Subject: [PATCH 16/32] Update snap publish action to use env var for secret --- .github/workflows/build-and-test-snap.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index a22fbbe..0b02666 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -133,7 +133,8 @@ jobs: cat $FILENAME - uses: snapcore/action-publish@v1 + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} with: - store_login: ${{ secrets.STORE_LOGIN }} snap: ${{ needs.build.outputs.snap }} release: edge/ieng-1057 From 0989a8c96b8dcfab9fb31b29cfb470013a250579 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 12:38:30 +0200 Subject: [PATCH 17/32] Clean up workflow --- .github/workflows/build-and-test-snap.yml | 135 +++++++++------------- 1 file changed, 52 insertions(+), 83 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 0b02666..6ce191a 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -31,107 +31,76 @@ jobs: name: ${{ env.SNAP_AMD64 }} path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error - - # build: - # # fake build - # outputs: - # snap: ${{ steps.snapcraft.outputs.snap }} - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - - # - name: Build snap - # run: | - # echo "test" > chip-tool_00509948+snap_amd64.snap - # echo "snap=chip-tool_00509948+snap_amd64.snap" >> "$GITHUB_OUTPUT" - # id: snapcraft - - # - name: Upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.SNAP_AMD64 }} - # path: ${{ steps.snapcraft.outputs.snap }} - # if-no-files-found: error - # test: - # needs: build - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # with: - # lfs: true + 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: - # name: ${{ env.SNAP_AMD64 }} + - name: Download locally built snap + uses: actions/download-artifact@v4 + with: + name: ${{ env.SNAP_AMD64 }} - # - name: Setup Go - # uses: actions/setup-go@v5 - # with: - # go-version: '1.*' - # cache: false + - 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: ../chip-tool_*.snap - # run: | - # go test -failfast -p 1 -timeout 30m -v + - name: Run tests + shell: bash + working-directory: tests + env: + SKIP_TEARDOWN_REMOVAL: true + LOCAL_SERVICE_SNAP: ../chip-tool_*.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/*.log + - name: Upload snap logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs + path: tests/*.log - # build-arm64: - # needs: test - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 + build-arm64: + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - # - name: Setup QEMU - # uses: docker/setup-qemu-action@v3 - # with: - # platforms: arm64 + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 - # - name: Build snap - # uses: diddlesnaps/snapcraft-multiarch-action@v1 - # id: build - # with: - # architecture: arm64 + - name: Build snap + uses: diddlesnaps/snapcraft-multiarch-action@v1 + id: build + with: + architecture: arm64 - # - name: Upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.SNAP_ARM64 }} - # path: ${{ steps.build.outputs.snap }} + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.SNAP_ARM64 }} + path: ${{ steps.build.outputs.snap }} publish-snap: - needs: build + needs: test runs-on: ubuntu-latest steps: - - name: Download locally built snap uses: actions/download-artifact@v4 with: name: ${{ env.SNAP_AMD64 }} - - name: Check file - env: - FILENAME: ${{needs.build.outputs.snap}} - run: | - echo "Looking for $FILENAME" - ls -lah - cat $FILENAME - - uses: snapcore/action-publish@v1 env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} From 201aed240fb9a8f1bee9a444c811efd4ddf62f03 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 13:31:56 +0200 Subject: [PATCH 18/32] Snap version use upstream tag or fall back to commit hash --- snap/snapcraft.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 39000ed..04d2079 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -23,13 +23,13 @@ parts: build-environment: - TAG: master override-pull: | - # shallow clone the project its submodules + # shallow clone the project and its submodules git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$TAG . scripts/checkout_submodules.py --shallow --platform linux - # set the snap version - GIT_HASH=$(git rev-parse --short HEAD) - craftctl set version=$GIT_HASH+snap + # set the snap version to the upstream tag, or fall back to the commit hash + UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) + craftctl set version=$UPSTREAM_VERSION chip-tool: after: [connectedhomeip] From 45cd3cd3b009467fdf2519cf946bb041b5c85719 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 13:32:21 +0200 Subject: [PATCH 19/32] Remove arm64 for now to test --- .github/workflows/build-and-test-snap.yml | 76 ++++++++++++++--------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 6ce191a..479319b 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -13,7 +13,7 @@ env: SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap jobs: - build: + build-amd64: outputs: snap: ${{ steps.snapcraft.outputs.snap }} runs-on: ubuntu-latest @@ -32,8 +32,8 @@ jobs: path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error - test: - needs: build + test-amd64: + needs: build-amd64 runs-on: ubuntu-latest steps: - name: Checkout code @@ -68,32 +68,8 @@ jobs: name: logs path: tests/*.log - build-arm64: - needs: test - runs-on: ubuntu-latest - 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 - id: build - with: - architecture: arm64 - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.SNAP_ARM64 }} - path: ${{ steps.build.outputs.snap }} - - publish-snap: - needs: test + publish-amd64: + needs: [build-amd64, test-amd64] runs-on: ubuntu-latest steps: - name: Download locally built snap @@ -105,5 +81,45 @@ jobs: env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} with: - snap: ${{ needs.build.outputs.snap }} + snap: ${{ needs.build-amd64.outputs.snap }} release: edge/ieng-1057 + + # build-arm64: + # needs: test-amd64 + # runs-on: ubuntu-latest + # 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 + # id: build + # with: + # architecture: arm64 + + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.SNAP_ARM64 }} + # path: ${{ steps.build.outputs.snap }} + + # publish-arm64: + # needs: [build-arm64] + # runs-on: ubuntu-latest + # steps: + # - name: Download locally built snap + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.SNAP_AMD64 }} + + # - uses: snapcore/action-publish@v1 + # env: + # SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + # with: + # snap: ${{ needs.build-arm64.outputs.snap }} + # release: edge/ieng-1057 From f67c8312407e60d5b83b4c9098c75ae5ec5264a0 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 14:28:56 +0200 Subject: [PATCH 20/32] Update version logic --- snap/snapcraft.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 04d2079..95d0836 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -27,10 +27,11 @@ parts: git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$TAG . scripts/checkout_submodules.py --shallow --platform linux - # set the snap version to the upstream tag, or fall back to the commit hash - UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) + # set the snap version to the upstream tag, or fall back to the commit count and hash + GIT_COUNT_HASH=git$(git rev-list --count --all).$(git rev-parse --short HEAD) + UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || $GIT_COUNT_HASH) craftctl set version=$UPSTREAM_VERSION - + chip-tool: after: [connectedhomeip] plugin: nil From 1df7696caeeb8a285e09c3df998c67b323d254bd Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 15:22:19 +0200 Subject: [PATCH 21/32] Rework snap version --- snap/snapcraft.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 95d0836..f391099 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -21,16 +21,16 @@ parts: connectedhomeip: plugin: nil build-environment: - - TAG: master + - UPSTREAM_TAG: master + - PACKAGE_VERSION: snap override-pull: | # shallow clone the project and its submodules - git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$TAG . + git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$UPSTREAM_TAG . scripts/checkout_submodules.py --shallow --platform linux - # set the snap version to the upstream tag, or fall back to the commit count and hash - GIT_COUNT_HASH=git$(git rev-list --count --all).$(git rev-parse --short HEAD) - UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || $GIT_COUNT_HASH) - craftctl set version=$UPSTREAM_VERSION + # prefix the snap version with the upstream tag, or fall back to the commit hash + UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || $(git rev-parse --short HEAD)) + craftctl set version=$UPSTREAM_VERSION+$PACKAGE_VERSION chip-tool: after: [connectedhomeip] From f79266674ff341d4e7e70cb384100dfefe4dffb1 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 15:24:03 +0200 Subject: [PATCH 22/32] Run workflow on self-hosted and enable arm64 --- .github/workflows/build-and-test-snap.yml | 84 +++++++++++------------ 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 479319b..403f2b3 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -16,7 +16,7 @@ jobs: build-amd64: outputs: snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: ubuntu-latest + runs-on: [self-hosted, linux, x64] steps: - name: Checkout code uses: actions/checkout@v4 @@ -34,7 +34,7 @@ jobs: test-amd64: needs: build-amd64 - runs-on: ubuntu-latest + runs-on: [self-hosted, linux, x64] steps: - name: Checkout code uses: actions/checkout@v4 @@ -70,7 +70,7 @@ jobs: publish-amd64: needs: [build-amd64, test-amd64] - runs-on: ubuntu-latest + runs-on: [self-hosted, linux, x64] steps: - name: Download locally built snap uses: actions/download-artifact@v4 @@ -84,42 +84,42 @@ jobs: snap: ${{ needs.build-amd64.outputs.snap }} release: edge/ieng-1057 - # build-arm64: - # needs: test-amd64 - # runs-on: ubuntu-latest - # 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 - # id: build - # with: - # architecture: arm64 - - # - name: Upload artifact - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.SNAP_ARM64 }} - # path: ${{ steps.build.outputs.snap }} - - # publish-arm64: - # needs: [build-arm64] - # runs-on: ubuntu-latest - # steps: - # - name: Download locally built snap - # uses: actions/download-artifact@v4 - # with: - # name: ${{ env.SNAP_AMD64 }} - - # - uses: snapcore/action-publish@v1 - # env: - # SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} - # with: - # snap: ${{ needs.build-arm64.outputs.snap }} - # release: edge/ieng-1057 + build-arm64: + needs: test-amd64 + runs-on: [self-hosted, linux, x64] + 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 + id: build + with: + architecture: arm64 + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.SNAP_ARM64 }} + path: ${{ steps.build.outputs.snap }} + + publish-arm64: + needs: [build-arm64] + runs-on: [self-hosted, linux, x64] + steps: + - name: Download locally built snap + uses: actions/download-artifact@v4 + with: + name: ${{ env.SNAP_AMD64 }} + + - uses: snapcore/action-publish@v1 + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} + with: + snap: ${{ needs.build-arm64.outputs.snap }} + release: edge/ieng-1057 From e6873618aa78227832bd49ca9dd6ca8ebaf265a0 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 15:41:42 +0200 Subject: [PATCH 23/32] Fix git version command --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index f391099..1ce43a9 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -29,7 +29,7 @@ parts: scripts/checkout_submodules.py --shallow --platform linux # prefix the snap version with the upstream tag, or fall back to the commit hash - UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || $(git rev-parse --short HEAD)) + UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) craftctl set version=$UPSTREAM_VERSION+$PACKAGE_VERSION chip-tool: From 65cb1c82d3fb110f1210ea7778b9ce2e84665363 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 16:00:05 +0200 Subject: [PATCH 24/32] Move back to github hosted runners --- .github/workflows/build-and-test-snap.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 403f2b3..fe45bb4 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -16,7 +16,7 @@ jobs: build-amd64: outputs: snap: ${{ steps.snapcraft.outputs.snap }} - runs-on: [self-hosted, linux, x64] + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 @@ -34,7 +34,7 @@ jobs: test-amd64: needs: build-amd64 - runs-on: [self-hosted, linux, x64] + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 @@ -70,7 +70,7 @@ jobs: publish-amd64: needs: [build-amd64, test-amd64] - runs-on: [self-hosted, linux, x64] + runs-on: ubuntu-latest steps: - name: Download locally built snap uses: actions/download-artifact@v4 @@ -86,7 +86,7 @@ jobs: build-arm64: needs: test-amd64 - runs-on: [self-hosted, linux, x64] + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 @@ -110,7 +110,7 @@ jobs: publish-arm64: needs: [build-arm64] - runs-on: [self-hosted, linux, x64] + runs-on: ubuntu-latest steps: - name: Download locally built snap uses: actions/download-artifact@v4 From e000e94907c035af4685475331b1097c0c9101ba Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Wed, 5 Jun 2024 17:37:25 +0200 Subject: [PATCH 25/32] Add missing outputs for arm64 build --- .github/workflows/build-and-test-snap.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index fe45bb4..52ed31f 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -85,7 +85,10 @@ jobs: release: edge/ieng-1057 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-latest steps: - name: Checkout code From 0f5191ca0f5754116726876bb730d42734f80d34 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Thu, 6 Jun 2024 08:46:52 +0200 Subject: [PATCH 26/32] Fix arm64 output variable path --- .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 52ed31f..bf60de8 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -88,7 +88,7 @@ jobs: # We do not start the long running arm64 build unless the amd64 tests have passed. needs: test-amd64 outputs: - snap: ${{ steps.snapcraft.outputs.snap }} + snap: ${{ steps.build.outputs.snap }} runs-on: ubuntu-latest steps: - name: Checkout code From feb762bf6e412fc810f340ad042dbce5afddbbdd Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Thu, 6 Jun 2024 08:47:28 +0200 Subject: [PATCH 27/32] Get snap name from variable in test --- .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 bf60de8..eaa3c5a 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -57,7 +57,7 @@ jobs: working-directory: tests env: SKIP_TEARDOWN_REMOVAL: true - LOCAL_SERVICE_SNAP: ../chip-tool_*.snap + LOCAL_SERVICE_SNAP: ../${{ needs.build-amd64.outputs.snap }} run: | go test -failfast -p 1 -timeout 30m -v From ab928b77d57abb29a39526e0d7704f4188759e07 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Thu, 6 Jun 2024 08:48:06 +0200 Subject: [PATCH 28/32] Remove .snap from zip archive names Rename archive name variables --- .github/workflows/build-and-test-snap.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index eaa3c5a..821fefe 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -9,8 +9,8 @@ on: workflow_dispatch: env: - SNAP_AMD64: chip-tool_${{ github.run_number}}_amd64.snap - SNAP_ARM64: chip-tool_${{ github.run_number}}_arm64.snap + ARTIFACT_AMD64: chip-tool_${{ github.run_number}}_amd64 + ARTIFACT_ARM64: chip-tool_${{ github.run_number}}_arm64 jobs: build-amd64: @@ -28,7 +28,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: ${{ env.SNAP_AMD64 }} + name: ${{ env.ARTIFACT_AMD64 }} path: ${{ steps.snapcraft.outputs.snap }} if-no-files-found: error @@ -44,7 +44,7 @@ jobs: - name: Download locally built snap uses: actions/download-artifact@v4 with: - name: ${{ env.SNAP_AMD64 }} + name: ${{ env.ARTIFACT_AMD64 }} - name: Setup Go uses: actions/setup-go@v5 @@ -75,7 +75,7 @@ jobs: - name: Download locally built snap uses: actions/download-artifact@v4 with: - name: ${{ env.SNAP_AMD64 }} + name: ${{ env.ARTIFACT_AMD64 }} - uses: snapcore/action-publish@v1 env: @@ -108,7 +108,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: ${{ env.SNAP_ARM64 }} + name: ${{ env.ARTIFACT_ARM64 }} path: ${{ steps.build.outputs.snap }} publish-arm64: @@ -118,7 +118,7 @@ jobs: - name: Download locally built snap uses: actions/download-artifact@v4 with: - name: ${{ env.SNAP_AMD64 }} + name: ${{ env.ARTIFACT_ARM64 }} - uses: snapcore/action-publish@v1 env: From d6a3e13c7318e081fad85e229892248975f1857d Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Thu, 6 Jun 2024 08:53:34 +0200 Subject: [PATCH 29/32] Rename arm64 build step to snapcraft --- .github/workflows/build-and-test-snap.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 821fefe..556e126 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -88,7 +88,7 @@ jobs: # We do not start the long running arm64 build unless the amd64 tests have passed. needs: test-amd64 outputs: - snap: ${{ steps.build.outputs.snap }} + snap: ${{ steps.snapcraft.outputs.snap }} runs-on: ubuntu-latest steps: - name: Checkout code @@ -101,7 +101,7 @@ jobs: - name: Build snap uses: diddlesnaps/snapcraft-multiarch-action@v1 - id: build + id: snapcraft with: architecture: arm64 @@ -109,7 +109,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ env.ARTIFACT_ARM64 }} - path: ${{ steps.build.outputs.snap }} + path: ${{ steps.snapcraft.outputs.snap }} publish-arm64: needs: [build-arm64] From 01982fe668d5d54d9dfc5cd0aef65aa3428b04c1 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Thu, 6 Jun 2024 13:46:39 +0200 Subject: [PATCH 30/32] Add scheduled run --- .github/workflows/build-and-test-snap.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 556e126..0d5ac91 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -1,6 +1,8 @@ -name: Snap Tester +name: Build, test and publish snap on: + schedule: + - cron: "20 2 * * 1" # Monday morning 02:20 UTC push: branches: [ main ] pull_request: From 34d6fee5325e2638ca44494658a11f92616ebf5c Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 7 Jun 2024 10:26:14 +0200 Subject: [PATCH 31/32] Only publish to store on main branch --- .github/workflows/build-and-test-snap.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-snap.yml b/.github/workflows/build-and-test-snap.yml index 0d5ac91..bbc87f4 100644 --- a/.github/workflows/build-and-test-snap.yml +++ b/.github/workflows/build-and-test-snap.yml @@ -71,6 +71,8 @@ jobs: path: tests/*.log publish-amd64: + # Only publish if we are on the main branch + if: github.ref == 'refs/heads/main' needs: [build-amd64, test-amd64] runs-on: ubuntu-latest steps: @@ -84,7 +86,7 @@ jobs: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} with: snap: ${{ needs.build-amd64.outputs.snap }} - release: edge/ieng-1057 + release: latest/edge build-arm64: # We do not start the long running arm64 build unless the amd64 tests have passed. @@ -114,6 +116,8 @@ jobs: path: ${{ steps.snapcraft.outputs.snap }} publish-arm64: + # Only publish if we are on the main branch + if: github.ref == 'refs/heads/main' needs: [build-arm64] runs-on: ubuntu-latest steps: @@ -127,4 +131,4 @@ jobs: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} with: snap: ${{ needs.build-arm64.outputs.snap }} - release: edge/ieng-1057 + release: latest/edge From b9ce10fea7405e86dd1f4611455d7b1ff24d3318 Mon Sep 17 00:00:00 2001 From: JP Meijers Date: Fri, 7 Jun 2024 10:52:45 +0200 Subject: [PATCH 32/32] Rename version env vars --- snap/snapcraft.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 1ce43a9..ad9cd1b 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -21,16 +21,16 @@ parts: connectedhomeip: plugin: nil build-environment: - - UPSTREAM_TAG: master - - PACKAGE_VERSION: snap + - BUILD_METADATA: snap + - CHIP_TAG: master override-pull: | # shallow clone the project and its submodules - git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$UPSTREAM_TAG . + git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$CHIP_TAG . scripts/checkout_submodules.py --shallow --platform linux # prefix the snap version with the upstream tag, or fall back to the commit hash UPSTREAM_VERSION=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD) - craftctl set version=$UPSTREAM_VERSION+$PACKAGE_VERSION + craftctl set version=$UPSTREAM_VERSION+$BUILD_METADATA chip-tool: after: [connectedhomeip]