Skip to content

Commit

Permalink
compatible: Deprecate integration_test_charm.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Feb 3, 2025
1 parent 0e591ba commit aada62e
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_test_charm.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Workflow file: [integration_test_charm.yaml](integration_test_charm.yaml)

> [!WARNING]
> The `pytest-operator-cache` plugin is **deprecated**. Follow the migration instructions here: [pytest_operator_cache/deprecation_notice.md](../../python/pytest_plugins/pytest_operator_cache/deprecation_notice.md)
> This workflow is **deprecated** & will be removed in a future release. Follow the migration instructions here: [integration_test_charm_deprecation_notice.md](integration_test_charm_deprecation_notice.md)
## Usage
### Step 1: Create your workflow
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/integration_test_charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ jobs:
# So, we add the Juju version & architecture to one of the first jobs in this workflow.
# (In the UI, when this workflow is called with a matrix, GitHub will separate each matrix
# combination and preserve job ordering within a matrix combination.)
name: ${{ inputs.juju-agent-version || inputs.juju-snap-channel }} | ${{ inputs.architecture }} | Collect integration test groups
name: (deprecated) ${{ inputs.juju-agent-version || inputs.juju-snap-channel }} | ${{ inputs.architecture }} | Collect integration test groups
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Deprecation notice
run: |

Check failure on line 120 in .github/workflows/integration_test_charm.yaml

View workflow job for this annotation

GitHub Actions / Lint workflows

shellcheck reported issue in this script: SC2016:info:1:6: Expressions don't expand in single quotes, use double quotes for that
echo '::warning::The `integration_test_charm.yaml` workflow is deprecated. Follow the migration instructions here: https://github.com/canonical/data-platform-workflows/blob/v29.1.0/.github/workflows/integration_test_charm_deprecation_notice.md'
- name: Parse architecture input
id: parse-architecture
shell: python
Expand Down Expand Up @@ -196,8 +199,12 @@ jobs:
needs:
- collect-integration-tests
runs-on: ${{ matrix.groups.runner || fromJSON(needs.collect-integration-tests.outputs.default_runner) }}
timeout-minutes: 296 # Sum of steps `timeout-minutes` + 5
timeout-minutes: 297 # Sum of steps `timeout-minutes` + 5
steps:
- name: Deprecation notice
timeout-minutes: 1
run: |

Check failure on line 206 in .github/workflows/integration_test_charm.yaml

View workflow job for this annotation

GitHub Actions / Lint workflows

shellcheck reported issue in this script: SC2016:info:1:6: Expressions don't expand in single quotes, use double quotes for that
echo '::warning::The `integration_test_charm.yaml` workflow is deprecated. Follow the migration instructions here: https://github.com/canonical/data-platform-workflows/blob/v29.1.0/.github/workflows/integration_test_charm_deprecation_notice.md'
- name: (Data Platform hosted) Write job name to file
timeout-minutes: 1
# Data Platform hosted
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/integration_test_charm_allure_beta.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[Allure Report](https://allurereport.org/) for [integration_test_charm.yaml](integration_test_charm.md)

> [!WARNING]
> `integration_test_charm.yaml` is **deprecated** & will be removed in a future release. Follow the migration instructions here: [integration_test_charm_deprecation_notice.md](integration_test_charm_deprecation_notice.md)
## Usage
> [!WARNING]
> This feature is in beta and **not part of the public interface**. It is subject to breaking changes or removal on a patch version bump.
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/integration_test_charm_deprecation_notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Deprecation notice

## Components that are deprecated
These components are deprecated & will be removed in a future release
- integration_test_charm.yaml
- python/pytest_plugins/pytest_operator_cache
- python/pytest_plugins/pytest_operator_groups
- python/pytest_plugins/allure_pytest_collection_report
- python/pytest_plugins/github_secrets
- python/pytest_plugins/microceph

## Migration instructions
### integration_test_charm.yaml
Use `charmcraft test`: https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/commands/test/

And concierge: https://github.com/jnsgruk/concierge

Example: https://github.com/canonical/mysql-router-k8s-operator/pull/379

### python/pytest_plugins/pytest_operator_cache
In integration tests, instead of calling `ops_test.build_charm`, assume the *.charm file exists and fail the test if the *.charm file is missing. The charm should be built outside of the test

When running tests locally, if you would like the charm to be re-built each time the tests are run, consider using [charmcraftcache](https://github.com/canonical/charmcraftcache) (e.g. `ccc pack`) before the `pytest` command (e.g. in spread.yaml). If you have multiple charms, `ccc pack` needs to be called once for each charm

Example: https://github.com/canonical/mysql-router-k8s-operator/pull/379

### python/pytest_plugins/pytest_operator_groups
Use separate python files (modules) for each test group, or configure different spread (`charmcraft test`) tasks for each group (e.g. using pytest markers)

### python/pytest_plugins/allure_pytest_collection_report
Use https://github.com/canonical/allure-pytest-default-results instead

Example: https://github.com/canonical/mysql-router-k8s-operator/pull/379

### python/pytest_plugins/github_secrets
Use normal GitHub Actions syntax (https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow) to pass secrets as environment variables where `charmcraft test` is called

### python/pytest_plugins/microceph
Set up microceph using spread (`charmcraft test`) or create a pytest fixture to set up microceph
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
| Name | Description |
|----------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [lint.yaml](.github/workflows/lint.md) | Lint GitHub Actions workflows (`.github/workflows/`) and `tox run -e lint` |
| [integration_test_charm.yaml](.github/workflows/integration_test_charm.md) | Integration test charm |
| [build_snap.yaml](.github/workflows/build_snap.md) | Build snap |
| [build_rock.yaml](.github/workflows/build_rock.md) | Build rock |
| [build_charm.yaml](.github/workflows/build_charm.md) | Build charm |
Expand All @@ -12,6 +11,7 @@
| [release_charm.yaml](.github/workflows/release_charm.md) | Release charm to Charmhub |
| [sync_docs.yaml](.github/workflows/sync_docs.md) | Sync Discourse documentation to GitHub |
| [_update_bundle.yaml](.github/workflows/_update_bundle.md) | **Experimental** Update charm revisions in bundle |
| [integration_test_charm.yaml](.github/workflows/integration_test_charm.md) | **Deprecated** Integration test charm |

### Version
Recommendation: pin the latest version (e.g. `v1.0.0`) and use [Renovate](https://docs.renovatebot.com/) to stay up-to-date.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> [!WARNING]
> `allure-pytest-collection-report` is **deprecated**. Migration instructions: [integration_test_charm_deprecation_notice.md](../../../.github/workflows/integration_test_charm_deprecation_notice.md)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Upstream feature request to replace this plugin:
# https://github.com/allure-framework/allure-python/issues/821

import warnings

import allure_commons.logger
import allure_commons.model2
import allure_commons.types
Expand All @@ -17,6 +19,12 @@ def pytest_addoption(parser):


def pytest_configure(config):
warnings.warn(
# "\n::warning::" for https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
"\n::warning::The `allure-pytest-collection-report` plugin is deprecated. Follow the migration instructions here: "
"https://github.com/canonical/data-platform-workflows/blob/v29.1.0/.github/workflows/integration_test_charm_deprecation_notice.md",
DeprecationWarning,
)
if config.option.allure_collection_dir:
config.option.collectonly = True

Expand Down
5 changes: 4 additions & 1 deletion python/pytest_plugins/github_secrets/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
> [!WARNING]
> `pytest-github-secrets` is **deprecated**. Migration instructions: [integration_test_charm_deprecation_notice.md](../../../.github/workflows/integration_test_charm_deprecation_notice.md)
Access GitHub secrets from integration tests executed by [integration_test_charm.yaml](../../../.github/workflows/integration_test_charm.yaml)

Usage: [integration_test_charm.md](../../../.github/workflows/integration_test_charm.md)

Since reusable GitHub workflows do not support arbitrary secret inputs, all secrets must be encoded into a single string and passed as one secret. This plugin provides a pytest fixture that decodes the string.
Since reusable GitHub workflows do not support arbitrary secret inputs, all secrets must be encoded into a single string and passed as one secret. This plugin provides a pytest fixture that decodes the string.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ast
import logging
import os
import warnings

import pytest

Expand All @@ -9,6 +10,12 @@

@pytest.fixture(scope="session")
def github_secrets() -> dict[str, str]:
warnings.warn(
# "\n::warning::" for https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
"\n::warning::The `pytest-github-secrets` plugin is deprecated. Follow the migration instructions here: "
"https://github.com/canonical/data-platform-workflows/blob/v29.1.0/.github/workflows/integration_test_charm_deprecation_notice.md",
DeprecationWarning,
)
# Note: Exceptions are raised directly to avoid leaking secrets in stderr
secrets_str = os.environ.get("SECRETS_FROM_GITHUB")
if secrets_str is None:
Expand Down
5 changes: 4 additions & 1 deletion python/pytest_plugins/microceph/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> [!WARNING]
> `pytest-microceph` is **deprecated**. Migration instructions: [integration_test_charm_deprecation_notice.md](../../../.github/workflows/integration_test_charm_deprecation_notice.md)
Set up [microceph](https://github.com/canonical/microceph) for S3 backup integration tests executed by [integration_test_charm.yaml](../../../.github/workflows/integration_test_charm.yaml)

Usage: [integration_test_charm.md](../../../.github/workflows/integration_test_charm.md)
Usage: [integration_test_charm.md](../../../.github/workflows/integration_test_charm.md)
7 changes: 7 additions & 0 deletions python/pytest_plugins/microceph/pytest_microceph/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import subprocess
import time
import warnings

import boto3
import botocore.exceptions
Expand All @@ -19,6 +20,12 @@ class ConnectionInformation:

@pytest.fixture(scope="session")
def microceph():
warnings.warn(
# "\n::warning::" for https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
"\n::warning::The `pytest-microceph` plugin is deprecated. Follow the migration instructions here: "
"https://github.com/canonical/data-platform-workflows/blob/v29.1.0/.github/workflows/integration_test_charm_deprecation_notice.md",
DeprecationWarning,
)
if not os.environ.get("CI") == "true":
raise Exception("Not running on CI. Skipping microceph installation")
logger.info("Setting up microceph")
Expand Down
4 changes: 2 additions & 2 deletions python/pytest_plugins/pytest_operator_cache/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
> [!WARNING]
> `pytest-operator-cache` is **deprecated**. Migration instructions: [deprecation_notice.md](deprecation_notice.md)
> `pytest-operator-cache` is **deprecated**. Migration instructions: [integration_test_charm_deprecation_notice.md](../../../.github/workflows/integration_test_charm_deprecation_notice.md)
[pytest-operator](https://github.com/charmed-kubernetes/pytest-operator) plugin that overrides `ops_test.build_charm()` to return cached *.charm file instead of building new *.charm file.

Usage: [integration_test_charm.md](../../../.github/workflows/integration_test_charm.md)
Usage: [integration_test_charm.md](../../../.github/workflows/integration_test_charm.md)
14 changes: 0 additions & 14 deletions python/pytest_plugins/pytest_operator_cache/deprecation_notice.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def pytest_configure(config):
warnings.warn(
# "\n::warning::" for https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
"\n::warning::The `pytest-operator-cache` plugin is deprecated. Follow the migration instructions here: "
"https://github.com/canonical/data-platform-workflows/blob/v26.0.0/python/pytest_plugins/pytest_operator_cache/deprecation_notice.md",
"https://github.com/canonical/data-platform-workflows/blob/v29.1.0/.github/workflows/integration_test_charm_deprecation_notice.md",
DeprecationWarning,
)
if os.environ.get("CI") == "true":
Expand Down
5 changes: 4 additions & 1 deletion python/pytest_plugins/pytest_operator_groups/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
> [!WARNING]
> `pytest-operator-groups` is **deprecated**. Migration instructions: [integration_test_charm_deprecation_notice.md](../../../.github/workflows/integration_test_charm_deprecation_notice.md)
Run integration tests on parallel GitHub runners

Usage: [integration_test_charm.md](../../../.github/workflows/integration_test_charm.md)

By default, [pytest-operator](https://github.com/charmed-kubernetes/pytest-operator) runs each test file (Python module) in a separate Juju model. Usually, on GitHub, each integration test file is run in parallel (on separate runners).

This plugin allows further parallelization—an individual test file can be split into multiple groups. Each group can run on a separate GitHub runner.
This plugin allows further parallelization—an individual test file can be split into multiple groups. Each group can run on a separate GitHub runner.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import os
import typing
import warnings

import pytest

Expand All @@ -18,6 +19,12 @@ def pytest_addoption(parser):


def pytest_configure(config):
warnings.warn(
# "\n::warning::" for https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
"\n::warning::The `pytest-operator-groups` plugin is deprecated. Follow the migration instructions here: "
"https://github.com/canonical/data-platform-workflows/blob/v29.1.0/.github/workflows/integration_test_charm_deprecation_notice.md",
DeprecationWarning,
)
config.addinivalue_line(
"markers", "group(id): Parallelize tests in a file across GitHub runners"
)
Expand Down

0 comments on commit aada62e

Please sign in to comment.