Skip to content

Commit

Permalink
Workflows adopted for Juju3 secrets testing
Browse files Browse the repository at this point in the history
  • Loading branch information
juditnovak committed Aug 3, 2023
1 parent 24a01d5 commit 7e029d2
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 24 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/integration-limited-juju3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
on:
workflow_call:
inputs:
juju-snap-channel:
description: Snap channel for Juju CLI
default: 3.1/stable
type: string
libjuju-version-specifier:
description: |
python-libjuju version specifier (e.g. ">=1.3")
https://packaging.python.org/en/latest/glossary/#term-Version-Specifier
required: false
type: string

jobs:
build:
name: Build charms
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v2

integration-test:
needs:
- build
strategy:
fail-fast: false
matrix:
tox-environments:
- charm-integration
- tls-integration
- client-integration
runner: ["ubuntu-22.04"]
name: ${{ matrix.tox-environments }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Juju environment
# Runs on juju 3 by default
# TODO: Replace with custom image on self-hosted runner
uses: charmed-kubernetes/actions-operator@main
with:
provider: lxd
juju-channel: ${{ inputs.juju-snap-channel }}

- name: Download packed charm(s)
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.artifact-name }}

- name: Select tests
id: select-tests
run: |
if [ "${{ github.event_name }}" == "schedule" ]
then
echo Running unstable and stable tests
echo "mark_expression=" >> $GITHUB_OUTPUT
else
echo Skipping unstable tests
echo "mark_expression=not unstable" >> $GITHUB_OUTPUT
fi
- name: Run integration tests
run: |
# free space in the runner
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# Set kernel params
sudo sysctl -w vm.max_map_count=262144 vm.swappiness=0 net.ipv4.tcp_retries2=5
tox run -e ${{ matrix.tox-environments }} -- -m '${{ steps.select-tests.outputs.mark_expression }}'
env:
CI_PACKED_CHARMS: ${{ needs.build.outputs.charms }}
LIBJUJU_VERSION_SPECIFIER: ${{ inputs.libjuju-version-specifier }}
- name: Print logs
run: juju switch testing; juju debug-log --replay --no-tail
35 changes: 15 additions & 20 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,25 @@ on:
jobs:
pre-integration-checks:
secrets: inherit
strategy:
fail-fast: false
matrix:
include:
- snap: 3.1/stable
libjuju: ==3.1.0.1
- snap: 2.9/stable
libjuju: ==2.9.42.4
uses: ./.github/workflows/pre_integration_checks.yaml
with:
libjuju-version-specifier: ${{ matrix.libjuju }}

integration:
needs:
- pre-integration-checks
strategy:
fail-fast: false
matrix:
include:
- snap: 3.1/stable
libjuju: ==3.1.0.1
- snap: 2.9/stable
libjuju: ==2.9.42.4
uses: ./.github/workflows/integration.yaml
with:
juju-snap-channel: ${{ matrix.snap }}
libjuju-version-specifier: ${{ matrix.libjuju }}
juju-snap-channel: 2.9/stable
libjuju-version-specifier: ==2.9.42.4

pre-integration-checks-juju3:
secrets: inherit
uses: ./.github/workflows/pre_integration_checks-juju3.yaml
with:
libjuju-version-specifier: ==3.2.0.1

integration-secrets:
needs:
- pre-integration-checks-juju3
uses: ./.github/workflows/integration-limited-juju3.yaml
with:
libjuju-version-specifier: ==3.2.0.1
44 changes: 44 additions & 0 deletions .github/workflows/pre_integration_checks-juju3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
name: Pre-integration checks

on:
workflow_call:
inputs:
libjuju-version-specifier:
description: |
python-libjuju version specifier (e.g. ">=1.3")
https://packaging.python.org/en/latest/glossary/#term-Version-Specifier
required: false
type: string

jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install tox
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version
run: python3 -m pip install tox
- name: Run linters
run: tox run -e lint

unit-test-juju3:
name: Unit tests Juju 3
runs-on: ubuntu-22.04
timeout-minutes: 5
needs:
- lint
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install tox
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version
run: python3 -m pip install tox
- name: Run tests
run: tox run -e unit-secrets-juju3
env:
LIBJUJU_VERSION_SPECIFIER: ${{ inputs.libjuju-version-specifier }}
19 changes: 16 additions & 3 deletions .github/workflows/pre_integration_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: tox run -e lint

unit-test:
name: Unit tests
name: Unit tests Juju 2
runs-on: ubuntu-22.04
timeout-minutes: 5
needs:
Expand All @@ -40,8 +40,21 @@ jobs:
run: python3 -m pip install tox
- name: Run tests
run: tox run -e unit
env:
LIBJUJU_VERSION_SPECIFIER: ${{ inputs.libjuju-version-specifier }}

unit-test-secrets:
name: Unit tests Juju 3
runs-on: ubuntu-22.04
timeout-minutes: 5
needs:
- lint
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install tox
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version
run: python3 -m pip install tox
- name: Run tests
run: tox run -e unit-secrets-juju3

lib-check:
name: Check libraries
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ commands =
description = Run unit tests
deps =
juju{env:LIBJUJU_VERSION_SPECIFIER:==2.9.42.4}
juju
pytest
pytest-asyncio
coverage[toml]
Expand Down Expand Up @@ -94,4 +95,3 @@ commands =
h-scaling: pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/ha/test_horizontal_scaling.py
ha-storage: pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/ha/test_storage.py
ha-networking: pytest -v --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/ha/test_ha_networking.py

0 comments on commit 7e029d2

Please sign in to comment.