@@ -21,24 +21,60 @@ jobs:
2121
2222 - name : Set up Python
2323 uses : actions/setup-python@v4
24+ with :
25+ python-version : ' 3.10'
26+
27+ - name : Install uv
28+ run : pip install uv
29+
30+ - name : Create uv virtualenv
31+ run : uv venv
2432
2533 - name : Install dependencies for testing
2634 run : |
27- pip install -r requirements-dev.txt
35+ source .venv/bin/activate
36+ uv pip install ".[dev]"
2837
2938 - name : Run tests
3039 run : |
40+ source .venv/bin/activate
3141 ./run_tests
3242
33-
3443 build :
35- name : Build charms
44+ name : Build charm
3645 needs : unit-tests
37- uses : canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v32.2.1
38- with :
39- charmcraft-snap-channel : 2.x/stable
40- artifact-prefix : charm-packed
46+ runs-on : ubuntu-latest
47+ steps :
48+ - name : Checkout code
49+ uses : actions/checkout@v4
50+
51+ - name : Set up Python
52+ uses : actions/setup-python@v4
53+ with :
54+ python-version : ' 3.10'
55+
56+ - name : Install uv
57+ run : pip install uv
4158
59+ - name : Set up LXD
60+ uses : canonical/setup-lxd@90d76101915da56a42a562ba766b1a77019242fd
61+
62+ - name : Add runner to lxd group
63+ run : |
64+ sudo usermod -a -G lxd $USER
65+ newgrp lxd
66+
67+ - name : Install charmcraft
68+ run : sudo snap install charmcraft --classic --channel=3.x/stable
69+
70+ - name : Pack charm
71+ run : sg lxd -c "charmcraft pack"
72+
73+ - name : Upload charm artifact
74+ uses : actions/upload-artifact@v4
75+ with :
76+ name : charm
77+ path : " *.charm"
4278
4379 channel :
4480 name : Select Charmhub channel
5591 set -eux
5692 case ${{ github.ref_name }} in
5793 3.* | 4.*)
58- TRACK="${{ github.ref_name }}"
94+ TRACK=$(echo "${{ github.ref_name }}" | awk -F "-" '{print $1}')
5995 DO_RELEASE=true
6096 ;;
6197 main)
@@ -84,20 +120,24 @@ jobs:
84120 runs-on : ubuntu-latest
85121
86122 steps :
123+ - name : Checkout code
124+ uses : actions/checkout@v4
125+
87126 - name : Download packed charm
88127 id : download
89- uses : actions/download-artifact@v3
128+ uses : actions/download-artifact@v4
90129 with :
91- name : ${{ needs.build.outputs.artifact-name }}
130+ name : charm
92131
93- - name : Upload charm to Charmhub
132+ - name : Upload charms to Charmhub
94133 env :
95134 CHARMCRAFT_AUTH : ${{ secrets.CHARMCRAFT_AUTH }}
96135 run : |
97136 sudo snap install charmcraft --channel 3.x/stable --classic
98- charmcraft upload ${{ steps.download.outputs.download-path }}/*.charm \
99- --name $CHARM_NAME \
100- --release ${{ needs.channel.outputs.test }}
137+ for FILE in *.charm; do
138+ echo "Uploading: $FILE"
139+ charmcraft upload --name "$CHARM_NAME" --release "${{ needs.channel.outputs.test }}" "$FILE"
140+ done
101141
102142
103143 integration :
@@ -108,103 +148,70 @@ jobs:
108148 fail-fast : false
109149 matrix :
110150 cloud : ["lxd", "microk8s"]
111- env :
112- LOCAL_CHARM_PATH : ${{ github.workspace }}/controller.charm
113151
114152 steps :
115- - name : Download packed charm
116- id : download
117- uses : actions/download-artifact@v3
118- with :
119- name : ${{ needs.build.outputs.artifact-name }}
120-
121- - name : Rename charm file
122- run : |
123- mv ${{ steps.download.outputs.download-path }}/*.charm \
124- $LOCAL_CHARM_PATH
125-
126153 - name : Save charmcraft logs as artifact
127154 if : always() && steps.charmcraft.outcome != 'skipped'
128- uses : actions/upload-artifact@v3
155+ uses : actions/upload-artifact@v4
129156 with :
130157 name : charmcraft-upload-logs
131158 path : ~/.local/state/charmcraft/log/
132159 continue-on-error : true
133160
134- - name : Set up LXD
161+ - name : Setup LXD
135162 if : matrix.cloud == 'lxd'
136- uses : canonical/setup-lxd@90d76101915da56a42a562ba766b1a77019242fd
163+ uses : canonical/setup-lxd@2fa6235ef2dfd3288e0de09edac03f2ebf922968
137164
138165 - name : Set up MicroK8s
139166 if : matrix.cloud == 'microk8s'
140- uses : balchua/microk8s-actions@v0.3.1
167+ uses : balchua/microk8s-actions@v0.4.2
141168 with :
142169 channel : " 1.25-strict/stable"
143170 addons : ' ["dns", "hostpath-storage"]'
144171
145172 - name : Install Juju
146173 run : |
147- sudo snap install juju --channel 4.0/beta
174+ sudo snap install juju --channel 4.0/stable
148175
149176 - name : Bootstrap on LXD
150177 if : matrix.cloud == 'lxd'
151178 run : |
152179 juju bootstrap lxd c \
153- --controller-charm-path=$LOCAL_CHARM_PATH
180+ --controller-charm-channel=${{ needs.channel.outputs.test }}
154181
155182 - name : Bootstrap on MicroK8s
156183 if : matrix.cloud == 'microk8s'
157184 run : |
158185 sg snap_microk8s <<EOF
159186 juju bootstrap microk8s c \
160- --controller-charm-path=$CHARM_NAME \
161187 --controller-charm-channel=${{ needs.channel.outputs.test }}
162188 EOF
163189
164190 - name : Check charm status
165191 run : |
166192 juju switch controller
167- juju wait-for application controller --timeout 1m
168193 juju status
169194
195+ start_time="$(date -u +%s)"
196+ until [[ $(juju status --format=json 2>/dev/null | jq -r '.applications.controller["application-status"].current') == "active" ]]; do
197+ echo "Waiting for controller to become active..."
198+ juju status
199+ sleep 10
200+
201+ elapsed=$(date -u +%s)-${start_time}
202+ if [[ ${elapsed} -ge 600 ]]; then
203+ echo "Timed out waiting for controller to become active"
204+ juju status
205+ exit 1
206+ fi
207+ done
208+
170209 - name : Get some info for debugging
171210 if : failure()
172211 run : |
173212 set -x
174213 set +e
175214 juju status
176- juju status --format json
177- juju debug-log -m controller
215+ juju debug-log -m controller --replay
178216
179217 # TODO: test integration with dashboard / ha-proxy
180-
181-
182- release :
183- name : " Release to edge"
184- runs-on : ubuntu-latest
185- needs : [upload, channel, integration]
186- env :
187- CHARMCRAFT_AUTH : ${{ secrets.CHARMCRAFT_AUTH }}
188-
189- steps :
190- - name : Install Charmcraft
191- run : |
192- sudo snap install charmcraft --channel 3.x/stable --classic
193-
194- - name : Get uploaded revision
195- id : revision
196- env :
197- CHANNEL : ${{ needs.channel.outputs.test }}
198- run : |
199- set -x
200- TRACK=$(echo $CHANNEL | cut -d '/' -f 1)
201- REVISION=$(charmcraft status $CHARM_NAME --format json |
202- jq ".[] | select(.track == \"$TRACK\") | .mappings[0].releases[] | select(.channel == \"$CHANNEL\") | .revision")
203- echo "revision=$REVISION" >> "$GITHUB_OUTPUT"
204-
205- - name : Release to edge
206- if : github.event_name == 'push' && needs.channel.outputs.release != ''
207- run : |
208- charmcraft release $CHARM_NAME \
209- --revision=${{ steps.revision.outputs.revision }} \
210- --channel=${{ needs.channel.outputs.release }}
0 commit comments