Skip to content

Commit 7f01ab6

Browse files
authored
refactor(ci): use data-platform workflows (#286)
* build: refactor charmcraft.yaml to use ST124 notation (#282) Refactor charmcraft.yaml files to enable the usage of charmcraft-cache and data-platform-workflows in general. Close #271 * refactor(ci): use data-platform-workflows in on_pull/push workflows (#284) * refactor(ci): use data-platform-workflows in on_pull/push workflows * Enable the usage of `build_charm.yaml` workflow, which allows independent and cached charm builds, making the CI more efficient and fast. * Refactor the tests and the integrate workflow to be able to use the charm artefacts generated by the `build_charm.yaml` workflow: - Refactor integrate.yaml to be ci.yaml, a workflow that now takes care for the whole pipeline from generating charm paths, to building, to testing, and then releasing. This change will replace on_pull_request.yaml. - on_push.yaml is now replaced entirely by release, which will run on pushes to main or track/* branches. This workflow is in charge of building -> testing -> releasing. - Refactor individual and repository level integration tests to be able to use charm artefacts besides building them. Close #272 * refactor(ci): Replace release.yaml with promote.yaml (#285) * Add promote.yaml workflow to replace the old release.yaml workflow_dispatch funcionality. * Remove publish.yaml workflow as the release process is handled by the recently refactor release.yaml. Fix #277
1 parent 00c211a commit 7f01ab6

File tree

15 files changed

+436
-287
lines changed

15 files changed

+436
-287
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,55 @@
1-
# reusable workflow triggered by other actions
21
name: CI
32

3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
47
on:
8+
pull_request:
9+
schedule:
10+
- cron: '0 8 * * TUE'
11+
# Triggered on push by .github/workflows/release.yaml
512
workflow_call:
6-
secrets:
7-
CHARMCRAFT_CREDENTIALS:
8-
required: true
13+
outputs:
14+
artifact-prefix:
15+
description: build_charm.yaml `artifact-prefix` output
16+
value: ${{ jobs.build.outputs.artifact-prefix }}
17+
charm-paths:
18+
description: paths for all charms in this repo
19+
value: ${{ jobs.get-charm-paths-channel.outputs.charm-paths }}
20+
channel:
21+
description: Charmhub channel the charms are released to
22+
value: ${{ jobs.get-charm-paths-channel.outputs.charm-channel }}
923

1024
jobs:
25+
get-charm-paths-channel:
26+
name: Get charm paths and charmhub channel
27+
runs-on: ubuntu-latest
28+
outputs:
29+
charm-paths: ${{ steps.get-charm-paths.outputs.charm-paths }}
30+
charm-channel: ${{ steps.select-channel.outputs.name }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
- name: Get paths for all charms in this repo
36+
id: get-charm-paths
37+
uses: canonical/kubeflow-ci/actions/get-charm-paths@main
38+
- name: Select charmhub channel
39+
uses: canonical/charming-actions/[email protected]
40+
id: select-channel
41+
1142
lib-check:
1243
name: Check libraries
44+
needs:
45+
- get-charm-paths-channel
46+
strategy:
47+
matrix:
48+
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
1349
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@main
1450
secrets: inherit
1551
with:
16-
charm-path: "."
52+
charm-path: ${{ matrix.charm }}
1753

1854
lint:
1955
name: Lint Code
@@ -23,9 +59,10 @@ jobs:
2359
matrix:
2460
charm: [operator, serving, eventing]
2561
steps:
26-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
2763
- run: pip install tox
2864
- run: tox -e ${{ matrix.charm }}-lint
65+
2966
unit:
3067
name: Unit Test
3168
runs-on: ubuntu-20.04
@@ -34,19 +71,21 @@ jobs:
3471
matrix:
3572
charm: [operator, serving, eventing]
3673
steps:
37-
- uses: actions/checkout@v3
74+
- uses: actions/checkout@v4
3875
- run: pip install tox
3976
- run: tox -e ${{ matrix.charm }}-unit
4077

4178
terraform-checks:
4279
name: Terraform
80+
needs:
81+
- get-charm-paths-channel
4382
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@main
4483
strategy:
4584
fail-fast: false
4685
matrix:
47-
charm: [operator, serving, eventing]
86+
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
4887
with:
49-
charm-path: ./charms/knative-${{ matrix.charm }}
88+
charm-path: ${{ matrix.charm }}
5089
# Skipping the Terraform apply check as knative-eventing and knative-serving
5190
# go to Error when knative-operator is not deployed, instead of the expected
5291
# Blocked or Active. This is currently a limitation of the Terraform re-usable
@@ -55,10 +94,22 @@ jobs:
5594
# See https://github.com/canonical/knative-operators/issues/156
5695
apply: false
5796

97+
build:
98+
strategy:
99+
matrix:
100+
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
101+
name: Build charm | ${{ matrix.charm }}
102+
needs:
103+
- get-charm-paths-channel
104+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
105+
with:
106+
path-to-charm-directory: ${{ matrix.charm }}
107+
58108
integration-charm-deployment:
59109
name: Integration Test
110+
needs:
111+
- build
60112
runs-on: ubuntu-20.04
61-
62113
steps:
63114
# Ideally we'd use self-hosted runners, but this effort is still not stable
64115
# This action will remove unused software (dotnet, haskell, android libs, codeql,
@@ -69,21 +120,28 @@ jobs:
69120
uses: jlumbroso/[email protected]
70121

71122
- name: Check out repo
72-
uses: actions/checkout@v3
123+
uses: actions/checkout@v4
73124

74125
- name: Setup operator environment
75126
uses: charmed-kubernetes/actions-operator@main
76127
with:
77128
provider: microk8s
78129
channel: 1.31-strict/stable
79130
juju-channel: 3.6/stable
80-
charmcraft-channel: 3.x/stable
81131
microk8s-addons: "dns storage rbac metallb:10.64.140.43-10.64.140.49"
82132

133+
- name: Download packed charm(s)
134+
id: download-charms
135+
timeout-minutes: 5
136+
uses: actions/download-artifact@v4
137+
with:
138+
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
139+
merge-multiple: true
140+
83141
- name: Run integration tests
84142
run: |
85143
sg snap_microk8s -c "juju add-model knative-test"
86-
sg snap_microk8s -c "tox -vve integration -- --model knative-test"
144+
sg snap_microk8s -c "tox -vve integration -- --model knative-test --charms-path=${{ github.workspace }}/charms"
87145
88146
- run: kubectl get all -A
89147
if: failure()
@@ -95,12 +153,13 @@ jobs:
95153
if: failure()
96154

97155
- uses: canonical/kubeflow-ci/actions/dump-charm-debug-artifacts@main
98-
if: always()
156+
if: failure()
99157

100158
integration-observability:
101159
name: Observability Integration Test
160+
needs:
161+
- build
102162
runs-on: ubuntu-20.04
103-
104163
steps:
105164
# Ideally we'd use self-hosted runners, but this effort is still not stable
106165
# This action will remove unused software (dotnet, haskell, android libs, codeql,
@@ -111,25 +170,32 @@ jobs:
111170
uses: jlumbroso/[email protected]
112171

113172
- name: Check out repo
114-
uses: actions/checkout@v3
173+
uses: actions/checkout@v4
115174

116175
- name: Setup operator environment
117176
uses: charmed-kubernetes/actions-operator@main
118177
with:
119178
provider: microk8s
120179
channel: 1.31-strict/stable
121180
juju-channel: 3.6/stable
122-
charmcraft-channel: 3.x/stable
181+
182+
- name: Download packed charm(s)
183+
id: download-charms
184+
timeout-minutes: 5
185+
uses: actions/download-artifact@v4
186+
with:
187+
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
188+
merge-multiple: true
123189

124190
- name: Run integration tests
125191
run: |
126192
sg snap_microk8s -c "juju add-model cos-test"
127-
sg snap_microk8s -c "tox -vve cos-integration -- --model cos-test"
193+
sg snap_microk8s -c "tox -vve cos-integration -- --model cos-test --charms-path=${{ github.workspace }}/charms"
128194
129-
- run: kubectl get pod/prometheus-k8s-0 -n knative-test -o=jsonpath='{.status}'
195+
- run: kubectl get pod/prometheus-k8s-0 -n cos-test -o=jsonpath='{.status}'
130196
if: failure()
131197

132-
- run: kubectl get pod/knative-operator-0 -nknative-test -o=jsonpath='{.status}'
198+
- run: kubectl get pod/knative-operator-0 -n cos-test -o=jsonpath='{.status}'
133199
if: failure()
134200

135201
- run: kubectl get all -A
@@ -139,4 +205,22 @@ jobs:
139205
if: failure()
140206

141207
- uses: canonical/kubeflow-ci/actions/dump-charm-debug-artifacts@main
142-
if: always()
208+
if: failure()
209+
210+
release:
211+
strategy:
212+
matrix:
213+
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
214+
name: Release charm to Charmhub branch | ${{ matrix.charm }}
215+
if: ${{ github.event_name == 'pull_request' }}
216+
needs:
217+
- get-charm-paths-channel
218+
- build
219+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
220+
with:
221+
channel: ${{ needs.get-charm-paths-channel.outputs.charm-channel }}
222+
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
223+
path-to-charm-directory: ${{ matrix.charm }}
224+
create-git-tags: false
225+
secrets:
226+
charmhub-token: ${{ secrets.CHARMCRAFT_CREDENTIALS }}

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

-30
This file was deleted.

.github/workflows/on_pull_request.yaml

-21
This file was deleted.

.github/workflows/on_push.yaml

-28
This file was deleted.

.github/workflows/promote.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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-20.04
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Release charm to channel
24+
uses: canonical/charming-actions/[email protected]
25+
with:
26+
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
destination-channel: ${{ github.event.inputs.destination-channel }}
29+
origin-channel: ${{ github.event.inputs.origin-channel }}
30+
tag-prefix: ${{ github.event.inputs.charm-name }}
31+
charm-path: charms/${{ github.event.inputs.charm-name}}

0 commit comments

Comments
 (0)