test: hookcmds integration tests for secret access and port managemen… #7085
This file contains hidden or 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
| name: Observability Charm Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_call: | |
| workflow_dispatch: | |
| permissions: {} | |
| jobs: | |
| build-wheels: | |
| uses: ./.github/workflows/_build-wheels.yaml | |
| o11y-charm-tests: | |
| runs-on: ubuntu-latest | |
| needs: build-wheels | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - charm-repo: canonical/alertmanager-k8s-operator | |
| commit: 8e44b663abc32b994b3eb917444a9be37d7e2362 # 2026-05-20T14:53:02Z | |
| - charm-repo: canonical/prometheus-k8s-operator | |
| commit: b7fb6cf55d50f4c17559576ecd5ac0245c0c179e # 2026-05-21T13:31:13Z | |
| - charm-repo: canonical/grafana-k8s-operator | |
| commit: f3999254035d5f39eda07261af2b86a4454846d4 # 2026-05-20T14:52:38Z | |
| steps: | |
| - name: Checkout the ${{ matrix.charm-repo }} repository | |
| uses: actions/checkout@v6.0.2 | |
| with: | |
| repository: ${{ matrix.charm-repo }} | |
| persist-credentials: false | |
| ref: ${{ matrix.commit }} | |
| - name: Download operator wheels | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: ${{ needs.build-wheels.outputs.artifact-name }} | |
| path: operator-wheels | |
| - name: Install dependencies | |
| run: pip install tox~=4.2 uv~=0.6 | |
| - name: Update 'ops' and 'ops-scenario' dependencies in test charm to latest | |
| if: ${{ !(matrix.disabled) }} | |
| run: | | |
| if [ -e "uv.lock" ]; then | |
| uv remove ops --optional dev --frozen || echo "maybe ops[testing] is not a dev dependency" | |
| uv remove ops-scenario --optional dev --frozen || echo "maybe ops-scenario is not a dev dependency" | |
| uv remove ops --frozen | |
| sed -i 's/requires-python = "~=3.8"/requires-python = "~=3.10"/g' pyproject.toml | |
| sed -i 's/pythonVersion = "3\.[89]"/pythonVersion = "3.10"/g' pyproject.toml | |
| # Get absolute paths to the wheels | |
| ops_wheel="$(ls operator-wheels/ops-[0-9]*.whl)" | |
| ops_scenario_wheel="$(ls operator-wheels/ops_scenario-*.whl)" | |
| ops_tracing_wheel="$(ls operator-wheels/ops_tracing-*.whl)" | |
| # Add ops first, then ops-scenario (for testing), then ops-tracing | |
| # Use --upgrade-package to ensure the wheel versions are used, not existing pinned versions | |
| uv add "${ops_wheel}" --raw-sources --prerelease=if-necessary-or-explicit --upgrade-package ops | |
| uv add "${ops_scenario_wheel}" --optional dev --raw-sources --prerelease=if-necessary-or-explicit --upgrade-package ops-scenario | |
| uv add "${ops_tracing_wheel}" --raw-sources --prerelease=if-necessary-or-explicit --upgrade-package ops-tracing | |
| else | |
| echo "Error: no uv.lock file found" | |
| exit 1 | |
| fi | |
| - name: Upgrade pytest-interface-tester for ops-scenario compatibility | |
| if: ${{ !(matrix.disabled) }} | |
| run: | | |
| if [ -e "uv.lock" ]; then | |
| # Upgrade only pytest-interface-tester to a version compatible with new ops-scenario | |
| uv add "pytest-interface-tester>=3.4" --optional dev --upgrade-package pytest-interface-tester || echo "Could not upgrade pytest-interface-tester" | |
| fi | |
| - name: Run the charm's unit tests | |
| if: ${{ !(matrix.disabled) }} | |
| run: tox -vve unit | |
| - name: Check if 'scenario' tox environment exists | |
| id: check-tox-env-scenario | |
| run: | | |
| if tox --listenvs | grep -q "^scenario$"; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # alertmanager-k8s has old Scenario tests, so we can't do this until those | |
| # are updated. | |
| # - name: Run the charm's scenario unit tests | |
| # if: ${{ steps.check-tox-env-scenario.outputs.exists == 'true' && !(matrix.disabled) }} | |
| # run: tox -vve scenario | |
| - name: Check if 'static' tox environment exists | |
| id: check-tox-env-static | |
| run: | | |
| if tox --listenvs | grep -q "^static$"; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run the charm's static analysis checks | |
| if: ${{ steps.check-tox-env-static.outputs.exists == 'true' && !(matrix.disabled) | |
| }} | |
| run: tox -vve static | |
| - name: Check if 'static-charm' tox environment exists | |
| id: check-tox-env-static-charm | |
| run: | | |
| if tox --listenvs | grep -q "^static-charm$"; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run the charm's static (charm) analysis checks | |
| if: ${{ steps.check-tox-env-static-charm.outputs.exists == 'true' && !(matrix.disabled) | |
| }} | |
| run: tox -vve static-charm |