Skip to content

Commit

Permalink
Merge pull request #18 from juju/fix-release
Browse files Browse the repository at this point in the history
ci: fix actions on ubuntu 24.04 runners
  • Loading branch information
hpidcock authored Dec 18, 2024
2 parents dd31409 + 9e21ea9 commit 56a937a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: build
on:
pull_request: {}
workflow_dispatch:
jobs:
generate-matrix:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -43,6 +44,58 @@ jobs:
sudo apt install -y make jq
sudo snap install yq
- name: Install microk8s
run: |
microk8s_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].microk8s_test_channel" < images.yaml)
sudo snap install microk8s --channel=${microk8s_test_channel} || sudo snap install microk8s --channel=${microk8s_test_channel} --classic
sudo microk8s.status --wait-ready
sudo microk8s.enable storage dns
sudo microk8s.status --wait-ready
microk8s_group=microk8s
if getent group snap_microk8s; then
microk8s_group=snap_microk8s
fi
sudo usermod -a -G "${microk8s_group}" "${USER}"
- name: Make build image ${{ matrix.image }}
run: |
IMAGES=${{ matrix.image }} make build
- name: Install juju snap
run: |
juju_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].juju_test_channel" < images.yaml)
sudo snap install juju --channel=${juju_test_channel} || sudo snap install juju --channel=${juju_test_channel} --classic
echo "installed juju $(juju version)"
- name: Copy built image to microk8s.ctr
run: |
IMAGES=${{ matrix.image }} make microk8s-image-update
- name: Bootstrap juju into microk8s
run: |
microk8s_group=microk8s
if getent group snap_microk8s; then
microk8s_group=snap_microk8s
fi
$(echo sudo su $USER -G ${microk8s_group} -g $(groups | sed "s/\s/ -G /g")) <<'EOF'
series=$(yq ".images.[\"${{ matrix.image }}\"].series" < images.yaml)
juju bootstrap microk8s
juju status -m controller
juju add-model test
juju deploy ./test-charm --series "${series}"
until juju status | grep -q "Image is all good."; do
sleep 1
juju status
done
image_tag="$(microk8s.kubectl -n test get pod ubuntu-test-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="charm"))[0].image')"
expected_image_id="$(docker inspect ${image_tag} --format {{.ID}})"
got_image_id="$(microk8s.kubectl -n test get pod ubuntu-test-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="charm"))[0].imageID')"
echo "image ${image_tag} built as ${expected_image_id}"
echo "image ${image_tag} used as ${got_image_id}"
if [ "${expected_image_id}" != "${got_image_id}" ]; then
echo "${got_image_id} does not match expected ${expected_image_id}"
exit 1
fi
EOF
11 changes: 6 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- "master"
schedule:
- cron: "15 0 * * *"
workflow_dispatch:
jobs:
generate-matrix:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -47,10 +48,6 @@ jobs:
sudo apt install -y make jq
sudo snap install yq
- name: Make build image ${{ matrix.image }}
run: |
IMAGES=${{ matrix.image }} make build
- name: Install microk8s
run: |
microk8s_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].microk8s_test_channel" < images.yaml)
Expand All @@ -64,6 +61,10 @@ jobs:
fi
sudo usermod -a -G "${microk8s_group}" $USER
- name: Make build image ${{ matrix.image }}
run: |
IMAGES=${{ matrix.image }} make build
- name: Install juju snap
run: |
juju_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].juju_test_channel" < images.yaml)
Expand All @@ -80,7 +81,7 @@ jobs:
if getent group snap_microk8s; then
microk8s_group=snap_microk8s
fi
sg "${microk8s_group}" <<'EOF'
$(echo sudo su $USER -G ${microk8s_group} -g $(groups | sed "s/\s/ -G /g")) <<'EOF'
series=$(yq ".images.[\"${{ matrix.image }}\"].series" < images.yaml)
juju bootstrap microk8s
juju status -m controller
Expand Down

0 comments on commit 56a937a

Please sign in to comment.