build: limit CI integration tests to relevant sections of the code. #1
Workflow file for this run
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
name: integration tests | |
on: | |
push: | |
branches: | |
- "main" | |
- "feature/*" | |
- "hotfix/*" | |
- "release/*" | |
- "renovate/*" | |
pull_request: | |
paths-ignore: | |
- "tests/unit/**" | |
- "tests/integration/multipass/**" | |
- "craft_providers/multipass/**" | |
- "docs/**" | |
# 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-tests-linux: | |
strategy: | |
fail-fast: false | |
matrix: | |
python: [ | |
{system-version: "3.8", tox-version: "py3.8"}, | |
{system-version: "3.10", tox-version: "py3.10"}, | |
{system-version: "3.11", tox-version: "py3.11"}, | |
{system-version: "3.12-dev", tox-version: "py3.12"}, | |
] | |
# does not work with canonical/setup-lxd github action (see https://github.com/canonical/craft-providers/issues/271) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python.system-version }} | |
cache: 'pip' | |
- name: Configure environment | |
run: | | |
echo "::group::clean disk" | |
# removing the android sdk and libraries doubles available disk space from 14GB to 28GB | |
sudo rm -rf /usr/local/lib/android/ | |
echo "::endgroup::" | |
echo "::group::pip install" | |
python -m pip install 'tox>=4.6' | |
echo "::endgroup::" | |
echo "::group::Configure LXD" | |
sudo groupadd --force --system lxd | |
sudo usermod --append --groups lxd $USER | |
sudo snap refresh lxd --channel=latest/stable | |
sudo snap start lxd | |
sudo lxd waitready --timeout=30 | |
sudo lxd init --auto | |
# iptables calls from https://github.com/canonical/setup-lxd/blob/main/action.yml | |
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 --colored yes -e integration-${{ matrix.python.tox-version }} --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 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: | | |
sg lxd -c "lxc version" | |
sg lxd -c ".tox/.tox/bin/tox run --skip-pkg-install --no-list-dependencies --colored yes -e integration-${{ matrix.python.tox-version }}" |