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
215 changes: 215 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# reusable workflow triggered by other actions
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:
- name: Check out code
uses: actions/checkout@v4

- name: Install dependencies
run: pipx install tox

- name: Lint code
run: tox -vve lint

unit:
name: Unit
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install dependencies
run: pipx install tox

- name: Run unit tests
run: tox -e unit

- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage
path: training-operator-cov_html
if: failure()

terraform-checks:
name: Terraform
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@main
with:
charm-path: .

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
charmcraft-snap-channel: 3.x/stable
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
needs:
- build
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
tox-environment:
- integration
- integration-with-profiles
steps:
- name: Maximise GH runner space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be

- name: Check out code
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: Fetch charm
uses: actions/download-artifact@v4
with:
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
merge-multiple: true
path: built/

- name: Get charm path
id: charm-path
run: echo "charm_path=$(find built/ -name '*.charm' -type f -print)" >> $GITHUB_OUTPUT

- name: Run integration tests
run: tox -e ${{ matrix.tox-environment }} -- --model testing --charm-path="${{ steps.charm-path.outputs.charm_path }}"

- name: Capture k8s resources on failure
run: |
set -eux
kubectl get all -A
kubectl get pods -n testing --show-labels
kubectl get crds
if: failure()

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

- name: Get validatingwebhookconfigurations
run: kubectl get validatingwebhookconfigurations validator.training-operator.kubeflow.org -oyaml
if: failure()

- name: Get secret
run: kubectl get secret -n testing training-operator-webhook-cert -oyaml
if: failure()

- name: Describe operator pod
run: kubectl describe pod -n testing -l app.kubernetes.io/name=training-operator
if: failure()

- name: Describe workload pod
run: kubectl describe pod -n testing -l control-plane=testing-training-operator
if: failure()

- name: Get pods
run: kubectl get pods -A
if: failure()

- name: Get operator logs
run: kubectl logs --tail 100 -n testing -l app.kubernetes.io/name=training-operator -c charm
if: failure()

- name: Get workload logs
run: kubectl logs --tail 100 -n testing -l control-plane=testing-training-operator -c training-operator
if: failure()
30 changes: 0 additions & 30 deletions .github/workflows/get-charm-paths.sh

This file was deleted.

9 changes: 0 additions & 9 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ jobs:
matrix:
tox-environment:
- integration
- integration-ambient
- integration-with-profiles
steps:
- name: Maximise GH runner space
Expand Down Expand Up @@ -88,14 +87,6 @@ jobs:
id: charm-path
run: echo "charm_path=$(find built/ -name '*.charm' -type f -print)" >> $GITHUB_OUTPUT

- name: Configure Cilium for Canonical K8s
if: matrix.tox-environment == 'integration-ambient'
run: |
# Configure Cilium for Canonical K8s to work with Charmed Istio (Ambient mode)
# See https://canonical-service-mesh-documentation.readthedocs-hosted.com/en/latest/how-to/use-charmed-istio-with-canonical-kubernetes/
kubectl -n kube-system patch configmap cilium-config --type merge --patch '{"data":{"bpf-lb-sock-hostns-only":"true"}}'
kubectl -n kube-system rollout restart daemonset cilium

- name: Run integration tests
run: tox -e ${{ matrix.tox-environment }} -- --model testing --charm-path="${{ steps.charm-path.outputs.charm_path }}"

Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: On Pull Request

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

on:
pull_request:

jobs:
<<<<<<< HEAD
build-charm:
name: Build charm
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -48,3 +48,14 @@ jobs:
uses: ./.github/workflows/publish.yaml
secrets: inherit

=======

populate-labels:
name: Populate labels
if: github.base_ref == 'main' && (github.event.action == 'opened' || github.event.action == 'reopened')
uses: canonical/charmed-kubeflow-workflows/.github/workflows/populate-labels.yaml@main
secrets: inherit
with:
track_file_path: ".github/automatic_backport_tracks.yaml"
label_prefix: "backport "
>>>>>>> f98583d (chore: Update CI to use charmcraftcache (#305))
54 changes: 0 additions & 54 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