-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache charmcraft pack container, skip unstable tests except on schedule #11
Closed
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
29c5d70
Cache charmcraft pack container, skip unstable tests except on schedule
carlcsaposs-canonical ae2bfd0
Change scope of ops_test fixture to "module"
carlcsaposs-canonical ed50033
Update build_charms_with_cache.yaml to v2
carlcsaposs-canonical a0864fc
Cancel CI that is not the latest commit on a branch
carlcsaposs-canonical 2a7fc2a
Fix matrix
carlcsaposs-canonical 991ad3e
Update tox.ini
carlcsaposs-canonical File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,72 +1,96 @@ | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
name: Tests | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
schedule: | ||
- cron: '53 0 * * *' # Daily at 00:53 UTC | ||
# Triggered on push to branch "main" by .github/workflows/release.yaml | ||
workflow_call: | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
- name: Install tox | ||
run: python3 -m pip install tox | ||
- name: Install poetry | ||
run: curl -sSL https://install.python-poetry.org | python3 - | ||
- name: Run linters | ||
run: tox -e lint | ||
run: tox run -e lint | ||
|
||
unit-test: | ||
name: Unit tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
- name: Install tox | ||
run: python3 -m pip install tox | ||
- name: Install poetry | ||
run: curl -sSL https://install.python-poetry.org | python3 - | ||
- name: Run tests | ||
run: tox -e unit | ||
|
||
integration-test-lxd: | ||
name: Integration tests for (lxd) | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- lint | ||
- unit-test | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: lxd | ||
bootstrap-options: "--agent-version 2.9.38" | ||
- name: Install tox | ||
run: python3 -m pip install tox | ||
- name: Install poetry | ||
run: curl -sSL https://install.python-poetry.org | python3 - | ||
- name: Run integration tests | ||
run: tox -e integration-lxd | ||
|
||
integration-test-k8s: | ||
name: Integration tests for (microk8s) | ||
run: tox run -e unit | ||
|
||
build: | ||
name: Build charms | ||
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v2 | ||
|
||
integration-test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
tox-environments: | ||
- name: integration-lxd | ||
provider: lxd | ||
- name: integration-k8s | ||
provider: microk8s | ||
name: ${{ matrix.tox-environments.name }} | ||
needs: | ||
- lint | ||
- unit-test | ||
- build | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup operator environment | ||
# TODO: Replace with custom image on self-hosted runner | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: microk8s | ||
provider: ${{ matrix.tox-environments.provider }} | ||
bootstrap-options: "--agent-version 2.9.38" | ||
- name: Install tox | ||
run: python3 -m pip install tox | ||
- name: Install poetry | ||
run: curl -sSL https://install.python-poetry.org | python3 - | ||
- 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: tox -e integration-k8s | ||
run: tox run -e ${{ matrix.tox-environments.name }} -- -m '${{ steps.select-tests.outputs.mark_expression }}' | ||
env: | ||
CI_PACKED_CHARMS: ${{ needs.build.outputs.charms }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# See LICENSE file for licensing details. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# See LICENSE file for licensing details. |
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 |
---|---|---|
|
@@ -2,27 +2,27 @@ | |
# See LICENSE file for licensing details. | ||
|
||
[tox] | ||
skipsdist=True | ||
no_package = True | ||
skip_missing_interpreters = True | ||
envlist = fmt, lint, unit | ||
env_list = lint, unit | ||
|
||
[vars] | ||
src_path = {toxinidir}/src/ | ||
tst_path = {toxinidir}/tests/ | ||
lib_path = {toxinidir}/lib/ | ||
all_path = {[vars]src_path} {[vars]tst_path} {[vars]lib_path} | ||
src_path = {tox_root}/src | ||
tests_path = {tox_root}/tests | ||
lib_path = {tox_root}/lib | ||
all_path = {[vars]src_path} {[vars]tests_path} {[vars]lib_path} | ||
|
||
[testenv] | ||
setenv = | ||
PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path} | ||
PYTHONBREAKPOINT=ipdb.set_trace | ||
PY_COLORS=1 | ||
passenv = | ||
PYTHONPATH | ||
CHARM_BUILD_DIR | ||
MODEL_SETTINGS | ||
set_env = | ||
PYTHONPATH = {tox_root}/lib:{[vars]src_path} | ||
PYTHONBREAKPOINT=ipdb.set_trace | ||
PY_COLORS=1 | ||
pass_env = | ||
PYTHONPATH | ||
CHARM_BUILD_DIR | ||
MODEL_SETTINGS | ||
|
||
[testenv:fmt] | ||
[testenv:format] | ||
allowlist_externals = poetry | ||
description = Apply coding style standards to code | ||
commands = | ||
|
@@ -36,9 +36,9 @@ description = Check code against coding style standards | |
commands = | ||
poetry install | ||
poetry run codespell {[vars]lib_path} | ||
poetry run codespell {toxinidir} --skip {toxinidir}/.git --skip {toxinidir}/.tox \ | ||
--skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \ | ||
--skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg | ||
poetry run codespell {tox_root} --skip {tox_root}/.git --skip {tox_root}/.tox \ | ||
--skip {tox_root}/build --skip {tox_root}/lib --skip {tox_root}/venv \ | ||
--skip {tox_root}/.mypy_cache --skip {tox_root}/icon.svg | ||
# pflake8 wrapper supports config from pyproject.toml | ||
poetry run pflake8 {[vars]all_path} | ||
poetry run isort --check-only --diff {[vars]all_path} | ||
|
@@ -51,23 +51,31 @@ commands = | |
poetry install | ||
poetry export -f requirements.txt -o requirements.txt | ||
poetry run coverage run --source={[vars]src_path} \ | ||
-m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs} | ||
-m pytest -v --tb native -s {posargs} {[vars]tests_path}/unit | ||
poetry run coverage report | ||
|
||
[testenv:integration-lxd] | ||
allowlist_externals = poetry | ||
description = Run integration tests | ||
pass_env = | ||
{[testenv]pass_env} | ||
CI | ||
CI_PACKED_CHARMS | ||
commands = | ||
poetry install --with dev | ||
poetry export -f requirements.txt -o requirements.txt | ||
poetry run pytest -v --tb native {[vars]tst_path}integration/test_charm.py --log-cli-level=INFO -s --cloud=localhost {posargs} | ||
poetry run pytest -v --tb native --log-cli-level=INFO -s --cloud=localhost {posargs} {[vars]tests_path}/integration/test_charm.py | ||
|
||
[testenv:integration-k8s] | ||
allowlist_externals = poetry | ||
description = Run integration tests | ||
pass_env = | ||
{[testenv]pass_env} | ||
CI | ||
CI_PACKED_CHARMS | ||
commands = | ||
poetry install --with dev | ||
poetry export -f requirements.txt -o requirements.txt | ||
poetry run pytest -v --tb native {[vars]tst_path}integration/test_charm.py --log-cli-level=INFO -s --cloud=microk8s {posargs} | ||
poetry run pytest -v --tb native --log-cli-level=INFO -s --cloud=microk8s {posargs} {[vars]tests_path}/integration/test_charm.py | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd make it more general to be consisnte with other repo |
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make it more general to be consisnte with other repo