Skip to content

Commit

Permalink
Update many of the operator-workflow-actions (#156)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
addyess authored Oct 25, 2024
1 parent 01301e2 commit 47af764
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 37 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/auto-update-libs-k8s-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
9 changes: 9 additions & 0 deletions .github/workflows/bot_pr_approval.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/charm-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions .github/workflows/comment_contributing.yaml
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions .github/workflows/download-charm.yaml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
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: [email protected]

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
42 changes: 22 additions & 20 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/load_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 8 additions & 6 deletions .github/workflows/promote-charms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
12 changes: 7 additions & 5 deletions .github/workflows/publish-charms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 47af764

Please sign in to comment.