forked from canonical/operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: run the smoke tests on a schedule (canonical#1387)
We have some basic smoke tests, which are currently the only tests we regularly run against an actual Juju model. The tests deploy a basic charm and verify that it goes to `active` status (which happens in an `install` handler). However, these are currently only run if someone manually runs `tox -e smoke`. This PR adds running the tests on a schedule (currently monthly, in the days before we will likely do a release). This tests: * Juju 3.5 (latest stable 3.x - I suggest we *change* this to 3.6 when that's released, rather than *adding* 3.6). The smoke tests do not currently work with Juju 2.9 (I'm not sure if it's worth adding that at this point), but if that changes, it should only require a matrix change in the workload. The smoke tests use python-libjuju, which doesn't yet support Juju 4.0, but when that changes, this should also only require a matrix change. * Charmcraft 2.x and 3.x. * LXD and MicroK8s. The smoke test is changed to use a plain `subprocess.run` to pack the charm, rather than use pytest-operator for this. The `pytest-operator` approach doesn't work out-of-the-box in the workflow, and it seems cleaner to just do the pack ourselves. There's an [example run on my fork](https://github.com/tonyandrewmeyer/operator/actions/runs/11006199263/job/30560942709). This could be optimised in the future to store the packed charms and share them across Juju versions and cloud types, but it doesn't seem worth doing that for now. Fixes canonical#1322
- Loading branch information
1 parent
4a14764
commit d342885
Showing
3 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: ops Smoke Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 7 25 * *' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
# pylibjuju does not currently support Juju 4.x | ||
# The smoke tests do not yet work on Juju 2.9. | ||
juju-version: ['3.5'] | ||
charmcraft-version: ['2.x', '3.x'] | ||
cloud: ['lxd', 'microk8s'] | ||
|
||
env: | ||
JUJU_VERSION: "${{ matrix.juju-version }}" | ||
|
||
steps: | ||
# LXD is required for charmcraft to pack, even if it's not used as the | ||
# Juju cloud. | ||
- name: Set up LXD | ||
uses: canonical/setup-lxd@8fb85546a934dfb994becf81341dd387ffe6aabb | ||
with: | ||
channel: 5.0/stable | ||
|
||
- name: Set up Microk8s | ||
if: matrix.cloud == 'microk8s' | ||
uses: balchua/[email protected] | ||
with: | ||
channel: '1.26-strict/stable' | ||
devMode: 'true' | ||
addons: '["dns", "hostpath-storage"]' | ||
|
||
- name: Set up Juju (classic) | ||
if: matrix.juju-version == '2.9' | ||
run: sudo snap install juju --classic --channel=${{ matrix.juju-version }} | ||
|
||
- name: Set up Juju | ||
if: matrix.juju-version != '2.9' | ||
run: sudo snap install juju --channel=${{ matrix.juju-version }} | ||
|
||
- name: Bootstrap Juju controller (k8s) | ||
if: matrix.cloud == 'microk8s' | ||
run: sg snap_microk8s -c 'juju bootstrap microk8s' | ||
|
||
- name: Bootstrap Juju controller (lxd) | ||
if: matrix.cloud == 'lxd' | ||
run: juju bootstrap localhost | ||
|
||
- name: Install charmcraft | ||
run: sudo snap install charmcraft --channel=${{ matrix.charmcraft-version }} --classic | ||
|
||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3 | ||
uses: actions/setup-python@v5 | ||
|
||
- name: Install tox | ||
run: pip install tox~=4.2 | ||
|
||
- name: Run smoke tests | ||
run: tox -e smoke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters