From 5f3a0641544e09b177adc3a9048e3599d7c81b1b Mon Sep 17 00:00:00 2001 From: Sheng Yu Date: Tue, 28 Nov 2023 11:02:02 -0500 Subject: [PATCH] tests(ci): add weekly slow tests for macOS --- .github/workflows/tests-weekly.yaml | 107 ++++++++++++++++++ pyproject.toml | 2 + .../multipass/test_multipass_provider.py | 1 + tox.ini | 12 +- 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests-weekly.yaml diff --git a/.github/workflows/tests-weekly.yaml b/.github/workflows/tests-weekly.yaml new file mode 100644 index 00000000..3c70ba47 --- /dev/null +++ b/.github/workflows/tests-weekly.yaml @@ -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 }} diff --git a/pyproject.toml b/pyproject.toml index 37b3033e..ec1c1a68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,6 +138,8 @@ testpaths = "tests" xfail_strict = true markers = [ "with_sudo: Test requires sudo", + "slow: slow tests", + "smoketest: basic tests", ] [tool.coverage.run] diff --git a/tests/integration/multipass/test_multipass_provider.py b/tests/integration/multipass/test_multipass_provider.py index 86755d5a..de07b8ce 100644 --- a/tests/integration/multipass/test_multipass_provider.py +++ b/tests/integration/multipass/test_multipass_provider.py @@ -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 diff --git a/tox.ini b/tox.ini index 050e61e1..ea9ee7ca 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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