|
| 1 | +name: CI |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + schedule: |
| 10 | + - cron: '0 8 * * TUE' |
| 11 | + workflow_call: |
| 12 | + outputs: |
| 13 | + artifact-prefix: |
| 14 | + description: build_charm.yaml `artifact-prefix` output |
| 15 | + value: ${{ jobs.build.outputs.artifact-prefix }} |
| 16 | + charm-paths: |
| 17 | + description: paths for all charms in this repo |
| 18 | + value: ${{ jobs.get-charm-paths-track.outputs.charm-paths }} |
| 19 | + track: |
| 20 | + description: Charmhub track determined from branch name |
| 21 | + value: ${{ jobs.get-charm-paths-track.outputs.track }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + get-charm-paths-track: |
| 25 | + name: Get charm paths and track |
| 26 | + runs-on: ubuntu-latest |
| 27 | + outputs: |
| 28 | + charm-paths: ${{ steps.get-charm-paths.outputs.charm-paths }} |
| 29 | + track: ${{ steps.determine-track.outputs.track }} |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + - name: Get paths for all charms in this repo |
| 35 | + id: get-charm-paths |
| 36 | + uses: canonical/kubeflow-ci/actions/get-charm-paths@main |
| 37 | + - name: Determine track |
| 38 | + id: determine-track |
| 39 | + shell: python |
| 40 | + run: | |
| 41 | + import os |
| 42 | +
|
| 43 | + if "${{ github.event_name }}" == "pull_request": |
| 44 | + ref = "${{ github.base_ref }}" |
| 45 | + else: |
| 46 | + ref = "${{ github.ref_name }}" |
| 47 | +
|
| 48 | + if ref.startswith("track/"): |
| 49 | + track = ref.removeprefix("track/") |
| 50 | + else: |
| 51 | + track = "latest" |
| 52 | +
|
| 53 | + with open(os.environ["GITHUB_OUTPUT"], "a") as f: |
| 54 | + f.write(f"track={track}\n") |
| 55 | +
|
| 56 | + print(f"Track: {track}") |
| 57 | +
|
| 58 | + lint: |
| 59 | + name: Lint |
| 60 | + runs-on: ubuntu-24.04 |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + - run: pipx install tox |
| 64 | + - run: tox -vve lint |
| 65 | + |
| 66 | + unit: |
| 67 | + name: Unit tests |
| 68 | + runs-on: ubuntu-24.04 |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + - run: pipx install tox |
| 72 | + - run: tox -e unit |
| 73 | + |
| 74 | + terraform-checks: |
| 75 | + name: Terraform |
| 76 | + needs: |
| 77 | + - get-charm-paths-track |
| 78 | + uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@main |
| 79 | + strategy: |
| 80 | + matrix: |
| 81 | + charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }} |
| 82 | + with: |
| 83 | + charm-path: ${{ matrix.charm }} |
| 84 | + |
| 85 | + build: |
| 86 | + strategy: |
| 87 | + matrix: |
| 88 | + charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }} |
| 89 | + name: Build charm | ${{ matrix.charm }} |
| 90 | + needs: |
| 91 | + - get-charm-paths-track |
| 92 | + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v49.0.1 |
| 93 | + with: |
| 94 | + path-to-charm-directory: ${{ matrix.charm }} |
| 95 | + cache: true |
| 96 | + permissions: |
| 97 | + actions: read |
| 98 | + contents: read |
| 99 | + |
| 100 | + release: |
| 101 | + strategy: |
| 102 | + matrix: |
| 103 | + charm: ${{ fromJSON(needs.get-charm-paths-track.outputs.charm-paths) }} |
| 104 | + name: Release charm to Charmhub branch | ${{ matrix.charm }} |
| 105 | + if: ${{ github.event_name == 'pull_request' }} |
| 106 | + needs: |
| 107 | + - get-charm-paths-track |
| 108 | + - build |
| 109 | + uses: canonical/data-platform-workflows/.github/workflows/release_charm_pr.yaml@v49.0.1 |
| 110 | + with: |
| 111 | + track: ${{ needs.get-charm-paths-track.outputs.track }} |
| 112 | + artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} |
| 113 | + path-to-charm-directory: ${{ matrix.charm }} |
| 114 | + secrets: |
| 115 | + charmhub-token: ${{ secrets.CHARMCRAFT_CREDENTIALS }} |
| 116 | + permissions: |
| 117 | + actions: read |
| 118 | + contents: read |
| 119 | + |
| 120 | + integration: |
| 121 | + name: Integration tests |
| 122 | + needs: |
| 123 | + - build |
| 124 | + runs-on: ubuntu-24.04 |
| 125 | + strategy: |
| 126 | + fail-fast: false |
| 127 | + matrix: |
| 128 | + charm: [kubeflow-dashboard] |
| 129 | + test-type: [integration] |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v4 |
| 132 | + |
| 133 | + - name: Install dependencies |
| 134 | + run: pipx install tox |
| 135 | + |
| 136 | + - name: Setup environment |
| 137 | + run: | |
| 138 | + sudo apt-get remove -y docker-ce docker-ce-cli containerd.io |
| 139 | + sudo rm -rf /run/containerd |
| 140 | + sudo snap install concierge --classic |
| 141 | + sudo concierge prepare --trace |
| 142 | +
|
| 143 | + - name: Download packed charm(s) |
| 144 | + id: download-charms |
| 145 | + timeout-minutes: 5 |
| 146 | + uses: actions/download-artifact@v4 |
| 147 | + with: |
| 148 | + pattern: ${{ needs.build.outputs.artifact-prefix }}-* |
| 149 | + merge-multiple: true |
| 150 | + |
| 151 | + - name: Integration tests |
| 152 | + run: | |
| 153 | + tox -vve ${{ matrix.test-type }} -- --model kubeflow --charm-path=${{ github.workspace }}/${{ matrix.charm }}_ubuntu@24.04-amd64.charm |
| 154 | +
|
| 155 | + # On failure, capture debugging resources |
| 156 | + - name: Get juju status |
| 157 | + run: juju status |
| 158 | + if: always() |
| 159 | + |
| 160 | + - uses: canonical/kubeflow-ci/actions/dump-charm-debug-artifacts@main |
| 161 | + if: failure() |
0 commit comments