Skip to content

Commit 8b44c4c

Browse files
authored
chore: Update CI to use charmcraftcache (#331)
* chore: Update CI to use charmcraftcache * Add back on_pull_request.yaml for backport label population * Fix CI: update stale workflow references * Remove weekly_ci.yaml (schedule already in ci.yaml) * ci: always collect juju status * Update Cilium config: add cni-exclusive patch and update comment URL * fix: Grant actions: read to ci-tests job in release workflow The ci.yaml reusable workflow's build and release jobs request 'actions: read' (needed by charmcraftcache), but the caller job in release.yaml did not grant this permission, causing a startup failure. Add permissions: actions: read to the ci-tests job. * fix: Grant contents: read to ci-tests job in release workflow
1 parent 8574344 commit 8b44c4c

12 files changed

Lines changed: 255 additions & 290 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: CI
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
schedule:
10+
- cron: '0 8 * * TUE'
11+
workflow_call:
12+
outputs:
13+
artifact-prefix:
14+
description: build_charm.yaml `artifact-prefix` output
15+
value: ${{ jobs.build.outputs.artifact-prefix }}
16+
charm-paths:
17+
description: paths for all charms in this repo
18+
value: ${{ jobs.get-charm-paths-track.outputs.charm-paths }}
19+
track:
20+
description: Charmhub track determined from branch name
21+
value: ${{ jobs.get-charm-paths-track.outputs.track }}
22+
23+
jobs:
24+
get-charm-paths-track:
25+
name: Get charm paths and track
26+
runs-on: ubuntu-latest
27+
outputs:
28+
charm-paths: ${{ steps.get-charm-paths.outputs.charm-paths }}
29+
track: ${{ steps.determine-track.outputs.track }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
- name: Get paths for all charms in this repo
35+
id: get-charm-paths
36+
uses: canonical/kubeflow-ci/actions/get-charm-paths@main
37+
- name: Determine track
38+
id: determine-track
39+
shell: python
40+
run: |
41+
import os
42+
43+
if "${{ github.event_name }}" == "pull_request":
44+
ref = "${{ github.base_ref }}"
45+
else:
46+
ref = "${{ github.ref_name }}"
47+
48+
if ref.startswith("track/"):
49+
track = ref.removeprefix("track/")
50+
else:
51+
track = "latest"
52+
53+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
54+
f.write(f"track={track}\n")
55+
56+
print(f"Track: {track}")
57+
58+
lint:
59+
name: Lint
60+
runs-on: ubuntu-24.04
61+
steps:
62+
- uses: actions/checkout@v4
63+
- run: pipx install tox
64+
- run: tox -vve lint
65+
66+
unit:
67+
name: Unit tests
68+
runs-on: ubuntu-24.04
69+
steps:
70+
- uses: actions/checkout@v4
71+
- run: pipx install tox
72+
- run: tox -e unit
73+
74+
terraform-checks:
75+
name: Terraform
76+
needs:
77+
- get-charm-paths-track
78+
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@main
79+
strategy:
80+
matrix:
81+
charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }}
82+
with:
83+
charm-path: ${{ matrix.charm }}
84+
85+
build:
86+
strategy:
87+
matrix:
88+
charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }}
89+
name: Build charm | ${{ matrix.charm }}
90+
needs:
91+
- get-charm-paths-track
92+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v49.0.1
93+
with:
94+
path-to-charm-directory: ${{ matrix.charm }}
95+
cache: true
96+
permissions:
97+
actions: read
98+
contents: read
99+
100+
release:
101+
strategy:
102+
matrix:
103+
charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }}
104+
name: Release charm to Charmhub branch | ${{ matrix.charm }}
105+
if: ${{ github.event_name == 'pull_request' }}
106+
needs:
107+
- get-charm-paths-track
108+
- build
109+
uses: canonical/data-platform-workflows/.github/workflows/release_charm_pr.yaml@v49.0.1
110+
with:
111+
track: ${{ needs.get-charm-paths-track.outputs.track }}
112+
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
113+
path-to-charm-directory: ${{ matrix.charm }}
114+
secrets:
115+
charmhub-token: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
116+
permissions:
117+
actions: read
118+
contents: read
119+
120+
integration:
121+
name: Integration tests
122+
needs:
123+
- build
124+
runs-on: ubuntu-24.04
125+
strategy:
126+
fail-fast: false
127+
matrix:
128+
charm: [kubeflow-dashboard]
129+
test-type: [integration, integration-ambient]
130+
steps:
131+
- uses: actions/checkout@v4
132+
133+
- name: Install dependencies
134+
run: pipx install tox
135+
136+
- name: Setup environment
137+
run: |
138+
sudo apt-get remove -y docker-ce docker-ce-cli containerd.io
139+
sudo rm -rf /run/containerd
140+
sudo snap install concierge --classic
141+
sudo concierge prepare --trace
142+
143+
- name: Configure Cilium for Canonical K8s
144+
if: matrix.test-type == 'integration-ambient'
145+
run: |
146+
# for context, see https://docs.cilium.io/en/stable/network/servicemesh/istio/
147+
kubectl -n kube-system patch configmap cilium-config --type merge --patch '{"data":{"bpf-lb-sock-hostns-only":"true"}}'
148+
kubectl -n kube-system patch configmap cilium-config --type merge --patch '{"data":{"cni-exclusive":"false"}}'
149+
kubectl -n kube-system rollout restart daemonset cilium
150+
151+
- name: Download packed charm(s)
152+
id: download-charms
153+
timeout-minutes: 5
154+
uses: actions/download-artifact@v4
155+
with:
156+
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
157+
merge-multiple: true
158+
159+
- name: Integration tests
160+
run: |
161+
tox -vve ${{ matrix.test-type }} -- --model testing --charm-path=${{ github.workspace }}/${{ matrix.charm }}_ubuntu@24.04-amd64.charm
162+
163+
# On failure, capture debugging resources
164+
- name: Get juju status
165+
run: juju status
166+
if: always()
167+
168+
- uses: canonical/kubeflow-ci/actions/dump-charm-debug-artifacts@main
169+
if: failure()

.github/workflows/get-charm-paths.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/integrate.yaml

Lines changed: 0 additions & 73 deletions
This file was deleted.

.github/workflows/on_pull_request.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: On Pull Request
22

33
# On pull_request, we:
44
# * create backport labels if it is against main, only when the PR is opened/reopened
5-
# * always publish to charmhub at latest/edge/branchname
6-
# * always run tests
75

86
on:
97
pull_request:
@@ -19,13 +17,3 @@ jobs:
1917
track_file_path: ".github/automatic_backport_tracks.yaml"
2018
label_prefix: "backport "
2119

22-
tests:
23-
name: Run Tests
24-
uses: ./.github/workflows/integrate.yaml
25-
secrets: inherit
26-
27-
# publish runs in parallel with tests, as we always publish in this situation
28-
publish-charm:
29-
name: Publish Charm
30-
uses: ./.github/workflows/publish.yaml
31-
secrets: inherit

.github/workflows/on_push.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/promote.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# reusable workflow triggered manually
2+
name: Promote charm to other tracks and channels
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
destination-channel:
8+
description: 'Destination Channel'
9+
required: true
10+
origin-channel:
11+
description: 'Origin Channel'
12+
required: true
13+
charm-name:
14+
description: 'Charm subdirectory name'
15+
required: true
16+
17+
jobs:
18+
promote-charm:
19+
name: Promote charm
20+
runs-on: ubuntu-24.04
21+
env:
22+
CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
23+
steps:
24+
- name: Install charmcraft
25+
run: |
26+
sudo snap install charmcraft --classic --channel latest/stable
27+
- name: Run charmcraft promote
28+
run: |
29+
charmcraft promote --name ${{ github.event.inputs.charm-name }} \
30+
--from-channel ${{ github.event.inputs.origin-channel }} \
31+
--to-channel ${{ github.event.inputs.destination-channel }} \
32+
--yes

0 commit comments

Comments
 (0)