Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weekly workflow to build and publish snap #61

Merged
merged 33 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3c6ba00
Merge remote-tracking branch 'origin/main' into feature/IENG-1057-git…
jpm-canonical Jun 4, 2024
f0a8176
Add publish snap
jpm-canonical Jun 4, 2024
f27d690
Debug asset file name
jpm-canonical Jun 5, 2024
f64e66a
Remove dependency on other jobs
jpm-canonical Jun 5, 2024
b7c76cf
Add build back
jpm-canonical Jun 5, 2024
0757036
Add back dependency
jpm-canonical Jun 5, 2024
9f00fc1
Hardcoded artifact name
jpm-canonical Jun 5, 2024
1563b09
Try upload to store with wildcard name
jpm-canonical Jun 5, 2024
74f8296
Build and upload with wildcard
jpm-canonical Jun 5, 2024
8153baf
Do a fake build to speed up
jpm-canonical Jun 5, 2024
39a7652
Use output variable from build step
jpm-canonical Jun 5, 2024
5b11e9d
Write variable to outputs file
jpm-canonical Jun 5, 2024
00d37b0
Correct use of variable
jpm-canonical Jun 5, 2024
2bd20e7
Use git hash in snap version
jpm-canonical Jun 5, 2024
a577164
Re-enable real build
jpm-canonical Jun 5, 2024
6720055
Check file before upload
jpm-canonical Jun 5, 2024
3a543ac
Update snap publish action to use env var for secret
jpm-canonical Jun 5, 2024
0989a8c
Clean up workflow
jpm-canonical Jun 5, 2024
201aed2
Snap version use upstream tag
jpm-canonical Jun 5, 2024
45cd3cd
Remove arm64 for now to test
jpm-canonical Jun 5, 2024
f67c831
Update version logic
jpm-canonical Jun 5, 2024
1df7696
Rework snap version
jpm-canonical Jun 5, 2024
f792666
Run workflow on self-hosted and enable arm64
jpm-canonical Jun 5, 2024
e687361
Fix git version command
jpm-canonical Jun 5, 2024
65cb1c8
Move back to github hosted runners
jpm-canonical Jun 5, 2024
e000e94
Add missing outputs for arm64 build
jpm-canonical Jun 5, 2024
0f5191c
Fix arm64 output variable path
jpm-canonical Jun 6, 2024
feb762b
Get snap name from variable in test
jpm-canonical Jun 6, 2024
ab928b7
Remove .snap from zip archive names
jpm-canonical Jun 6, 2024
d6a3e13
Rename arm64 build step to snapcraft
jpm-canonical Jun 6, 2024
01982fe
Add scheduled run
jpm-canonical Jun 6, 2024
34d6fee
Only publish to store on main branch
jpm-canonical Jun 7, 2024
b9ce10f
Rename version env vars
jpm-canonical Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 54 additions & 13 deletions .github/workflows/build-and-test-snap.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -9,11 +11,11 @@ on:
workflow_dispatch:

jpm-canonical marked this conversation as resolved.
Show resolved Hide resolved
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:
build-amd64:
outputs:
snap: ${{ steps.snapcraft.outputs.snap }}
runs-on: ubuntu-latest
Expand All @@ -28,12 +30,12 @@ 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

test:
needs: build
test-amd64:
needs: build-amd64
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -44,7 +46,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
Expand All @@ -57,7 +59,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

Expand All @@ -68,8 +70,29 @@ jobs:
name: logs
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:
- 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:
needs: test
# 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
Expand All @@ -82,12 +105,30 @@ jobs:

- name: Build snap
uses: diddlesnaps/snapcraft-multiarch-action@v1
id: build
id: snapcraft
with:
architecture: arm64

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.SNAP_ARM64 }}
path: ${{ steps.build.outputs.snap }}
name: ${{ env.ARTIFACT_ARM64 }}
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:
- 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-arm64.outputs.snap }}
release: latest/edge
14 changes: 8 additions & 6 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ parts:
connectedhomeip:
plugin: nil
build-environment:
- TAG: master
- BUILD_METADATA: snap
- CHIP_TAG: master
override-pull: |
# shallow clone the project its submodules
git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$TAG .
# shallow clone the project and its submodules
git clone https://github.com/project-chip/connectedhomeip.git --depth=1 --branch=$CHIP_TAG .
scripts/checkout_submodules.py --shallow --platform linux

# set the snap version
craftctl set version=$TAG+snap

# 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+$BUILD_METADATA

chip-tool:
after: [connectedhomeip]
plugin: nil
Expand Down
Loading