Skip to content

Commit

Permalink
ci, tests: pass charm artefacts to deploy and test charms (#640)
Browse files Browse the repository at this point in the history
* ci, tests: pass charm artefacts to deploy and test charms

This commit enables the "--charm-path" option to pass .charm artefacts
to be deployed and tested at an individual level.
This change enables the option to pass pre-built charms to the tests
to avoid building them on the same test. It also ensures compatibility
with the build_charm.py reusable workflow (from canonical/data-platform-workflows).

Fixes: #639

Use single (cached) build for integration tests & release

Fix hardcoded path for `platforms` syntax

skip: remove duplicated download-charms

remove workflow dispatch from release.yaml not needed

add description for outputs

rename get charm paths job and channel output

skip: rename job in needs

pin quality checks back to main due to merging canonical/charmed-kubeflow-workflows#95

Use stage instead of prime in charmcraft files part (#658)
  • Loading branch information
DnPlas authored and NohaIhab committed Jan 24, 2025
1 parent 1a58b13 commit 11af2a7
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 281 deletions.
87 changes: 71 additions & 16 deletions .github/workflows/integrate.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# reusable workflow triggered by other actions
name: CI
name: Tests

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
schedule:
- cron: '0 8 * * TUE'
# Triggered on push by .github/workflows/release.yaml
workflow_call:
secrets:
CHARMCRAFT_CREDENTIALS:
required: true
inputs:
outputs:
artifact-prefix:
description: |
Prefix for charm package GitHub artifact(s)
Use canonical/data-platform-workflows build_charm.yaml to build the charm(s)
required: true
type: string
description: build_charm.yaml `artifact-prefix` output
value: ${{ jobs.build.outputs.artifact-prefix }}
charm-paths:
description: paths for all charms in this repo
value: ${{ jobs.get-charm-paths-channel.outputs.charm-paths }}
channel:
description: Charmhub channel the charms are released to
value: ${{ jobs.get-charm-paths-channel.outputs.charm-channel }}

jobs:
lib-check:
Expand All @@ -29,7 +35,7 @@ jobs:
- kfp-ui
- kfp-viewer
- kfp-viz
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@kf-6725-use-charmcraft-3.x-edge-check-libs
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@main
secrets: inherit
with:
charm-path: ./charms/${{ matrix.charm }}
Expand Down Expand Up @@ -94,9 +100,58 @@ jobs:
# So the model's name must be kubeflow
# See: https://github.com/kubeflow/kubeflow/issues/6136
model: kubeflow


get-charm-paths-channel:
name: Get charm paths and charmhub channel
runs-on: ubuntu-latest
outputs:
charm-paths: ${{ steps.get-charm-paths.outputs.charm-paths }}
charm-channel: ${{ steps.select-channel.outputs.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get paths for all charms in this repo
id: get-charm-paths
uses: canonical/kubeflow-ci/actions/get-charm-paths@main
- name: Select charmhub channel
uses: canonical/charming-actions/[email protected]
id: select-channel

build:
strategy:
matrix:
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
name: Build charm | ${{ matrix.charm }}
needs:
- get-charm-paths-channel
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
with:
charmcraft-snap-channel: latest/candidate # TODO: remove after charmcraft 3.3 stable release
path-to-charm-directory: ${{ matrix.charm }}

release:
strategy:
matrix:
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
name: Release charm to Charmhub branch | ${{ matrix.charm }}
if: ${{ github.event_name == 'pull_request' }}
needs:
- build
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
with:
charmcraft-snap-channel: latest/candidate # TODO: remove after charmcraft 3.3 stable release
channel: ${{ needs.get-charm-paths-channel.outputs.charm-channel }}
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
path-to-charm-directory: ${{ matrix.charm }}
create-git-tags: false
secrets:
charmhub-token: ${{ secrets.CHARMCRAFT_CREDENTIALS }}

integration:
name: Integration tests (microk8s)
needs:
- build
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand Down Expand Up @@ -134,7 +189,7 @@ jobs:
timeout-minutes: 5
uses: actions/download-artifact@v4
with:
pattern: ${{ inputs.artifact-prefix }}-*
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
merge-multiple: true

- name: Integration tests
Expand All @@ -143,7 +198,7 @@ jobs:
# https://github.com/canonical/kfp-operators/issues/389
juju add-model kubeflow
# Pass the path where the charm artefact is downloaded to the tox command
# FIXME: Right now the complete path is half hardcoded to <charm name>_ubuntu-20.04-amd64.charm
# FIXME: Right now the complete path is half hardcoded to <charm name>_ubuntu@20.04-amd64.charm
# We need to find a better way to dynamically get this value
sg snap_microk8s -c "tox -e ${{ matrix.charm }}-integration -- --model kubeflow --charm-path=${{ github.workspace }}/charms/${{ matrix.charm }}/${{ matrix.charm }}[email protected]"
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/get-charm-paths.sh

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/on_pull_request.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/on_push.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/promote.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# reusable workflow triggered manually
name: Promote charm to other tracks and channels

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel'
required: true
origin-channel:
description: 'Origin Channel'
required: true
charm-name:
description: 'Charm subdirectory name'
required: true

jobs:
promote-charm:
name: Promote charm
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Release charm to channel
# TODO: use canonical/charming-actions/promote-charm?
uses: canonical/charming-actions/[email protected]
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
destination-channel: ${{ github.event.inputs.destination-channel }}
origin-channel: ${{ github.event.inputs.origin-channel }}
tag-prefix: ${{ github.event.inputs.charm-name }}
charm-path: charms/${{ github.event.inputs.charm-name}}
94 changes: 0 additions & 94 deletions .github/workflows/publish.yaml

This file was deleted.

Loading

0 comments on commit 11af2a7

Please sign in to comment.