Skip to content

Commit

Permalink
Run unit tests in CI (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
simondeziel authored Oct 3, 2024
2 parents 9d485a4 + b112726 commit 337fb9e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
49 changes: 29 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Repository checkout
uses: actions/checkout@v4
Expand All @@ -23,16 +23,38 @@ jobs:

- name: Install dependencies
run: |
pip install --upgrade pip tox
python3 -m venv venv
. ./venv/bin/activate
./venv/bin/pip install --require-virtualenv --upgrade pip tox
- name: Lint Python files
run: |
. ./venv/bin/activate
tox -e lint
- name: Typecheck Python files
run: |
. ./venv/bin/activate
tox -e check
unit-tests:
name: Unit tests
runs-on: ubuntu-24.04
steps:
- name: Repository checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
python3 -m venv venv
. ./venv/bin/activate
./venv/bin/pip install --require-virtualenv --upgrade pip tox
- name: Run unit tests
run: |
. ./venv/bin/activate
tox -e unit
tests:
name: Tests
strategy:
Expand Down Expand Up @@ -65,30 +87,17 @@ jobs:
- name: Install dependencies
run: |
set -x
pip install --upgrade pip tox codecov
python3 -m venv venv
. ./venv/bin/activate
./venv/bin/pip install --require-virtualenv --upgrade pip tox codecov
- name: Coverage
run: |
. ./venv/bin/activate
tox -e coverage
codecov
- name: Integration
run: |
. ./venv/bin/activate
integration/run-integration-tests
publish:
name: Publish
runs-on: ubuntu-22.04
if: startsWith(github.event.ref, 'refs/tags')

permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ github.ref }}
generateReleaseNotes: true
16 changes: 9 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install_requires =
testing =
ddt >= 0.7.0
mock-services >= 0.3
pytest-cov == 5.0.0
pytest-cov >= 5.0.0
pytest >= 6.1.2
# mock-services is old and unmaintained. Doesn't work with newer versions
# of requests-mock. Thus, we have to pin it down.
Expand All @@ -37,9 +37,9 @@ testing =
# but mock-services depends on it for `pkg_resources`
setuptools
format =
black == 24.8.0
flake8 >= 2.5.0
isort == 5.13.2
black
flake8
isort
check =
mypy
doc =
Expand All @@ -48,7 +48,7 @@ doc =
[flake8]
show-source = True
ignore = E203, E266, E501, W503, W504
exclude = .git, .tox, dist, doc, *egg, build
exclude = .git, .tox, dist, doc, *egg, build, venv

[mypy]
ignore_missing_imports = True
Expand All @@ -67,10 +67,10 @@ upload-dir = doc/build/html

[tox:tox]
minversion = 1.6
envlist = lint,check,coverage
envlist = lint,check,coverage,format,integration,intregration-in-lxd,migration,unit
skipsdist = True

[testenv]
[testenv:unit]
usedevelop = True
setenv =
PYLXD_WARNINGS=none
Expand All @@ -81,6 +81,8 @@ commands =

[testenv:integration]
passenv = LXD_*
deps =
.[testing]
commands =
pytest integration {posargs}

Expand Down

0 comments on commit 337fb9e

Please sign in to comment.