Skip to content
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
185 changes: 185 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: CI

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:
outputs:
artifact-prefix:
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-track.outputs.charm-paths }}
track:
description: Charmhub track determined from branch name
value: ${{ jobs.get-charm-paths-track.outputs.track }}

jobs:
get-charm-paths-track:
name: Get charm paths and track
runs-on: ubuntu-latest
outputs:
charm-paths: ${{ steps.get-charm-paths.outputs.charm-paths }}
track: ${{ steps.determine-track.outputs.track }}
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: Determine track
id: determine-track
shell: python
run: |
import os

if "${{ github.event_name }}" == "pull_request":
ref = "${{ github.base_ref }}"
else:
ref = "${{ github.ref_name }}"

if ref.startswith("track/"):
track = ref.removeprefix("track/")
else:
track = "latest"

with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"track={track}\n")

print(f"Track: {track}")

lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: pipx install tox
- run: tox -vve lint

unit:
name: Unit tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- run: pipx install tox
- run: tox -e unit

terraform-checks:
name: Terraform
needs:
- get-charm-paths-track
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@main
strategy:
matrix:
charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }}
with:
charm-path: ${{ matrix.charm }}

build:
strategy:
matrix:
charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }}
name: Build charm | ${{ matrix.charm }}
needs:
- get-charm-paths-track
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v49.0.1
with:
path-to-charm-directory: ${{ matrix.charm }}
cache: true
permissions:
actions: read # Needed for GitHub API call to get workflow version (for private repositories)
contents: read

release:
strategy:
matrix:
charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }}
name: Release charm to Charmhub branch | ${{ matrix.charm }}
if: ${{ github.event_name == 'pull_request' }}
needs:
- get-charm-paths-track
- build
uses: canonical/data-platform-workflows/.github/workflows/release_charm_pr.yaml@v49.0.1
with:
track: ${{ needs.get-charm-paths-track.outputs.track }}
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
path-to-charm-directory: ${{ matrix.charm }}
secrets:
charmhub-token: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
permissions:
actions: read # Needed for GitHub API call to get workflow version (for private repositories)
contents: read

integration:
name: Integration tests
needs:
- build
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
charm: [mlmd]
test-type: [integration]
steps:
- name: Maximise GH runner space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be

- uses: actions/checkout@v4

- name: Install dependencies
run: pipx install tox

- name: Setup environment
run: |
sudo apt-get remove -y docker-ce docker-ce-cli containerd.io
sudo rm -rf /run/containerd
sudo snap install concierge --classic
sudo concierge prepare --trace

- name: Download packed charm(s)
id: download-charms
timeout-minutes: 5
uses: actions/download-artifact@v4
with:
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
merge-multiple: true

- name: Integration tests
run: |
# 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@24.04-amd64.charm
# We need to find a better way to dynamically get this value
tox -vve ${{ matrix.test-type }} -- --model testing --charm-path=${{ github.workspace }}/${{ matrix.charm }}_ubuntu@24.04-amd64.charm

# On failure, capture debugging resources
- name: Get all
run: kubectl get all -A
if: failure()

- name: Describe deployments
run: kubectl describe deployments -A
if: failure()

- name: Describe replicasets
run: kubectl describe replicasets -A
if: failure()

- name: Get juju status
run: juju status
if: always()

- name: Get application logs
run: kubectl logs -n testing --tail 1000 -lapp.kubernetes.io/name=mlmd
if: failure()

- name: Get application operator logs
run: kubectl logs -n testing --tail 1000 -ljuju-operator=mlmd
if: failure()
30 changes: 0 additions & 30 deletions .github/workflows/get-charm-paths.sh

This file was deleted.

84 changes: 0 additions & 84 deletions .github/workflows/integrate.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: On Pull Request

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

on:
pull_request:
Expand All @@ -19,13 +17,3 @@ jobs:
track_file_path: ".github/automatic_backport_tracks.yaml"
label_prefix: "backport "

tests:
name: Run Tests
uses: ./.github/workflows/integrate.yaml
secrets: inherit

# publish runs in parallel with tests, as we always publish in this situation
publish-charm:
name: Publish Charm
uses: ./.github/workflows/publish.yaml
secrets: inherit
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-24.04
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
steps:
- name: Install charmcraft
run: |
sudo snap install charmcraft --classic --channel latest/stable
- name: Run charmcraft promote
run: |
charmcraft promote --name ${{ github.event.inputs.charm-name }} \
--from-channel ${{ github.event.inputs.origin-channel }} \
--to-channel ${{ github.event.inputs.destination-channel }} \
--yes
Loading
Loading