Skip to content

Commit 976a441

Browse files
ci: test on different architectures (#114)
This PR adds a reusable workflow that can run our `spread` tests on the specified architecture and runner, and adds a manually dispatchable workflow that uses this worfklow to run tests across the alternative architectures `ppc64le`, and `s390x`. - The existing testing logic has been moved from `push.yaml` to `_tests.yaml`, and `push.yaml` has been updated to call it for `amd64`. - `_tests.yaml` updates the test logic to accept the runner and architecture, building the `concierge` binary for the target architecture on Github's `ubuntu-latest`. - We can then run `spread` with our `concierge` binary on the correct runner -- `ubuntu-latest` for `amd64`, and our self-hosted runners for `ppc64le` and `s390x`. The `k8s` snap doesn't support these alternative architectures yet (tracked in canonical/k8s-snap#2076, PR in progress by maintainers at canonical/k8s-snap#1980, but support may be incomplete even if builds are provided). To keep CI green and useful, I've added logic to the workflow to skip the tests that require `k8s` based on the architecture, and updated several of the tests that used `k8s` but weren't testing anything K8s-specific to use `lxd` instead. This PR changes the job names run in CI, and the required checks have been updated accordingly. Resolves #76.
1 parent 2faeb5b commit 976a441

File tree

9 files changed

+165
-107
lines changed

9 files changed

+165
-107
lines changed

.github/workflows/_tests.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
arch:
7+
required: true
8+
type: string
9+
runner:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
binaries:
15+
name: Build concierge
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out the code
19+
uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Go
24+
uses: actions/setup-go@v6
25+
with:
26+
go-version-file: "go.mod"
27+
28+
- name: Run tests
29+
run: |
30+
go test -v -race ./...
31+
32+
- name: Setup goreleaser
33+
run: |
34+
sudo snap install --classic goreleaser
35+
36+
- name: Build concierge
37+
id: build
38+
run: |
39+
goreleaser build --clean --snapshot --single-target --output .
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
GOOS: linux
43+
GOARCH: ${{ inputs.arch }}
44+
45+
- name: Upload binary artifact
46+
uses: actions/upload-artifact@v6
47+
with:
48+
name: binary-${{ inputs.runner }}
49+
path: ./concierge
50+
51+
define-matrix:
52+
name: Define spread matrix
53+
runs-on: ubuntu-latest
54+
outputs:
55+
suites: ${{ steps.suites.outputs.suites }}
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v6
59+
60+
- name: Setup Go
61+
uses: actions/setup-go@v6
62+
with:
63+
go-version-file: "go.mod"
64+
65+
- name: Install
66+
run: |
67+
go install github.com/snapcore/spread/cmd/spread@latest
68+
69+
- name: Generate matrix list
70+
id: suites
71+
env:
72+
ARCH: ${{ inputs.arch }}
73+
run: |
74+
list="$(spread -list github-ci | sed "s|github-ci:ubuntu-24.04:tests/||g" | jq -r -ncR '[inputs | select(length>0)]')"
75+
case $ARCH in
76+
ppc64le|s390x)
77+
skip='{
78+
"preset-k8s": "Uses k8s snap.",
79+
"provider-k8s": "Uses k8s snap.",
80+
"preset-microk8s": "Uses microk8s snap.",
81+
"provider-microk8s": "Uses microk8s snap.",
82+
"juju-extra-bootstrap-args": "Uses microk8s snap.",
83+
"preset-dev": "Uses k8s and microk8s snaps.",
84+
"overrides-env": "Uses k8s and rockcraft snaps.",
85+
"provider-lxd-init-no-bootstrap": "Packs a charm (from charmcraft init) for only standard bases."
86+
}'
87+
echo "Skipping these tests:"
88+
echo $skip | jq
89+
list=$(echo "$list" | jq --compact-output --argjson skip "$skip" 'map(select(. as $item | $skip | has($item) | not))')
90+
;;
91+
amd64)
92+
echo 'Standard architecture, using all tests.'
93+
;;
94+
*)
95+
echo "Unknown architecture $ARCH, using all tests."
96+
;;
97+
esac
98+
echo "suites=$list"
99+
echo "suites=$list" >> $GITHUB_OUTPUT
100+
101+
spread-test:
102+
name: Spread (${{ matrix.suite }})
103+
runs-on: ${{ inputs.runner }}
104+
needs:
105+
- binaries
106+
- define-matrix
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
suite: ${{ fromJSON(needs.define-matrix.outputs.suites) }}
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v6
114+
115+
- name: Download binary artifact
116+
uses: actions/download-artifact@v7
117+
with:
118+
name: binary-${{ inputs.runner }}
119+
120+
- name: Setup Go
121+
uses: actions/setup-go@v6
122+
with:
123+
go-version-file: "go.mod"
124+
architecture: ${{ inputs.arch }}
125+
126+
- name: Install
127+
run: |
128+
go install github.com/snapcore/spread/cmd/spread@latest
129+
130+
- name: Run integration tests
131+
run: |
132+
spread -v "github-ci:ubuntu-24.04:tests/${{ matrix.suite }}"

.github/workflows/push.yaml

Lines changed: 5 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -36,92 +36,8 @@ jobs:
3636
run: |
3737
! egrep -R --exclude-dir .git 'interface\{\}'
3838
39-
binaries:
40-
name: Build concierge
41-
runs-on: ubuntu-latest
42-
steps:
43-
- name: Check out the code
44-
uses: actions/checkout@v6
45-
with:
46-
fetch-depth: 0
47-
48-
- name: Setup Go
49-
uses: actions/setup-go@v6
50-
with:
51-
go-version-file: "go.mod"
52-
53-
- name: Run tests
54-
run: |
55-
go test -v -race ./...
56-
57-
- name: Setup goreleaser
58-
run: |
59-
sudo snap install --classic goreleaser
60-
61-
- name: Build concierge
62-
id: build
63-
run: |
64-
goreleaser build --clean --snapshot --single-target --output .
65-
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
68-
- name: Upload binary artifact
69-
uses: actions/upload-artifact@v6
70-
with:
71-
name: binary
72-
path: ./concierge
73-
74-
define-matrix:
75-
name: Define spread matrix
76-
runs-on: ubuntu-24.04
77-
outputs:
78-
suites: ${{ steps.suites.outputs.suites }}
79-
steps:
80-
- name: Checkout
81-
uses: actions/checkout@v6
82-
83-
- name: Setup Go
84-
uses: actions/setup-go@v6
85-
86-
- name: Install
87-
run: |
88-
go install github.com/snapcore/spread/cmd/spread@latest
89-
90-
- name: Generate matrix list
91-
id: suites
92-
run: |
93-
list="$(spread -list github-ci | sed "s|github-ci:ubuntu-24.04:tests/||g" | jq -r -ncR '[inputs | select(length>0)]')"
94-
echo "suites=$list"
95-
echo "suites=$list" >> $GITHUB_OUTPUT
96-
97-
spread-test:
98-
name: Spread (${{ matrix.suite }})
99-
runs-on: ubuntu-24.04
100-
needs:
101-
- binaries
102-
- define-matrix
103-
strategy:
104-
fail-fast: false
105-
matrix:
106-
suite: ${{ fromJSON(needs.define-matrix.outputs.suites) }}
107-
steps:
108-
- name: Checkout
109-
uses: actions/checkout@v6
110-
111-
- name: Download binary artifact
112-
uses: actions/download-artifact@v7
113-
with:
114-
name: binary
115-
116-
- name: Setup Go
117-
uses: actions/setup-go@v6
118-
with:
119-
go-version-file: "go.mod"
120-
121-
- name: Install
122-
run: |
123-
go install github.com/snapcore/spread/cmd/spread@latest
124-
125-
- name: Run integration tests
126-
run: |
127-
spread -v "github-ci:ubuntu-24.04:tests/${{ matrix.suite }}"
39+
test:
40+
uses: ./.github/workflows/_tests.yaml
41+
with:
42+
arch: amd64
43+
runner: ubuntu-24.04
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# We test on alternative architectures manually rather than in push.yaml.
2+
# This is because these tests need to run on our self-hosted runners for these arches,
3+
# which are currently a bit too slow and flaky to run on PRs without sporadic failures.
4+
name: Test on alternative architectures
5+
6+
on:
7+
workflow_dispatch:
8+
9+
jobs:
10+
ppc64le:
11+
uses: ./.github/workflows/_tests.yaml
12+
with:
13+
arch: ppc64le # note: ppc64le for arch, ppc64el in runner name
14+
runner: self-hosted-linux-ppc64el-noble-edge
15+
16+
s390x:
17+
uses: ./.github/workflows/_tests.yaml
18+
with:
19+
arch: s390x
20+
runner: self-hosted-linux-s390x-noble-edge

spread.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ path: /root/proj
8383
prepare: |
8484
snap refresh --hold
8585
if systemctl is-enabled unattended-upgrades.service; then
86-
systemctl stop unattended-upgrades.service
86+
systemctl stop unattended-upgrades.service || echo 'Self-hosted runner?'
8787
systemctl mask unattended-upgrades.service
8888
fi
8989

tests/disable-juju-env-var/task.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ execute: |
66
pushd "${SPREAD_PATH}/${SPREAD_TASK}"
77
88
export CONCIERGE_DISABLE_JUJU=true
9-
"$SPREAD_PATH"/concierge --trace prepare --preset k8s
9+
"$SPREAD_PATH"/concierge --trace prepare --preset machine
1010
1111
list="$(snap list lxd)"
1212
echo $list | MATCH lxd

tests/juju-model-defaults/concierge.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ juju:
55
automatically-retry-hooks: "false"
66

77
providers:
8-
microk8s:
8+
lxd:
99
enable: true
1010
bootstrap: true
11-
channel: 1.31-strict/stable
12-
addons:
13-
- hostpath-storage
14-
- dns
11+
channel: latest/stable

tests/juju-model-defaults/task.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ execute: |
77
88
"$SPREAD_PATH"/concierge --trace prepare
99
10-
juju controllers | tail -n1 | MATCH concierge-microk8s
10+
juju controllers | tail -n1 | MATCH concierge-lxd
1111
juju models | tail -n1 | MATCH testing
1212
1313
juju model-defaults | grep test-mode | tr -s " " | MATCH "test-mode false true"

tests/restore/task.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ execute: |
66
pushd "${SPREAD_PATH}/${SPREAD_TASK}"
77
88
# First, prepare the machine
9-
"$SPREAD_PATH"/concierge --trace prepare -p k8s
9+
"$SPREAD_PATH"/concierge --trace prepare -p machine
1010
1111
# Ensure that the runtime configuration was dumped into the user's cache dir
1212
ls ~/.cache/concierge/concierge.yaml
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
providers:
2-
k8s:
2+
lxd:
33
enable: true
44
bootstrap: true
5-
channel: 1.32-classic/stable
6-
features:
7-
local-storage:
8-
load-balancer:
9-
l2-mode: true
10-
cidrs: 10.64.140.43/32
11-
bootstrap-constraints:
12-
root-disk: 2G
5+
channel: latest/stable

0 commit comments

Comments
 (0)