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
224 changes: 224 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# 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-ambient
- 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: Configure Cilium for Canonical K8s
if: matrix.tox-environment == 'integration-ambient'
run: |
# for context, see https://docs.cilium.io/en/stable/network/servicemesh/istio/
kubectl -n kube-system patch configmap cilium-config --type merge --patch '{"data":{"bpf-lb-sock-hostns-only":"true"}}'
kubectl -n kube-system patch configmap cilium-config --type merge --patch '{"data":{"cni-exclusive":"false"}}'
kubectl -n kube-system rollout restart daemonset cilium

- 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.

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

This file was deleted.

Loading
Loading