From 40f9cee084730d490da1d514506c9112b8bd1eb2 Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Wed, 18 Sep 2024 20:14:26 -0400 Subject: [PATCH] ci: add github lint and test workflow --- .github/workflows/tests.yaml | 45 ++++++++++++++++++++++++++++++++++++ Makefile | 7 +++--- sysdeps.mk | 1 + tox.ini | 4 +++- 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..fde8e8d --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,45 @@ +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] + python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13-dev'] + 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: ${{ matrix.python }} + cache: 'pip' + - name: Install dependencies + run: make setup + - name: Run tests + run: make test + env: + PYTEST_ADDOPTS: "--no-header -vv -rN" diff --git a/Makefile b/Makefile index 70d1763..e2c4bda 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,12 @@ $(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 touch $(SYSDEPS_INSTALLED) diff --git a/sysdeps.mk b/sysdeps.mk index dcb9005..34327ae 100644 --- a/sysdeps.mk +++ b/sysdeps.mk @@ -1 +1,2 @@ APT_SYSDEPS = python3-pip python3-setuptools libsodium-dev libffi-dev libssl-dev tox isort +BREW_SYSDEPS = python3 libsodium libffi openssl tox isort diff --git a/tox.ini b/tox.ini index b9b393d..706eac9 100644 --- a/tox.ini +++ b/tox.ini @@ -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 = py27 +# If the system has tox < 4.8, installs a newer tox in a venv. +minversion = 4.8 [testenv] setenv =