fix(lxd): update LXD version naming support LTS #2300
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: tests | |
on: | |
push: | |
branches: | |
- "main" | |
- "feature/*" | |
- "hotfix/*" | |
- "release/*" | |
- "renovate/*" | |
pull_request: | |
# 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: | |
linters: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Configure environment | |
run: | | |
echo "::group::Begin snap install" | |
echo "Installing snaps in the background while running apt and pip..." | |
sudo snap install --no-wait --classic pyright | |
sudo snap install --no-wait shellcheck | |
echo "::endgroup::" | |
echo "::group::pip install" | |
python -m pip install 'tox>=4' | |
echo "::endgroup::" | |
echo "::group::Create virtual environments for linting processes." | |
tox run --colored yes -m lint --notest | |
echo "::endgroup::" | |
echo "::group::Wait for snap to complete" | |
snap watch --last=install | |
echo "::endgroup::" | |
- name: Enable ssh access | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ inputs.enable_ssh_access }} | |
with: | |
limit-access-to-actor: true | |
- name: Run Linters | |
run: tox run --colored yes --skip-pkg-install --no-list-dependencies -m lint | |
unit-tests: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python versions on ${{ matrix.os }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: | | |
3.8 | |
3.9 | |
3.10 | |
3.11 | |
3.12-dev | |
cache: 'pip' | |
- name: Configure environment | |
run: | | |
echo "::group::pip install" | |
python -m pip install 'tox>=4.6' | |
echo "::endgroup::" | |
mkdir -p results | |
- name: Setup Tox environments | |
run: tox run --colored yes -m unit-tests --notest | |
- name: Enable ssh access | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ inputs.enable_ssh_access }} | |
with: | |
limit-access-to-actor: true | |
- name: Test with tox | |
run: tox run --skip-pkg-install --no-list-dependencies --result-json results/tox-${{ matrix.os }}.json --colored yes -m unit-tests | |
env: | |
PYTEST_ADDOPTS: "--no-header -vv -rN" | |
- name: Upload code coverage | |
uses: codecov/codecov-action@v4 | |
with: | |
directory: ./results/ | |
files: coverage*.xml | |
- name: Upload test results | |
if: success() || failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.os }} | |
path: results/ | |
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@v5 | |
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 }}" | |
integration-smoketests-macos: | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ["3.11"] | |
os: [macos-13] | |
runs-on: ${{ matrix.os }} | |
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@v5 | |
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-smoketests-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 smoketests 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-smoketests-py${{ matrix.python }} |