diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1832e76d..6c41fac2 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,6 +21,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.10' + cache: 'pip' - name: Configure environment run: | echo "::group::Begin snap install" @@ -38,7 +39,7 @@ jobs: snap watch --last=install echo "::endgroup::" - name: Run Linters - run: tox run -m lint + run: tox run --skip-pkg-install --no-list-dependencies -m lint unit-tests: strategy: matrix: @@ -57,16 +58,20 @@ jobs: 3.10 3.11 3.12-dev + cache: 'pip' - name: Configure environment run: | echo "::group::pip install" - python -m pip install 'tox>=4' tox-gh + python -m pip install 'tox>=4.6' tox-gh echo "::endgroup::" mkdir -p results - name: Setup Tox environments run: tox run -m unit-tests --notest - name: Test with tox - run: tox run-parallel --parallel all --parallel-no-spinner --skip-pkg-install --result-json results/tox-${{ matrix.platform }}.json -m unit-tests -- --no-header --quiet -rN + # use `tox` instead of `.tox/.tox/bin/tox` to support Windows + run: tox run --skip-pkg-install --no-list-dependencies --result-json results/tox-${{ matrix.platform }}.json -m unit-tests + env: + PYTEST_ADDOPTS: "--no-header -vv -rN" - name: Upload code coverage uses: codecov/codecov-action@v3 with: @@ -98,10 +103,11 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python.system-version }} + cache: 'pip' - name: Configure environment run: | echo "::group::pip install" - python -m pip install 'tox>=4' + python -m pip install 'tox>=4.6' echo "::endgroup::" echo "::group::Configure LXD" sudo groupadd --force --system lxd @@ -114,13 +120,17 @@ jobs: sudo iptables -I DOCKER-USER -i lxdbr0 -j ACCEPT sudo iptables -I DOCKER-USER -o lxdbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT echo "::endgroup::" + - name: Setup Tox environments + run: tox run -e integration-${{ matrix.python.tox-version }} --notest - name: Run integration tests on Linux + env: + CRAFT_PROVIDERS_TESTS_ENABLE_SNAP_INSTALL: 1 + CRAFT_PROVIDERS_TESTS_ENABLE_LXD_INSTALL: 1 + CRAFT_PROVIDERS_TESTS_ENABLE_LXD_UNINSTALL: 1 + PYTEST_ADDOPTS: "--no-header -vv -rN" run: | - export CRAFT_PROVIDERS_TESTS_ENABLE_SNAP_INSTALL=1 - export CRAFT_PROVIDERS_TESTS_ENABLE_LXD_INSTALL=1 - export CRAFT_PROVIDERS_TESTS_ENABLE_LXD_UNINSTALL=1 sg lxd -c "lxc version" - sg lxd -c "tox run -e integration-${{ matrix.python.tox-version }}" + sg lxd -c ".tox/.tox/bin/tox run --skip-pkg-install --no-list-dependencies -e integration-${{ matrix.python.tox-version }}" integration-tests-macos: strategy: matrix: @@ -140,10 +150,11 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python.system-version }} + cache: 'pip' - name: Configure environment run: | echo "::group::pip install" - python -m pip install 'tox>=4' + python -m pip install 'tox>=4.6' echo "::endgroup::" echo "::group::Install Multipass" brew update @@ -155,8 +166,12 @@ jobs: sleep 20 multipass version echo "::endgroup::" + - name: Setup Tox environments + run: tox run -e integration-${{ matrix.python.tox-version }} --notest - 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: | - export CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_INSTALL=1 - export CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_UNINSTALL=1 - tox run -e integration-${{ matrix.python.tox-version }} + .tox/.tox/bin/tox run --skip-pkg-install --no-list-dependencies -e integration-${{ matrix.python.tox-version }} diff --git a/tox.ini b/tox.ini index 3d16961b..386b1ed7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] env_list = # Environments to run when called with no parameters. - lint-{black,ruff,pyright,shellcheck,codespell,docs} + lint-{black,ruff,pyright,shellcheck,codespell} test-{py38,py310,py311} -minversion = 4.5 +minversion = 4.6 # Tox will use these requirements to bootstrap a venv if necessary. # tox-igore-env-name-mismatch allows us to have one virtualenv for all linting. # By setting requirements here, we make this INI file compatible with older