Skip to content

ci: refactor using data platform workflows #27

ci: refactor using data platform workflows

ci: refactor using data platform workflows #27

Workflow file for this run

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-channel.outputs.charm-paths }}
channel:
description: Charmhub channel the charms are released to
value: ${{ jobs.get-charm-paths-channel.outputs.charm-channel }}
jobs:
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
lib-check:
name: Check libraries
needs:
- get-charm-paths-channel
strategy:
matrix:
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@main
secrets: inherit
with:
charm-path: ${{ matrix.charm }}
lint:
name: Lint
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
charm:
- jupyter-controller
- jupyter-ui
steps:
- uses: actions/checkout@v3
- run: python3 -m pip install tox
- run: tox -e ${{ matrix.charm }}-lint
unit:
name: Unit tests
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
charm:
- jupyter-controller
- jupyter-ui
steps:
- uses: actions/checkout@v3
- run: python3 -m pip install tox
- run: tox -e ${{ matrix.charm }}-unit
terraform-checks:
name: Terraform
needs:
- get-charm-paths-channel
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@main
strategy:
matrix:
charm: ${{ fromJSON(needs.get-charm-paths-channel.outputs.charm-paths) }}
with:
charm-path: ${{ matrix.charm }}
# Skipping the Terraform apply check as the tensorboard-controller goes to Waiting status
# instead of the expected Blocked or Active. This is currently a limitation of the
# Terraform re-usable workflows in canonical/charmed-kubeflow-workflows
# See https://github.com/canonical/charmed-kubeflow-workflows/issues/65
apply: false
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:
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:
- get-charm-paths-channel
- build
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
with:
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
matrix:
charm:
- jupyter-controller
- jupyter-ui
steps:
- uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
channel: 1.31-strict/stable
microk8s-addons: "dns storage rbac metallb:10.64.140.43-10.64.140.49"
juju-channel: 3.6/stable
- 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: |
# Requires the model to be called kubeflow due to
# 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>[email protected]
# 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]"
test-bundle:
name: Test the bundle
needs: build
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
channel: 1.31-strict/stable
juju-channel: 3.6/stable
microk8s-addons: "dns hostpath-storage rbac metallb:10.64.140.43-10.64.140.49"
- 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: Run test
run: |
sudo apt install tar wget
# Install firefox-geckodriver from source to avoid issues
wget https://github.com/mozilla/geckodriver/releases/download/v0.28.0/geckodriver-v0.28.0-linux64.tar.gz
tar xf geckodriver-v0.28.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin
juju add-model kubeflow
sg snap_microk8s -c "tox -e integration -- --model kubeflow --charms-path=${{ github.workspace }}/charms/"
- run: kubectl get all -A
if: failure()
- run: kubectl get notebooks -A
if: failure()
- run: kubectl get pods -A -oyaml
if: failure()
- run: juju status
if: failure()
- name: Get jupyter-controller workload logs
run: kubectl logs --tail 100 -nkubeflow -lapp.kubernetes.io/name=jupyter-controller
if: failure()
- name: Get jupyter-controller operator logs
run: kubectl logs --tail 100 -nkubeflow -loperator.juju.is/name=jupyter-controller
if: failure()
- name: Get jupyter-ui workload logs
run: kubectl logs --tail 100 -nkubeflow -lapp.kubernetes.io/name=jupyter-ui
if: failure()
- name: Get jupyter-ui operator logs
run: kubectl logs --tail 100 -nkubeflow -loperator.juju.is/name=jupyter-ui
if: failure()
- name: Generate inspect tarball
run: >
sg microk8s <<EOF
microk8s inspect | \
grep -Po "Report tarball is at \K.+" | \
xargs -I {} cp {} inspection-report-${{ strategy.job-index }}.tar.gz
EOF
if: failure()
- name: Upload inspect tarball
uses: actions/upload-artifact@v3
with:
name: inspection-reports
path: ./inspection-report-${{ strategy.job-index }}.tar.gz
if: failure()
- name: Upload selenium screenshots
uses: actions/upload-artifact@v3
with:
name: selenium-screenshots
path: /tmp/selenium-*.png
if: failure()
- name: Upload HAR logs
uses: actions/upload-artifact@v3
with:
name: selenium-har
path: /tmp/selenium-*.har
if: failure()