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

ci: fix actions on ubuntu 24.04 runners #18

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix.

series=$(yq ".images.[\"${{ matrix.image }}\"].series" < images.yaml)
juju bootstrap microk8s
juju status -m controller
Expand Down
Loading