From 47af76417cec8d8799dc5efc14168ce19a840f5b Mon Sep 17 00:00:00 2001 From: Adam Dyess Date: Fri, 25 Oct 2024 17:05:21 -0500 Subject: [PATCH] Update many of the operator-workflow-actions (#156) * Update many of the operator-workflow-actions * Use tip workflows for integration testing * Publish charms from the k8s integration tests * Prepare for multiarch charm builds --- .../auto-update-libs-k8s-worker.yaml | 12 ++++- .github/workflows/bot_pr_approval.yaml | 9 ++++ .github/workflows/charm-analysis.yaml | 2 +- .github/workflows/comment.yaml | 4 +- .github/workflows/comment_contributing.yaml | 13 +++++ .github/workflows/download-charm.yaml | 54 +++++++++++++++++++ .github/workflows/integration_test.yaml | 42 ++++++++------- .github/workflows/load_test.yaml | 4 +- .github/workflows/promote-charms.yaml | 14 ++--- .github/workflows/publish-charms.yaml | 12 +++-- 10 files changed, 129 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/bot_pr_approval.yaml create mode 100644 .github/workflows/comment_contributing.yaml create mode 100644 .github/workflows/download-charm.yaml diff --git a/.github/workflows/auto-update-libs-k8s-worker.yaml b/.github/workflows/auto-update-libs-k8s-worker.yaml index a1c8e634..22fdc573 100644 --- a/.github/workflows/auto-update-libs-k8s-worker.yaml +++ b/.github/workflows/auto-update-libs-k8s-worker.yaml @@ -5,8 +5,18 @@ on: - cron: "0 1 * * *" jobs: + charmcraft-channel: + runs-on: ubuntu-24.04 + outputs: + channel: ${{ steps.charmcraft.outputs.channel }} + steps: + - uses: actions/checkout@v4 + - id: charmcraft + run: echo "channel=$(cat .charmcraft-channel)" >> $GITHUB_OUTPUT auto-update-libs: - uses: canonical/operator-workflows/.github/workflows/auto_update_charm_libs.yaml@08c5a65a0bc4696164b4f85a29a9ccbd830d10d8 + needs: [charmcraft-channel] + uses: canonical/operator-workflows/.github/workflows/auto_update_charm_libs.yaml@main secrets: inherit with: working-directory: ./charms/worker/k8s + charmcraft-channel: ${{ needs.charmcraft-channel.outputs.channel }} diff --git a/.github/workflows/bot_pr_approval.yaml b/.github/workflows/bot_pr_approval.yaml new file mode 100644 index 00000000..e38c5841 --- /dev/null +++ b/.github/workflows/bot_pr_approval.yaml @@ -0,0 +1,9 @@ +name: Provide approval for bot PRs + +on: + pull_request: + +jobs: + bot_pr_approval: + uses: canonical/operator-workflows/.github/workflows/bot_pr_approval.yaml@main + secrets: inherit diff --git a/.github/workflows/charm-analysis.yaml b/.github/workflows/charm-analysis.yaml index e4b8f0fa..b064a784 100644 --- a/.github/workflows/charm-analysis.yaml +++ b/.github/workflows/charm-analysis.yaml @@ -6,7 +6,7 @@ on: jobs: unit-tests: - uses: canonical/operator-workflows/.github/workflows/test.yaml@08c5a65a0bc4696164b4f85a29a9ccbd830d10d8 + uses: canonical/operator-workflows/.github/workflows/test.yaml@main secrets: inherit with: charm-directory: charms diff --git a/.github/workflows/comment.yaml b/.github/workflows/comment.yaml index eb8379ce..a2b1768f 100644 --- a/.github/workflows/comment.yaml +++ b/.github/workflows/comment.yaml @@ -2,11 +2,11 @@ name: Comment on the pull request on: workflow_run: - workflows: ["Tests"] + workflows: ["Charm Analysis"] types: - completed jobs: comment-on-pr: - uses: canonical/operator-workflows/.github/workflows/comment.yaml@08c5a65a0bc4696164b4f85a29a9ccbd830d10d8 + uses: canonical/operator-workflows/.github/workflows/comment.yaml@main secrets: inherit diff --git a/.github/workflows/comment_contributing.yaml b/.github/workflows/comment_contributing.yaml new file mode 100644 index 00000000..c51f8731 --- /dev/null +++ b/.github/workflows/comment_contributing.yaml @@ -0,0 +1,13 @@ +name: Comment on the pull request + +on: + pull_request: + types: + - opened + branches: + - 'track/**' + +jobs: + comment-on-pr: + uses: canonical/operator-workflows/.github/workflows/comment_contributing.yaml@main + secrets: inherit diff --git a/.github/workflows/download-charm.yaml b/.github/workflows/download-charm.yaml new file mode 100644 index 00000000..03fc35b5 --- /dev/null +++ b/.github/workflows/download-charm.yaml @@ -0,0 +1,54 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +name: Download Charm + +on: + workflow_call: + inputs: + charm-arch: + type: string + description: The charm architecture to download + default: amd64 + charm-base: + type: string + description: The charm base to download + default: ubuntu@20.04 + charm-channel: + type: string + description: The charm channel to download + default: latest/edge + charm-name: + type: string + description: The charm name to download + juju-channel: + type: string + description: Which juju client to use for pulling charms + default: 3/stable + runs-on: + type: string + description: Image runner for building the images + default: ubuntu@22.04 + +jobs: + download-charms: + name: Download Charms + runs-on: ${{ inputs.runs-on }} + env: + CHARM_FILE: "${{ inputs.charm-name }}-${{ inputs.charm-channel }}-${{ inputs.charm-base }}-${{ inputs.charm-arch }}.charm" + steps: + - name: Install Juju + run: | + sudo snap install juju --channel ${{ inputs.juju-channel }} + - name: Download charm + run: | + CHARM_FILE=${{ env.CHARM_FILE }} + CHARM_FILE=${CHARM_FILE//\//-} # replace all slashes with dashes + echo CHARM_FILE=${CHARM_FILE} >> $GITHUB_ENV # update GitHub ENV vars + juju download ${{ inputs.charm-name }} --channel ${{ inputs.charm-channel }} --base ${{ inputs.charm-base }} --arch ${{ inputs.charm-arch }} - > ${{ env.CHARM_FILE }} + - name: Upload charm artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.charm-name }}-charm + path: ${{ env.CHARM_FILE }} + if-no-files-found: error diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index f70cb36a..7a392ef9 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -24,34 +24,36 @@ jobs: fi echo "args=$EXTRA_ARGS" >> "$GITHUB_OUTPUT" - build-all-charms: - needs: [extra-args] - strategy: - matrix: - path: - - "./charms/worker/k8s/" - - "./charms/worker/" - uses: ./.github/workflows/build-charm.yaml - with: - working-directory: ${{ matrix.path }} + charmcraft-channel: + runs-on: ubuntu-24.04 + outputs: + channel: ${{ steps.charmcraft.outputs.channel }} + steps: + - uses: actions/checkout@v4 + - id: charmcraft + run: echo "channel=$(cat .charmcraft-channel)" >> $GITHUB_OUTPUT integration-tests: - uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@08c5a65a0bc4696164b4f85a29a9ccbd830d10d8 - needs: [build-all-charms, extra-args] + uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main + needs: [charmcraft-channel, extra-args] strategy: matrix: - suite: ["k8s", "etcd"] + arch: + - {id: amd64-k8s, suite: k8s, builder-label: ubuntu-22.04, tester-arch: x64} + - {id: amd64-etcd, suite: etcd, builder-label: ubuntu-22.04, tester-arch: x64} secrets: inherit with: - provider: lxd + identifier: ${{ matrix.arch.id }} + charmcraft-channel: ${{ needs.charmcraft-channel.outputs.channel }} + extra-arguments: ${{needs.extra-args.outputs.args}} -k test_${{ matrix.arch.suite }} juju-channel: 3/stable - extra-arguments: ${{needs.extra-args.outputs.args}} -k test_${{ matrix.suite }} load-test-enabled: false - zap-enabled: false + provider: lxd self-hosted-runner: true - self-hosted-runner-label: "large" - trivy-fs-enabled: true + self-hosted-runner-arch: ${{ matrix.arch.tester-arch }} + test-timeout: 120 + test-tox-env: integration-${{ matrix.arch.suite }} + trivy-fs-enabled: false trivy-image-config: "trivy.yaml" tmate-debug: true - test-timeout: 120 - test-tox-env: integration-${{ matrix.suite }} + zap-enabled: false diff --git a/.github/workflows/load_test.yaml b/.github/workflows/load_test.yaml index 792599fb..02829b3c 100644 --- a/.github/workflows/load_test.yaml +++ b/.github/workflows/load_test.yaml @@ -6,10 +6,10 @@ on: jobs: load-tests: - uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@08c5a65a0bc4696164b4f85a29a9ccbd830d10d8 + uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main with: provider: lxd - juju-channel: 3.3/stable + juju-channel: 3/stable load-test-enabled: true load-test-run-args: "-e LOAD_TEST_HOST=localhost" secrets: inherit diff --git a/.github/workflows/promote-charms.yaml b/.github/workflows/promote-charms.yaml index ddac359f..99ea66cb 100644 --- a/.github/workflows/promote-charms.yaml +++ b/.github/workflows/promote-charms.yaml @@ -52,7 +52,7 @@ jobs: - name: Determine Charms id: charms env: - CHOICE: ${{ github.event.inputs.charm }} + CHOICE: ${{ inputs.charm }} run: | echo "Determines which charms were chosen from $CHOICE" if [[ "${CHOICE}" == "all" ]]; then @@ -67,10 +67,12 @@ jobs: strategy: matrix: charm-directory: ${{ fromJson(needs.select-charms.outputs.charms) }} - uses: canonical/operator-workflows/.github/workflows/promote_charm.yaml@08c5a65a0bc4696164b4f85a29a9ccbd830d10d8 + arch: + - amd64 + uses: canonical/operator-workflows/.github/workflows/promote_charm.yaml@main with: - origin-channel: ${{needs.configure-track.outputs.track}}/${{ github.event.inputs.origin-risk }} - destination-channel: ${{needs.configure-track.outputs.track}}/${{ github.event.inputs.destination-risk }} - charm-directory: ./charms - working-directory: ${{ matrix.charm-directory }} + base-architecture: ${{ matrix.arch }} + charm-directory: ${{ matrix.charm-directory }} + destination-channel: ${{needs.configure-track.outputs.track}}/${{ inputs.destination-risk }} + origin-channel: ${{needs.configure-track.outputs.track}}/${{ inputs.origin-risk }} secrets: inherit diff --git a/.github/workflows/publish-charms.yaml b/.github/workflows/publish-charms.yaml index 2d22ddf0..ad0962c4 100644 --- a/.github/workflows/publish-charms.yaml +++ b/.github/workflows/publish-charms.yaml @@ -41,16 +41,18 @@ jobs: run: echo "channel=$(cat .charmcraft-channel)" >> $GITHUB_OUTPUT publish-to-edge: needs: [configure-channel, charmcraft-channel] - uses: canonical/operator-workflows/.github/workflows/publish_charm.yaml@08c5a65a0bc4696164b4f85a29a9ccbd830d10d8 + uses: canonical/operator-workflows/.github/workflows/publish_charm.yaml@main strategy: matrix: - charm: [ - {path: "./charms/worker/", tagPrefix: "k8s-worker"}, - {path: "./charms/worker/k8s/", tagPrefix: "k8s"} - ] + charm: + - { path: ./charms/worker/k8s/, tagPrefix: k8s } + - { path: ./charms/worker/, tagPrefix: k8s-worker } + arch: + - amd64 secrets: inherit with: channel: ${{needs.configure-channel.outputs.track}}/${{needs.configure-channel.outputs.risk}} working-directory: ${{ matrix.charm.path }} charmcraft-channel: ${{ needs.charmcraft-channel.outputs.channel }} tag-prefix: ${{ matrix.charm.tagPrefix }} + identifier: ${{ matrix.arch}}-k8s