From c135d403a5d3e66fc4f03ed7c8cb8c4b61f8b48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Siwek?= <71661357+RafalSiwek@users.noreply.github.com> Date: Thu, 22 Feb 2024 20:41:26 +0100 Subject: [PATCH] Migrate build to ubuntu 22 04 (#12) * define bundles * update readme * migrate build to ubuntu 22.04 * update charmcratf.yaml * update publishing job * use ubuntu-latest for unit,fmt,lint * support linting * migrate setting output * bump action version * bump publish actions versions --- .github/workflows/integrate.yaml | 16 +++--- .github/workflows/publish.yaml | 89 +++++++++++++++++++++++++++++--- .github/workflows/release.yaml | 2 +- charmcraft.yaml | 6 +-- 4 files changed, 94 insertions(+), 19 deletions(-) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 3d3f0c1..9eb77e6 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -10,10 +10,10 @@ on: jobs: lib-check: name: Check libraries - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Check libs @@ -28,7 +28,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies run: sudo apt-get install python3-pip tox @@ -38,11 +38,11 @@ jobs: unit: name: Unit Test - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies run: sudo apt-get install python3-pip tox @@ -52,7 +52,7 @@ jobs: integration: name: Integration tests (microk8s) - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Workflow Telemetry uses: catchpoint/workflow-telemetry-action@v1.8.7 @@ -67,7 +67,7 @@ jobs: remove-android: "true" remove-codeql: "true" remove-docker-images: "true" - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup operator environment uses: charmed-kubernetes/actions-operator@1.1.0 with: @@ -82,11 +82,9 @@ jobs: # On failure, capture debugging resources - name: Get all run: kubectl get all -A - if: failure() - name: Get juju status run: juju status - if: failure() - name: Get juju debug logs run: juju debug-log --limit 100 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2bb03b0..f4282ff 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,15 +1,92 @@ -# reusable workflow for publishing all charms in this repo +# reusable workflow for publishing all charms in a repo name: Publish on: workflow_call: + inputs: + source_branch: + description: Github branch from this repo to publish. If blank, will use the default branch + default: "" + required: false + type: string secrets: CHARMCRAFT_CREDENTIALS: required: true + workflow_dispatch: + inputs: + destination_channel: + description: CharmHub channel to publish to + required: false + default: "latest/edge" + type: string + source_branch: + description: Github branch from this repo to publish. If blank, will use the default branch + required: false + default: "" + type: string jobs: - publish: - name: Publish - uses: canonical/charmed-kubeflow-workflows/.github/workflows/_publish.yaml@main - secrets: - CHARMCRAFT_CREDENTIALS: ${{ secrets.CHARMCRAFT_CREDENTIALS }} + get-charm-paths: + # forks don't have access to keyrings and cannot publish, we just skip these jobs from forks + if: github.event.pull_request.head.repo.fork == false + + name: Generate the Charm Matrix content (bash) + runs-on: ubuntu-22.04 + outputs: + charm_paths: ${{ steps.get-charm-paths.outputs.charm-paths }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get paths for all charms in this repo + id: get-charm-paths + uses: ca-scribner/github-actions-recipes/get-charm-paths@master + + publish-charm: + name: Publish Charm + runs-on: ubuntu-22.04 + needs: get-charm-paths + strategy: + fail-fast: false + matrix: + charm-path: ${{ fromJson(needs.get-charm-paths.outputs.charm_paths) }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ inputs.source_branch }} + + - name: Select charmhub channel + uses: canonical/charming-actions/channel@2.4.0 + id: select-channel + if: ${{ inputs.destination_channel == '' }} + + # Combine inputs from different sources to a single canonical value so later steps don't + # need logic for picking the right one + - name: Parse and combine inputs + id: parse-inputs + run: | + # destination_channel + destination_channel="${{ inputs.destination_channel || steps.select-channel.outputs.name }}" + echo "setting output of destination_channel=$destination_channel" + echo "destination_channel=$destination_channel" >> $GITHUB_OUTPUT + # tag_prefix + # if charm_path = ./ --> tag_prefix = '' (null) + # if charm_path != ./some-charm (eg: a charm in a ./charms dir) --> tag_prefix = 'some-charm' + if [ ${{ matrix.charm-path }} == './' ]; then + tag_prefix='' + else + tag_prefix=$(basename ${{ matrix.charm-path }} ) + fi + echo "setting output of tag_prefix=$tag_prefix" + echo "tag_prefix=$tag_prefix" >> $GITHUB_OUTPUT + - name: Upload charm to charmhub + uses: canonical/charming-actions/upload-charm@2.4.0 + with: + credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }} + github-token: ${{ secrets.GITHUB_TOKEN }} + charm-path: ${{ matrix.charm-path }} + channel: ${{ steps.parse-inputs.outputs.destination_channel }} + tag-prefix: ${{ steps.parse-inputs.outputs.tag_prefix }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f04e3e6..00b8243 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,7 @@ on: jobs: promote-charm: name: Promote charm - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - name: Release charm to channel diff --git a/charmcraft.yaml b/charmcraft.yaml index 2d0960d..7246aa1 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -1,11 +1,11 @@ -type: "charm" +type: charm bases: - build-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" run-on: - name: "ubuntu" - channel: "20.04" + channel: "22.04" parts: charm: charm-python-packages: [setuptools, pip]