From f238e06b65de33cbeb53b1715aefc1a9ac79a3fd Mon Sep 17 00:00:00 2001 From: Chi Wai Chan Date: Tue, 4 Mar 2025 11:33:59 +0800 Subject: [PATCH 1/4] Update workflow to release only tested charms --- .github/workflows/check.yaml | 9 +++++++++ .github/workflows/release.yaml | 26 ++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index d8410f5..5167f4b 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -142,6 +142,15 @@ jobs: TEST_JUJU3: "1" # https://github.com/openstack-charmers/zaza/pull/653 TEST_JUJU_CHANNEL: ${{ matrix.juju-channel }} + - name: Determine system architecture + run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV + + - name: Upload the tested charms + uses: actions/upload-artifact@v4 + with: + name: charm_${{ env.SYSTEM_ARCH }} + path: ./*.charm + # Save output for debugging - name: Generate debugging information diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7be3f5a..e9f7758 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,28 +11,30 @@ jobs: uses: ./.github/workflows/check.yaml secrets: inherit + release: needs: check - runs-on: ${{ matrix.runs-on }} - strategy: - fail-fast: false - matrix: - runs-on: [[ubuntu-22.04]] + runs-on: ubuntu-24.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 - # 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: Download the tested charms + uses: actions/download-artifact@v4 + with: + pattern: charm_* + merge-multiple: true + + - name: List the names of the tested charms + run: | + echo "CHARM_NAMES=$(ls *.charm | paste -sd ,)" >> "$GITHUB_ENV" + echo "${{ env.CHARM_NAMES }}" - - name: Pack and upload to charmhub + - name: Upload the tested charms to charmhub uses: canonical/charming-actions/upload-charm@2.6.2 with: - charmcraft-channel: "3.x/stable" credentials: "${{ secrets.CHARMHUB_TOKEN }}" github-token: "${{ secrets.GITHUB_TOKEN }}" - # Ensure the charm is built in an isolated environment and on the correct base in an lxd container. - destructive-mode: false + built-charm-path: "${{ env.CHARM_NAMES }}" From 24bf1be73a7c4b93ab4f6d0cf0699d51143f7524 Mon Sep 17 00:00:00 2001 From: Chi Wai Chan Date: Tue, 4 Mar 2025 11:40:59 +0800 Subject: [PATCH 2/4] Update upload-charm version --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e9f7758..92a19c5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -33,7 +33,7 @@ jobs: echo "${{ env.CHARM_NAMES }}" - name: Upload the tested charms to charmhub - uses: canonical/charming-actions/upload-charm@2.6.2 + uses: canonical/charming-actions/upload-charm@2.7.0 with: credentials: "${{ secrets.CHARMHUB_TOKEN }}" github-token: "${{ secrets.GITHUB_TOKEN }}" From 29c18b868bae85b9ae7605fea68fb2dab7195796 Mon Sep 17 00:00:00 2001 From: Chi Wai Chan Date: Tue, 4 Mar 2025 13:52:33 +0800 Subject: [PATCH 3/4] Split build job and func job --- .github/workflows/check.yaml | 60 +++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 5167f4b..88fc43f 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -67,17 +67,49 @@ jobs: - name: Run unit tests run: tox -e unit - func: + build: needs: - lint - unit - name: functional tests + name: build charms runs-on: ${{ matrix.runs-on }} timeout-minutes: 120 strategy: fail-fast: false matrix: runs-on: [[ubuntu-22.04]] + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - uses: canonical/craft-actions/charmcraft/pack@main + id: build + with: + verbosity: verbose + channel: "3.x/stable" + + - name: List the names of the built charms + run: echo "${{ steps.build.outputs.charms}}" + + - name: Determine system architecture + run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV + + - name: Upload the tested charms + uses: actions/upload-artifact@v4 + with: + name: built_charms_${{ env.SYSTEM_ARCH }} + path: ./*.charm + + func: + needs: + - build + name: functional tests + runs-on: ubuntu-24.04 + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: test-command: ['tox -e func -- -v --series focal', 'tox -e func -- -v --series jammy'] juju-channel: ["3.4/stable"] steps: @@ -115,15 +147,24 @@ jobs: # set default project to be nested-lxd project juju model-default project=nested-lxd + - name: Determine system architecture + run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV + # 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 + if [ "${{ env.SYSTEM_ARCH }}" = "aarch64" ]; then echo "TEST_MODEL_CONSTRAINTS=arch=arm64" >> "$GITHUB_ENV" fi - - name: Build the charm - run: charmcraft -v pack + - name: Download the built charms + uses: actions/download-artifact@v4 + with: + name: built_charms_${{ env.SYSTEM_ARCH }} + + - name: List the names of the downloaded charms + run: | + ls *.charm - name: Run tests run: | @@ -142,15 +183,6 @@ jobs: TEST_JUJU3: "1" # https://github.com/openstack-charmers/zaza/pull/653 TEST_JUJU_CHANNEL: ${{ matrix.juju-channel }} - - name: Determine system architecture - run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV - - - name: Upload the tested charms - uses: actions/upload-artifact@v4 - with: - name: charm_${{ env.SYSTEM_ARCH }} - path: ./*.charm - # Save output for debugging - name: Generate debugging information From 3f3f7f60ded6a66575370ba573dbdd673cc3f531 Mon Sep 17 00:00:00 2001 From: Chi Wai Chan Date: Tue, 4 Mar 2025 19:33:13 +0800 Subject: [PATCH 4/4] Add back runs-on --- .github/workflows/check.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 88fc43f..f92ba15 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -105,11 +105,12 @@ jobs: needs: - build name: functional tests - runs-on: ubuntu-24.04 + runs-on: ${{ matrix.runs-on }} timeout-minutes: 120 strategy: fail-fast: false matrix: + runs-on: [[ubuntu-22.04]] test-command: ['tox -e func -- -v --series focal', 'tox -e func -- -v --series jammy'] juju-channel: ["3.4/stable"] steps: