Skip to content

Commit 8aeae70

Browse files
Migrate to charmcraft 3 & charmcraft test (#210)
Ported from canonical/mysql-router-k8s-operator#379
1 parent 6ce95c6 commit 8aeae70

40 files changed

+1152
-1007
lines changed

.github/workflows/ci.yaml

+15-110
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ concurrency:
99
on:
1010
pull_request:
1111
schedule:
12-
- cron: '53 0 * * *' # Daily at 00:53 UTC
12+
- cron: '53 0 * * *' # Daily at 00:53 UTC
1313
# Triggered on push to branch "main" by .github/workflows/release.yaml
1414
workflow_call:
15+
outputs:
16+
artifact-prefix:
17+
description: build_charm.yaml `artifact-prefix` output
18+
value: ${{ jobs.build.outputs.artifact-prefix }}
1519

1620
jobs:
1721
lint:
@@ -31,7 +35,7 @@ jobs:
3135
unit-test:
3236
name: Unit test charm
3337
runs-on: ubuntu-22.04 # TODO: use ubuntu-latest after fixing pathlib issue on python 3.12
34-
timeout-minutes: 5
38+
timeout-minutes: 20
3539
steps:
3640
- name: Checkout
3741
uses: actions/checkout@v4
@@ -66,116 +70,17 @@ jobs:
6670

6771
build:
6872
name: Build charm
69-
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
70-
with:
71-
# Use of cache blocked by https://github.com/canonical/charmcraft/issues/1456
72-
# Details: https://github.com/canonical/charmcraftcache/issues/3
73-
cache: false
74-
# Remove prefix when cache enabled
75-
# Needed to avoid conflict with artifact name on release CI
76-
artifact-prefix: ci-packed-charm-cache-false-.
73+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
7774

78-
gh-hosted-collect-integration-tests:
79-
name: (GH hosted) Collect integration test groups
80-
needs:
81-
- lint
82-
- unit-test
83-
runs-on: ubuntu-latest
84-
steps:
85-
- name: Checkout
86-
uses: actions/checkout@v4
87-
- name: Install tox & poetry
88-
run: |
89-
pipx install tox
90-
pipx install poetry
91-
- name: Select test stability level
92-
id: select-test-stability
93-
run: |
94-
if [[ "${{ github.event_name }}" == "schedule" ]]
95-
then
96-
echo Running unstable and stable tests
97-
echo "mark_expression=" >> "$GITHUB_OUTPUT"
98-
else
99-
echo Skipping unstable tests
100-
echo "mark_expression=not unstable" >> "$GITHUB_OUTPUT"
101-
fi
102-
- name: Collect test groups
103-
id: collect-groups
104-
run: tox run -e integration -- tests/integration -m '${{ steps.select-test-stability.outputs.mark_expression }}' --collect-groups
105-
outputs:
106-
groups: ${{ steps.collect-groups.outputs.groups }}
107-
108-
gh-hosted-integration-test:
109-
strategy:
110-
fail-fast: false
111-
matrix:
112-
groups: ${{ fromJSON(needs.gh-hosted-collect-integration-tests.outputs.groups) }}
113-
ubuntu-versions:
114-
# Update whenever charmcraft.yaml is changed
115-
- series: focal
116-
bases-index: 0
117-
- series: jammy
118-
bases-index: 1
119-
juju-snap-channel: ["2.9/stable", "3.6/stable"]
120-
include:
121-
- juju-snap-channel: "3.6/stable"
122-
agent-version: "3.6.1"
123-
libjuju-version: "3.6.0.0"
124-
- juju-snap-channel: "2.9/stable"
125-
agent-version: "2.9.51"
126-
libjuju-version: "2.9.49.0"
127-
exclude:
128-
- groups: {path_to_test_file: tests/integration/test_data_integrator.py}
129-
ubuntu-versions: {series: focal}
130-
- groups: {path_to_test_file: tests/integration/test_hacluster.py}
131-
ubuntu-versions: {series: focal}
132-
name: ${{ matrix.juju-snap-channel }} - (GH hosted) ${{ matrix.groups.job_name }} | ${{ matrix.ubuntu-versions.series }}
75+
integration-test:
76+
name: Integration test charm
13377
needs:
13478
- lint
13579
- unit-test
13680
- build
137-
- gh-hosted-collect-integration-tests
138-
runs-on: ubuntu-latest
139-
timeout-minutes: 120
140-
steps:
141-
- name: Checkout
142-
uses: actions/checkout@v4
143-
- name: Install tox & poetry
144-
run: |
145-
pipx install tox
146-
pipx install poetry
147-
- name: Setup operator environment
148-
uses: charmed-kubernetes/actions-operator@main
149-
with:
150-
provider: lxd
151-
bootstrap-options: "--agent-version ${{ matrix.agent-version }}"
152-
juju-channel: ${{ matrix.juju-snap-channel }}
153-
- name: Update python-libjuju version
154-
if: ${{ matrix.libjuju-version == '2.9.49.0' }}
155-
run: poetry add --lock --group integration juju@'${{ matrix.libjuju-version }}'
156-
- name: Download packed charm(s)
157-
uses: actions/download-artifact@v4
158-
with:
159-
pattern: ${{ needs.build.outputs.artifact-prefix }}-*
160-
merge-multiple: true
161-
- name: Select test stability level
162-
id: select-test-stability
163-
run: |
164-
if [[ "${{ github.event_name }}" == "schedule" ]]
165-
then
166-
echo Running unstable and stable tests
167-
echo "mark_expression=" >> "$GITHUB_OUTPUT"
168-
else
169-
echo Skipping unstable tests
170-
echo "mark_expression=not unstable" >> "$GITHUB_OUTPUT"
171-
fi
172-
- name: Run integration tests
173-
run: tox run -e integration -- "${{ matrix.groups.path_to_test_file }}" --group="${{ matrix.groups.group_number }}" -m '${{ steps.select-test-stability.outputs.mark_expression }}' --mysql-router-charm-series=${{ matrix.ubuntu-versions.series }} --mysql-router-charm-bases-index=${{ matrix.ubuntu-versions.bases-index }}
174-
env:
175-
LIBJUJU_VERSION_SPECIFIER: ${{ matrix.libjuju-version }}
176-
SECRETS_FROM_GITHUB: |
177-
{
178-
"UBUNTU_PRO_TOKEN" : "${{ secrets.UBUNTU_PRO_TOKEN }}",
179-
"LANDSCAPE_ACCOUNT_NAME": "${{ secrets.LANDSCAPE_ACCOUNT_NAME }}",
180-
"LANDSCAPE_REGISTRATION_KEY": "${{ secrets.LANDSCAPE_REGISTRATION_KEY }}",
181-
}
81+
uses: ./.github/workflows/integration_test.yaml
82+
with:
83+
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
84+
secrets: inherit
85+
permissions:
86+
contents: write # Needed for Allure Report

0 commit comments

Comments
 (0)