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

ci: add github lint and test workflow #101

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
51 changes: 51 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: test
on:
push:
branches:
- "master"
- "feature/*"
- "hotfix/*"
- "release/*"
- "renovate/*"
pull_request:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: make setup
- name: Run Linters
run: make lint
test:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
cache: 'pip'
- name: Install dependencies
run: |
make setup
pip install tox-gh
- name: Run tests
run: tox -m ci
env:
PYTEST_ADDOPTS: "--no-header -vv -rN"
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# Copyright 2017 Canonical Ltd.
# Copyright 2017,2024 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
include sysdeps.mk

PYTHON = python
# Since the python-tox package in Ubuntu uses Python 3, use pip to install tox
# instead. This also works on OSX where tox is not present in Homebrew.
PIP_SYSDEPS = tox

PIP = sudo pip install $(1)

SYSDEPS_INSTALLED = .sysdeps-installed
DEVENV = venv
Expand All @@ -21,17 +16,18 @@ $(DEVENVPIP):
$(SYSDEPS_INSTALLED): sysdeps.mk
ifeq ($(shell command -v apt-get > /dev/null; echo $$?),0)
sudo apt-get install --yes $(APT_SYSDEPS)
else ifeq ($(shell command -v brew > /dev/null; echo $$?),0)
brew install $(BREW_SYSDEPS)
else
@echo 'System dependencies can only be installed automatically on'
@echo 'systems with "apt-get". On OSX you can manually use Homebrew'
@echo 'if there are missing dependencies corresponding to the following'
@echo 'Debian packages:'
@echo 'systems with "apt-get" or "brew". Dependencies correspond to'
@echo 'the following Debian packages:'
@echo '$(APT_SYSDEPS).'
endif
sudo pip3 install $(PIP_SYSDEPS)
@command -v tox > /dev/null || (echo "Could not find tox on the PATH"; exit 1)
@command -v isort > /dev/null || (echo "Could not find isort on the PATH"; exit 1)
touch $(SYSDEPS_INSTALLED)


.PHONY: check
check: setup lint
@tox
Expand Down
3 changes: 2 additions & 1 deletion sysdeps.mk
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
APT_SYSDEPS = python3-pip python3-setuptools libsodium-dev libffi-dev libssl-dev
APT_SYSDEPS = python3-pip python3-setuptools libsodium-dev libffi-dev libssl-dev tox isort
BREW_SYSDEPS = python3 libsodium libffi openssl tox isort
7 changes: 4 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Copyright 2017 Canonical Ltd.
# Copyright 2017,2024 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.

coverage==7.3.2
extras==1.0.0
fixtures==3.0.0
flake8==2.4.0
httmock==1.2.5
httmock==1.4.0
linecache2==1.0.0
mock==1.0.1
mock==5.1.0
nose2==0.13.0
pbr==3.1.1
python-mimeparse==1.6.0
setuptools==75.1.0
testtools==2.3.0; python_version<"3"
testtools==2.5.0; python_version>="3"
traceback2==1.4.0
Expand Down
9 changes: 7 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Copyright 2017 Canonical Ltd.
# Copyright 2017,2024 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.

[tox]
envlist = lint, py27, py35, docs
envlist = lint, py3.8, docs
# envlist = py27
# If the system has tox < 4.8, installs a newer tox in a venv.
minversion = 4.8

[testenv]
setenv =
Expand All @@ -15,6 +17,9 @@ commands =
deps =
-r{toxinidir}/test-requirements.txt

[testenv:py3.{8,9,10,11,12,13}]
labels = ci

[testenv:devenv]
envdir = devenv
usedevelop = True
Expand Down