Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run unit tests in CI #611

Merged
merged 8 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
hamistao marked this conversation as resolved.
Show resolved Hide resolved
. ./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
hamistao marked this conversation as resolved.
Show resolved Hide resolved
./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