Skip to content

Commit

Permalink
tests(ci): add weekly slow tests for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
syu-w committed Nov 28, 2023
1 parent d64bc43 commit 5f3a064
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
107 changes: 107 additions & 0 deletions .github/workflows/tests-weekly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: weekly-tests
on:
pull_request:

schedule:
# Every Monday at 00:00 UTC
- cron: '0 0 * * 1'

# Allows triggering the workflow manually from the Actions tab
workflow_dispatch:
inputs:
enable_ssh_access:
type: boolean
description: 'Enable ssh access'
required: false
default: false

jobs:
integration-macos:
strategy:
matrix:
python: ["3.11"]
runs-on: macos-latest
timeout-minutes: 120
steps:
- name: Install Multipass
run: |
brew update
brew install multipass
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Configure environment
run: |
echo "::group::pip install"
python -m pip install 'tox>=4.6'
echo "::endgroup::"
echo "::group::Configure Multipass"
while ! multipass version
do
sleep 1
done
echo "::endgroup::"
- name: Setup Tox environments
run: tox run --colored yes -e integration-py${{ matrix.python }} --notest
- name: Enable ssh access
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.enable_ssh_access }}
with:
limit-access-to-actor: true
- name: Run integration tests on MacOS
env:
CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_INSTALL: 1
CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_UNINSTALL: 1
PYTEST_ADDOPTS: "--no-header -vv -rN"
run: |
.tox/.tox/bin/tox run --skip-pkg-install --no-list-dependencies --colored yes -e integration-py${{ matrix.python }}
integration-slow-macos:
strategy:
matrix:
python: ["3.11"]
runs-on: macos-latest
steps:
- name: Install Multipass
run: |
brew update
brew install multipass
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Configure environment
run: |
echo "::group::pip install"
python -m pip install 'tox>=4.6'
echo "::endgroup::"
echo "::group::Configure Multipass"
while ! multipass version
do
sleep 1
done
echo "::endgroup::"
- name: Setup Tox environments
run: tox run --colored yes -e integration-slow-py${{ matrix.python }} --notest
- name: Enable ssh access
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.enable_ssh_access }}
with:
limit-access-to-actor: true
- name: Run integration slow tests on MacOS
env:
CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_INSTALL: 1
CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_UNINSTALL: 1
PYTEST_ADDOPTS: "--no-header -vv -rN"
run: |
.tox/.tox/bin/tox run --skip-pkg-install --no-list-dependencies --colored yes -e integration-slow-py${{ matrix.python }}
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ testpaths = "tests"
xfail_strict = true
markers = [
"with_sudo: Test requires sudo",
"slow: slow tests",
"smoketest: basic tests",
]

[tool.coverage.run]
Expand Down
1 change: 1 addition & 0 deletions tests/integration/multipass/test_multipass_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_create_environment(installed_multipass, instance_name):
ALIASES.remove(BuilddBaseAlias.XENIAL)


@pytest.mark.slow()
@pytest.mark.parametrize("alias", ALIASES)
def test_launched_environment(alias, installed_multipass, instance_name, tmp_path):
"""Verify `launched_environment()` creates and starts an instance then stops
Expand Down
12 changes: 11 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ change_dir =
integration: tests/integration
commands =
unit: pytest {tty:--color=yes} --cov --cov-report=xml:{tox_root}/results/coverage-{env_name}.xml --junit-xml={tox_root}/results/test-results-{env_name}.xml {posargs}
integration: pytest {tty:--color=yes} --cov --cov-report=xml:{tox_root}/results/coverage-{env_name}.xml --junit-xml={tox_root}/results/test-results-{env_name}.xml -m "not smoketest" {posargs}
integration: pytest {tty:--color=yes} --cov --cov-report=xml:{tox_root}/results/coverage-{env_name}.xml --junit-xml={tox_root}/results/test-results-{env_name}.xml -m "not smoketest and not slow" {posargs}

[testenv:integration-smoketests-py3.{8,9,10,11,12}] # Configuration for all tests using pytest
base = testenv, test
Expand All @@ -67,6 +67,16 @@ change_dir =
integration: tests/integration
commands = pytest {tty:--color=yes} --cov --cov-report=xml:{tox_root}/results/coverage-{env_name}.xml --junit-xml={tox_root}/results/test-results-{env_name}.xml -m smoketest {posargs}

[testenv:integration-slow-py3.{8,9,10,11,12}] # Configuration for all tests using pytest
base = testenv, test
description =
integration: Run slow integration tests with pytest
labels =
integration-slow-tests-py3.{8,10,11}: integration-slow-tests
change_dir =
integration: tests/integration
commands = pytest {tty:--color=yes} --cov --cov-report=xml:{tox_root}/results/coverage-{env_name}.xml --junit-xml={tox_root}/results/test-results-{env_name}.xml -m slow {posargs}

[lint] # Standard linting configuration
package = editable
extras = lint
Expand Down

0 comments on commit 5f3a064

Please sign in to comment.