Skip to content

Commit 56a937a

Browse files
authored
Merge pull request #18 from juju/fix-release
ci: fix actions on ubuntu 24.04 runners
2 parents dd31409 + 9e21ea9 commit 56a937a

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

.github/workflows/build.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: build
22
on:
33
pull_request: {}
4+
workflow_dispatch:
45
jobs:
56
generate-matrix:
67
runs-on: ubuntu-latest
@@ -43,6 +44,58 @@ jobs:
4344
sudo apt install -y make jq
4445
sudo snap install yq
4546
47+
- name: Install microk8s
48+
run: |
49+
microk8s_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].microk8s_test_channel" < images.yaml)
50+
sudo snap install microk8s --channel=${microk8s_test_channel} || sudo snap install microk8s --channel=${microk8s_test_channel} --classic
51+
sudo microk8s.status --wait-ready
52+
sudo microk8s.enable storage dns
53+
sudo microk8s.status --wait-ready
54+
microk8s_group=microk8s
55+
if getent group snap_microk8s; then
56+
microk8s_group=snap_microk8s
57+
fi
58+
sudo usermod -a -G "${microk8s_group}" "${USER}"
59+
4660
- name: Make build image ${{ matrix.image }}
4761
run: |
4862
IMAGES=${{ matrix.image }} make build
63+
64+
- name: Install juju snap
65+
run: |
66+
juju_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].juju_test_channel" < images.yaml)
67+
sudo snap install juju --channel=${juju_test_channel} || sudo snap install juju --channel=${juju_test_channel} --classic
68+
echo "installed juju $(juju version)"
69+
70+
- name: Copy built image to microk8s.ctr
71+
run: |
72+
IMAGES=${{ matrix.image }} make microk8s-image-update
73+
74+
- name: Bootstrap juju into microk8s
75+
run: |
76+
microk8s_group=microk8s
77+
if getent group snap_microk8s; then
78+
microk8s_group=snap_microk8s
79+
fi
80+
$(echo sudo su $USER -G ${microk8s_group} -g $(groups | sed "s/\s/ -G /g")) <<'EOF'
81+
series=$(yq ".images.[\"${{ matrix.image }}\"].series" < images.yaml)
82+
juju bootstrap microk8s
83+
juju status -m controller
84+
juju add-model test
85+
juju deploy ./test-charm --series "${series}"
86+
87+
until juju status | grep -q "Image is all good."; do
88+
sleep 1
89+
juju status
90+
done
91+
92+
image_tag="$(microk8s.kubectl -n test get pod ubuntu-test-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="charm"))[0].image')"
93+
expected_image_id="$(docker inspect ${image_tag} --format {{.ID}})"
94+
got_image_id="$(microk8s.kubectl -n test get pod ubuntu-test-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="charm"))[0].imageID')"
95+
echo "image ${image_tag} built as ${expected_image_id}"
96+
echo "image ${image_tag} used as ${got_image_id}"
97+
if [ "${expected_image_id}" != "${got_image_id}" ]; then
98+
echo "${got_image_id} does not match expected ${expected_image_id}"
99+
exit 1
100+
fi
101+
EOF

.github/workflows/release.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- "master"
66
schedule:
77
- cron: "15 0 * * *"
8+
workflow_dispatch:
89
jobs:
910
generate-matrix:
1011
runs-on: ubuntu-latest
@@ -47,10 +48,6 @@ jobs:
4748
sudo apt install -y make jq
4849
sudo snap install yq
4950
50-
- name: Make build image ${{ matrix.image }}
51-
run: |
52-
IMAGES=${{ matrix.image }} make build
53-
5451
- name: Install microk8s
5552
run: |
5653
microk8s_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].microk8s_test_channel" < images.yaml)
@@ -64,6 +61,10 @@ jobs:
6461
fi
6562
sudo usermod -a -G "${microk8s_group}" $USER
6663
64+
- name: Make build image ${{ matrix.image }}
65+
run: |
66+
IMAGES=${{ matrix.image }} make build
67+
6768
- name: Install juju snap
6869
run: |
6970
juju_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].juju_test_channel" < images.yaml)
@@ -80,7 +81,7 @@ jobs:
8081
if getent group snap_microk8s; then
8182
microk8s_group=snap_microk8s
8283
fi
83-
sg "${microk8s_group}" <<'EOF'
84+
$(echo sudo su $USER -G ${microk8s_group} -g $(groups | sed "s/\s/ -G /g")) <<'EOF'
8485
series=$(yq ".images.[\"${{ matrix.image }}\"].series" < images.yaml)
8586
juju bootstrap microk8s
8687
juju status -m controller

0 commit comments

Comments
 (0)