From ce34a36e7a612e8aefdaf1e7a8db217a0710fcc2 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:10:17 +0000 Subject: [PATCH 01/18] update .github/workflows/promote.yaml --- .github/workflows/promote.yaml | 38 +++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index aa53c2e..fed31a1 100644 --- a/.github/workflows/promote.yaml +++ b/.github/workflows/promote.yaml @@ -1,25 +1,39 @@ -name: Promote charm to other tracks and channels +# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation +# To update the file: +# - Edit it in the canonical/solutions-engineering-automation repository. +# - Open a PR with the changes. +# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes. +name: Promote charm to default track, standard risk levels. on: workflow_dispatch: inputs: - destination-channel: - description: 'Destination Channel, e.g. latest/candidate' - required: true - origin-channel: - description: 'Origin Channel, e.g. latest/edge' + channel-promotion: + description: 'Channel Promotion, e.g. latest/edge -> latest/candidate' required: true + type: choice + options: + - 'latest/edge -> latest/candidate' + - 'latest/candidate -> latest/stable' jobs: promote-charm: name: Promote charm - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - name: Release charm to channel - uses: canonical/charming-actions/release-charm@2.4.0 + - name: Set channels + id: set-channels + run: | + channel_promotion="${{ github.event.inputs.channel-promotion }}" + origin=$(echo "$channel_promotion" | sed 's/\s*->.*//') + destination=$(echo "$channel_promotion" | sed 's/.*->\s*//') + echo "destination-channel=$destination" >> $GITHUB_OUTPUT + echo "origin-channel=$origin" >> $GITHUB_OUTPUT + - name: Promote charm to channel + uses: canonical/charming-actions/promote-charm@2.6.3 with: credentials: ${{ secrets.CHARMHUB_TOKEN }} - github-token: ${{ secrets.GITHUB_TOKEN }} - destination-channel: ${{ github.event.inputs.destination-channel }} - origin-channel: ${{ github.event.inputs.origin-channel }} + destination-channel: ${{ steps.set-channels.outputs.destination-channel }} + origin-channel: ${{ steps.set-channels.outputs.origin-channel }} + charmcraft-channel: "2.x/stable" From 303eed677c1954271e9875d125d2a1c6a47c67ee Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:10:18 +0000 Subject: [PATCH 02/18] update .github/workflows/release.yaml --- .github/workflows/release.yaml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3b01e7e..539925c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,3 +1,8 @@ +# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation +# To update the file: +# - Edit it in the canonical/solutions-engineering-automation repository. +# - Open a PR with the changes. +# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes. name: Release to Edge on: @@ -13,17 +18,26 @@ jobs: release: needs: check - runs-on: ubuntu-latest + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + runs-on: [[ubuntu-22.04]] steps: - name: Checkout uses: actions/checkout@v4 + with: + submodules: true + - name: Initialize lxd # This should dropped once it's implemented on charming-actions itself. https://github.com/canonical/charming-actions/issues/140 - uses: canonical/setup-lxd@v0.1.1 - - name: Upload charm to charmhub - uses: canonical/charming-actions/upload-charm@2.4.0 + # revision is latest main at time of writing; using because it contains a fix to https://github.com/canonical/setup-lxd/issues/19 + uses: canonical/setup-lxd@2aa6f7caf7d1484298a64192f7f63a6684e648a4 + + - name: Pack and upload to charmhub + uses: canonical/charming-actions/upload-charm@2.6.2 with: + charmcraft-channel: "2.x/stable" credentials: "${{ secrets.CHARMHUB_TOKEN }}" github-token: "${{ secrets.GITHUB_TOKEN }}" - channel: "latest/edge" - # Note(rgildein): Right now we are not using destructive-mode, since our charmcraft.yaml is designed with a single build-on and the ability to run-on multiple bases. Running with destructive-mode would require aligning the base defined in this job with the one defined in charmcraft.yaml (build-on). + # Ensure the charm is built in an isolated environment and on the correct base in an lxd container. destructive-mode: false From 4add78cc72a5812c80d7a0888fc8f07822306884 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:10:20 +0000 Subject: [PATCH 03/18] update .github/workflows/check.yaml --- .github/workflows/check.yaml | 175 ++++++++++++++++++++++++++++++----- 1 file changed, 152 insertions(+), 23 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 17543c6..6974948 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -1,45 +1,174 @@ -# This is a template `pr.yaml` file for ops charms -# This file is managed by bootstack-charms-spec and should not be modified -# within individual charm repos. https://launchpad.net/bootstack-charms-spec - -name: PR workflow running lint checkers, unit and functional tests +# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation +# To update the file: +# - Edit it in the canonical/solutions-engineering-automation repository. +# - Open a PR with the changes. +# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes. +name: Tests on: workflow_call: workflow_dispatch: pull_request: - types: [ opened, synchronize, reopened ] - branches: [ master, main ] + types: [opened, synchronize, reopened] + branches: [main] paths-ignore: - - '**.md' - - '**.rst' + - "**.md" + - "**.rst" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: true jobs: - lint-unit: - uses: canonical/bootstack-actions/.github/workflows/lint-unit.yaml@v2 + lint: + name: Lint strategy: fail-fast: false matrix: python-version: ["3.8", "3.10"] - with: - python-version: ${{ matrix.python-version }} + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + # pin tox to the current major version to avoid + # workflows breaking all at once when a new major version is released. + python -m pip install 'tox<5' + + - name: Run linters + run: tox -e lint + + unit: + name: Unit + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.10"] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install 'tox<5' + + - name: Run unit tests + run: tox -e unit func: - uses: canonical/bootstack-actions/.github/workflows/func.yaml@v2 - needs: lint-unit + needs: + - lint + - unit + name: functional tests + runs-on: ${{ matrix.runs-on }} + timeout-minutes: 120 strategy: fail-fast: false matrix: - command: ["TEST_JUJU3=1 make functional"] # TEST_JUJU3 needed due https://github.com/openstack-charmers/zaza/blob/b22c2eed4c322f1dfc14ffb2d31e0dd18c911a40/setup.py#L47 to support Juju3+ + runs-on: [[ubuntu-22.04]] + test-command: ['TEST_JUJU3=1 make functional'] juju-channel: ["3.4/stable"] - with: - command: ${{ matrix.command }} - juju-channel: ${{ matrix.juju-channel }} - nested-containers: false - provider: "lxd" - python-version: "3.10" - timeout-minutes: 120 + steps: + + - uses: actions/checkout@v4 + with: + submodules: true + + # arm64 runners don't have gcc installed by default + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y gcc + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Setup Juju environment + uses: charmed-kubernetes/actions-operator@main + with: + provider: "lxd" + juju-channel: ${{ matrix.juju-channel }} + charmcraft-channel: "2.x/stable" + + # This is used by zaza in the functional tests for non-amd64 architectures (if applicable) + - name: Set zaza juju model constraints for architecture + run: | + if [ "$(uname -m)" = "aarch64" ]; then + echo "TEST_MODEL_CONSTRAINTS=arch=arm64" >> "$GITHUB_ENV" + fi + + - name: Build the charm + run: charmcraft -v pack + + - name: Run tests + run: | + # These variables are for a consistent method to find the charm file(s) across all projects. + # It is designed to work both with charms that output one file per base, + # and charms that output a single file to run on all bases. + # Not all charms will use them, and for some charms the variables will resolve to the same file. + export CHARM_PATH_NOBLE="$(pwd)/$(ls | grep '.*24.04.*\.charm$')" + echo "$CHARM_PATH_NOBLE" + export CHARM_PATH_JAMMY="$(pwd)/$(ls | grep '.*22.04.*\.charm$')" + echo "$CHARM_PATH_JAMMY" + export CHARM_PATH_FOCAL="$(pwd)/$(ls | grep '.*20.04.*\.charm$')" + echo "$CHARM_PATH_FOCAL" + ${{ matrix.test-command }} + env: + TEST_JUJU3: "1" # https://github.com/openstack-charmers/zaza/pull/653 + TEST_JUJU_CHANNEL: ${{ matrix.juju-channel }} + + # Save output for debugging + + - name: Generate debugging information + if: always() + run: | + set -x + # install dependencies + sudo snap install --classic juju-crashdump + sudo apt install -y jq uuid + + # Print juju controller information for debugging + # to check controller and client are compatible versions; + # we can have a mismatch if using an external controller. + juju version + juju controllers + + models="$(juju models --format json | jq -r '.models[]."short-name"')" + dir="$(mktemp -d)" + # Use a different dir to avoid charmed-kubernetes/actions-operator from also trying to upload crashdumps. + # We don't want to rely on that action, because it doesn't use a descriptive enough name for the artefact, + # and we may stop using that action soon. + echo "CRASHDUMPS_DIR=$dir" | tee -a "$GITHUB_ENV" + echo "CRASHDUMPS_ARTEFACT_SUFFIX=$(uuid)-$(uname -m)" | tee -a "$GITHUB_ENV" + + for model in $models; do + # show status here for quick debugging + juju status -m "$model" + juju-crashdump --as-root -m "$model" -u "$model-$(uname -m)" -o "$dir" + done + + - name: Upload juju crashdumps + uses: actions/upload-artifact@v4 + if: always() + with: + name: "juju-crashdumps-${{ env.CRASHDUMPS_ARTEFACT_SUFFIX }}" + path: "${{ env.CRASHDUMPS_DIR }}/juju-crashdump-*.tar.xz" From 4c28b45a825fd91ee6dfd7333bb203b63b629cc0 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 01:42:29 +0000 Subject: [PATCH 04/18] update .github/workflows/release.yaml From 34f3b999b848f6ec4772f55f54becfe6fba2ead9 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 01:42:30 +0000 Subject: [PATCH 05/18] update .github/workflows/promote.yaml From 092e40ddfd85d69b5d6ce0f7e3a9b00e1536873f Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 01:42:32 +0000 Subject: [PATCH 06/18] update .github/workflows/check.yaml From e075d84ee7f58d5f544d8da830a5ff6edf1e9bda Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 03:42:14 +0000 Subject: [PATCH 07/18] update .github/workflows/release.yaml From a1e9c7ab77ee8493e64ce82ec0300973c95e6cbc Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 03:42:16 +0000 Subject: [PATCH 08/18] update .github/workflows/promote.yaml From 4d29317a611eacdb8151b4b320b2eeae381d86fe Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 03:42:17 +0000 Subject: [PATCH 09/18] update .github/workflows/check.yaml From 94928c0596104260204f068012841dd1ab4b80ab Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 06:05:50 +0000 Subject: [PATCH 10/18] update .github/workflows/promote.yaml From 1257f6208bc19761160da98faaa80699bbdb863c Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 06:05:52 +0000 Subject: [PATCH 11/18] update .github/workflows/release.yaml From 731424ca0181ac2e3c0a6c5d006739271bbbeeab Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 06:05:53 +0000 Subject: [PATCH 12/18] update .github/workflows/check.yaml From b6129acdc6ad4511a3113baac9f9d2748e822d46 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:26:52 +0000 Subject: [PATCH 13/18] update .github/workflows/release.yaml From 459d0761280e53c8221ceeb53639bd2c0f507594 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:26:53 +0000 Subject: [PATCH 14/18] update .github/workflows/promote.yaml From 76c45f0193e5e1cff2b9fdba06a25ae2552d511d Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:26:55 +0000 Subject: [PATCH 15/18] update .github/workflows/check.yaml From 60541eb2c5a5d76f9aa0fde13f76ba1dae773faa Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 01:53:29 +0000 Subject: [PATCH 16/18] update .github/workflows/promote.yaml From 79873cd194908674be951c60e197afbcd5302bc9 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 01:53:31 +0000 Subject: [PATCH 17/18] update .github/workflows/release.yaml From 0f5f62a75f0649665bf68f79170dc59461161515 Mon Sep 17 00:00:00 2001 From: "soleng-terraform[bot]" <168111096+soleng-terraform[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 01:53:32 +0000 Subject: [PATCH 18/18] update .github/workflows/check.yaml