From ad13a6927388031064d0b81a6960bc189baaea53 Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Wed, 18 Sep 2024 17:41:44 -0400 Subject: [PATCH 1/3] build: make most make items work on noble This updates the Makefile and apt dependencies to work on Ubuntu 24.04 --- Makefile | 8 +------- sysdeps.mk | 2 +- test-requirements.txt | 3 ++- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 390c954..70d1763 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -28,7 +23,6 @@ else @echo 'Debian packages:' @echo '$(APT_SYSDEPS).' endif - sudo pip3 install $(PIP_SYSDEPS) touch $(SYSDEPS_INSTALLED) diff --git a/sysdeps.mk b/sysdeps.mk index d3bffee..dcb9005 100644 --- a/sysdeps.mk +++ b/sysdeps.mk @@ -1 +1 @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index 27a0b39..2f26d5e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,4 @@ -# Copyright 2017 Canonical Ltd. +# Copyright 2017,2024 Canonical Ltd. # Licensed under the LGPLv3, see LICENCE file for details. coverage==7.3.2 @@ -11,6 +11,7 @@ mock==1.0.1 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 From 4efe7332f1a9c3070fa56168e92a17a7272acecc Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Wed, 18 Sep 2024 20:51:12 -0400 Subject: [PATCH 2/3] Add brew installation to Makefile --- Makefile | 18 +++++++----------- sysdeps.mk | 3 ++- tox.ini | 4 +++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 390c954..e5eacdf 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/sysdeps.mk b/sysdeps.mk index d3bffee..34327ae 100644 --- a/sysdeps.mk +++ b/sysdeps.mk @@ -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 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 = From 13f5d892b89a69823b361228fd202fd2d0de57e0 Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Wed, 18 Sep 2024 21:07:46 -0400 Subject: [PATCH 3/3] Add GitHub workflow --- .github/workflows/tests.yaml | 51 ++++++++++++++++++++++++++++++++++++ test-requirements.txt | 4 +-- tox.ini | 5 +++- 3 files changed, 57 insertions(+), 3 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..2629cbd --- /dev/null +++ b/.github/workflows/tests.yaml @@ -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" diff --git a/test-requirements.txt b/test-requirements.txt index 2f26d5e..0984b89 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,9 +5,9 @@ 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 diff --git a/tox.ini b/tox.ini index 706eac9..f9860bf 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ # 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 @@ -17,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