Skip to content

Commit

Permalink
Add matrix to runs-on in snaps (#78)
Browse files Browse the repository at this point in the history
* Add matrix to runs-on in snaps

This way it's possible to build and release snaps using arm64
for the projects.

Added arm64 build and release for the dcgm snap

---------

Co-authored-by: Samuel Allan <[email protected]>
  • Loading branch information
gabrielcocenza and samuelallan72 authored Sep 18, 2024
1 parent 573421b commit c5b914f
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ templates = {
release = {
source = "./templates/github/snap_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {}
vars = {
runs_on = "[[ubuntu-22.04]]",
}
}
}
8 changes: 6 additions & 2 deletions terraform-plans/configs/dcgm-snap_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ templates = {
check = {
source = "./templates/github/snap_check.yaml.tftpl"
destination = ".github/workflows/check.yaml"
vars = {}
vars = {
runs_on = "[[ubuntu-22.04], [self-hosted, jammy, ARM64]]",
}
}
promote = {
source = "./templates/github/snap_promote.yaml.tftpl"
Expand All @@ -25,7 +27,9 @@ templates = {
release = {
source = "./templates/github/snap_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {}
vars = {
runs_on = "[[ubuntu-22.04], [self-hosted, jammy, ARM64]]",
}
}
yamllint = {
source = "./templates/github/snap_yamllint.yaml.tftpl"
Expand Down
8 changes: 6 additions & 2 deletions terraform-plans/configs/smartctl-exporter-snap_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ templates = {
check = {
source = "./templates/github/snap_check.yaml.tftpl"
destination = ".github/workflows/check.yaml"
vars = {}
vars = {
runs_on = "[[ubuntu-22.04]]",
}
}
promote = {
source = "./templates/github/snap_promote.yaml.tftpl"
Expand All @@ -25,7 +27,9 @@ templates = {
release = {
source = "./templates/github/snap_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {}
vars = {
runs_on = "[[ubuntu-22.04]]",
}
}
yamllint = {
source = "./templates/github/snap_yamllint.yaml.tftpl"
Expand Down
8 changes: 6 additions & 2 deletions terraform-plans/configs/tailscale-snap_main.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ templates = {
check = {
source = "./templates/github/snap_check.yaml.tftpl"
destination = ".github/workflows/check.yaml"
vars = {}
vars = {
runs_on = "[[ubuntu-22.04]]",
}
}
promote = {
source = "./templates/github/snap_promote.yaml.tftpl"
Expand All @@ -25,7 +27,9 @@ templates = {
release = {
source = "./templates/github/snap_release.yaml.tftpl"
destination = ".github/workflows/release.yaml"
vars = {}
vars = {
runs_on = "[[ubuntu-22.04]]",
}
}
yamllint = {
source = "./templates/github/snap_yamllint.yaml.tftpl"
Expand Down
50 changes: 49 additions & 1 deletion terraform-plans/templates/github/snap_check.yaml.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,59 @@ jobs:
yamllint .yamllint snap/snapcraft.yaml

build:
runs-on: ubuntu-22.04
runs-on: $${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: ${runs_on}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Complete git history is required to generate the version from git tags.

- name: Verify snap builds successfully
id: build
uses: snapcore/action-build@v1

- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV

- name: Upload the built snap
uses: actions/upload-artifact@v4
with:
name: snap_$${{ env.SYSTEM_ARCH }}
path: $${{ steps.build.outputs.snap }}

func:
needs:
- build
runs-on: $${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: ${runs_on}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Complete git history is required to generate the version from git tags.

- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV

- name: Download the built snap
uses: actions/download-artifact@v4
with:
name: snap_$${{ env.SYSTEM_ARCH }}

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install 'tox<5'

- name: Run functional tests
run: tox -e func
10 changes: 8 additions & 2 deletions terraform-plans/templates/github/snap_release.yaml.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ jobs:
secrets: inherit

release:
runs-on: ubuntu-22.04
runs-on: $${{ matrix.runs-on }}
needs: check
strategy:
fail-fast: false
matrix:
runs-on: ${runs_on}
outputs:
snap: $${{ steps.build.outputs.snap }}
steps:
Expand All @@ -27,9 +31,11 @@ jobs:
fetch-depth: 0 # Complete git history is required to generate the version from git tags.
- uses: snapcore/action-build@v1
id: build
- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: snap
name: snap_$${{ env.SYSTEM_ARCH }}
path: $${{ steps.build.outputs.snap }}
- uses: snapcore/action-publish@v1
env:
Expand Down

0 comments on commit c5b914f

Please sign in to comment.