Skip to content

Commit

Permalink
ci: add tox
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
  • Loading branch information
mr-cal committed Jun 15, 2023
1 parent 511996d commit e236924
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 189 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- [ ] Have you followed the guidelines for contributing?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `tox`?

-----
104 changes: 54 additions & 50 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
name: Tests
name: tests

on:
push:
branches:
- "main"
- "feature/*"
- "release/*"
- "hotfix/*"
- "release/*"
pull_request:

# Allows triggering the workflow manually from the Actions tab
workflow_dispatch:

jobs:
linters:
runs-on: ubuntu-latest
Expand All @@ -23,7 +20,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.10'
- name: Configure environment
run: |
echo "::group::Begin snap install"
Expand All @@ -32,61 +29,64 @@ jobs:
sudo snap install --no-wait shellcheck
echo "::endgroup::"
echo "::group::pip install"
python -m pip install -U .[dev,lint,types]
python -m pip install 'tox>=4' tox-gh
echo "::endgroup::"
echo "::group::Create virtual environments for linting processes."
tox run -m lint --notest
echo "::endgroup::"
echo "::group::Wait for snap to complete"
snap watch --last=install
echo "::endgroup::"
- name: Run black
run: |
make test-black
- name: Run ruff
run: |
make test-ruff
- name: Run codespell
run: |
make test-codespell
- name: Run mypy
run: |
make test-mypy
- name: Run pyright
run: |
make test-pyright
- name: Run shellcheck
run: |
make test-shellcheck
- name: Run yamllint
run: |
make test-yaml
- name: Run Linters
run: tox run -m lint
unit-tests:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.10", "3.11", "3.12-dev"]
runs-on: ${{ matrix.os }}
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python on ${{ matrix.platform }}
- name: Set up Python versions on ${{ matrix.platform }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: |
3.8
3.9
3.10
3.11
3.12-dev
- name: Configure environment
run: |
echo "::group::pip install"
python -m pip install -U .[dev]
python -m pip install -U -e .
python -m pip install 'tox>=4' tox-gh
echo "::endgroup::"
- name: Run unit tests
run: make test-units

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
- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
directory: ./results/
files: coverage*.xml
- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.platform }}
path: results/
integration-tests-linux:
strategy:
matrix:
python-version: ["3.8", "3.10", "3.11", "3.12-dev"]
python: [
{system-version: "3.8", tox-version: "py38"},
{system-version: "3.10", tox-version: "py310"},
{system-version: "3.11", tox-version: "py311"},
{system-version: "3.12-dev", tox-version: "py312"},
]
# does not work with canonical/setup-lxd github action (see https://github.com/canonical/craft-providers/issues/271)
runs-on: ubuntu-latest
steps:
Expand All @@ -97,11 +97,11 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.python.system-version }}
- name: Configure environment
run: |
echo "::group::pip install"
python -m pip install -U .[dev]
python -m pip install 'tox>=4'
echo "::endgroup::"
echo "::group::Configure LXD"
sudo groupadd --force --system lxd
Expand All @@ -120,12 +120,16 @@ jobs:
export CRAFT_PROVIDERS_TESTS_ENABLE_LXD_INSTALL=1
export CRAFT_PROVIDERS_TESTS_ENABLE_LXD_UNINSTALL=1
sg lxd -c "lxc version"
sg lxd -c "make test-integrations"
sg lxd -c "tox run -e integration-${{ matrix.python.tox-version }}"
integration-tests-macos:
strategy:
matrix:
python-version: ["3.8", "3.10", "3.11", "3.12-dev"]
python: [
{system-version: "3.8", tox-version: "py38"},
{system-version: "3.10", tox-version: "py310"},
{system-version: "3.11", tox-version: "py311"},
{system-version: "3.12-dev", tox-version: "py312"},
]
runs-on: macos-latest
steps:
- name: Checkout code
Expand All @@ -135,11 +139,11 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.python.system-version }}
- name: Configure environment
run: |
echo "::group::pip install"
python -m pip install -U -e .[dev]
python -m pip install 'tox>=4'
echo "::endgroup::"
echo "::group::Install Multipass"
brew update
Expand All @@ -155,4 +159,4 @@ jobs:
run: |
export CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_INSTALL=1
export CRAFT_PROVIDERS_TESTS_ENABLE_MULTIPASS_UNINSTALL=1
make test-integrations
tox run -e integration-${{ matrix.python.tox-version }}
104 changes: 0 additions & 104 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@


def run_apidoc(_):
from sphinx.ext.apidoc import main
from sphinx.ext.apidoc import main # type: ignore
import os
import sys

Expand Down
Loading

0 comments on commit e236924

Please sign in to comment.