From df6ea9b3443d7736759c81ab80996aca6fc5920e Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Sun, 11 Sep 2022 23:30:13 +0200 Subject: [PATCH 1/5] Pin sqlalchemy version in requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index eeb4d54c..c1066c96 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,5 +13,5 @@ PyNaCl~=1.4.0 pyrad~=2.1 pyroute2~=0.5.14 pysnmp~=4.4.12 -SQLAlchemy~=1.3.22 +SQLAlchemy~=1.3.22,<1.4 systemd-python==234 From e7757fb5aace2ef3637ef7614c2bea36b94987ae Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Sun, 11 Sep 2022 23:31:29 +0200 Subject: [PATCH 2/5] [ci] Add requirements for testing/linting/docs and add CI workflow try py3.10 in CI --- .github/workflows/ci.yml | 78 ++++++++++++++++++++++++++++++++++++++++ requirements.doc.txt | 5 +++ requirements.lint.txt | 3 ++ requirements.test.txt | 3 ++ 4 files changed, 89 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 requirements.doc.txt create mode 100644 requirements.lint.txt create mode 100644 requirements.test.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3f5145bb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,78 @@ +name: Hades CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + python-lint: + runs-on: ubuntu-latest + steps: + - name: Check out hades and submodules + uses: actions/checkout@v2 + with: + submodules: recursive + - name: install dev dependencies + # libgirepository1.0-dev required for PyGObject setup + run: > + sudo apt update + && sudo apt install + libsystemd-dev + libgirepository1.0-dev + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' + - name: print pip cache information + run: pip cache info && pip cache list + - name: ensure presence of `wheel` + run: pip install wheel + - name: install pip dependencies + run: > + pip install + vendor/arpreq + -e . + -r requirements.txt + -r requirements.doc.txt + -r requirements.lint.txt + -r requirements.test.txt + + # TODO add script rendering mypy warnings as annotations + - name: Execute mypy + run: mypy + + - name: execute unittests + run: pytest -v tests + + - name: Build sphinx docs + run: make SPHINXOPTS="-EN -w sphinx.log" -C docs html + # TODO add script rendering annotations + # - name: Render sphinx warnings as annotations + # run: python ./scripts/render_sphinx_log.py docs/sphinx.log + - name: Publish sphinx docs as pages artifact + uses: actions/upload-pages-artifact@v1 + with: + path: docs/build/html + + # see https://github.com/actions/deploy-pages#usage + deploy-docs: + if: (github.event_name == 'push') && github.ref == 'refs/heads/main' + # Add a dependency to the build job + needs: python-lint + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + # Deploy to the github-pages environment. see + # https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment + # for general information abotu environments. + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy sphinx docs to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/requirements.doc.txt b/requirements.doc.txt new file mode 100644 index 00000000..635313ac --- /dev/null +++ b/requirements.doc.txt @@ -0,0 +1,5 @@ +guzzle-sphinx-theme~=0.7.11 +sphinx~=5.1.1 +sphinx-argparse~=0.3.1 +sphinx-autobuild~=2021.3.14 +sphinx-paramlinks~=0.5.4 diff --git a/requirements.lint.txt b/requirements.lint.txt new file mode 100644 index 00000000..38fd9570 --- /dev/null +++ b/requirements.lint.txt @@ -0,0 +1,3 @@ +mypy~=0.971 +types-docutils~=0.19.1 +types-setuptools~=65.3.0 diff --git a/requirements.test.txt b/requirements.test.txt new file mode 100644 index 00000000..2bbcfa2c --- /dev/null +++ b/requirements.test.txt @@ -0,0 +1,3 @@ +pytest~=7.1.3 +pytest-mock~=3.8.2 +trio~=0.21.0 From e836959f31a63f3810dd812471d55a59c807acdb Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Fri, 21 Oct 2022 01:00:16 +0200 Subject: [PATCH 3/5] [ci] run configure script with stubs to provide `constants.py` --- .github/workflows/ci.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f5145bb..29c0a92a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,8 @@ jobs: run: > sudo apt update && sudo apt install + bash + build-essential libsystemd-dev libgirepository1.0-dev - uses: actions/setup-python@v4 @@ -38,7 +40,19 @@ jobs: -r requirements.doc.txt -r requirements.lint.txt -r requirements.test.txt - + - name: run configure script + run: > + ./configure.mk + IFDOWN= + IFUP= + IPSET= + KEEPALIVED= + RADIUSD= + UNBOUND= + UNBOUND_ANCHOR= + UNBOUND_CHECKCONF= + UNBOUND_CONTROL= + UWSGI= # TODO add script rendering mypy warnings as annotations - name: Execute mypy run: mypy From 173b272e870684e3b3e10fa5ce7ac53fad05cf53 Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Sat, 22 Oct 2022 13:18:07 +0200 Subject: [PATCH 4/5] [ci] skip tests which need the dhcp lease script to run --- .github/workflows/ci.yml | 2 +- pyproject.toml | 9 +++++++++ tests/test_lease_script.py | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29c0a92a..12a67d89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: run: mypy - name: execute unittests - run: pytest -v tests + run: pytest -v tests -m "not needs_build" - name: Build sphinx docs run: make SPHINXOPTS="-EN -w sphinx.log" -C docs html diff --git a/pyproject.toml b/pyproject.toml index 2c2ce58d..ab3b3a82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,15 @@ requires = ["setuptools", "wheel"] # when used with `--no-use-pep517`: # pip install --no-use-pep517 -e . +[tool.pytest.ini_options] +addopts = [ + "--strict-markers", +] +markers = [ + "needs_build: marks tests which need programs compiled with C", +] + + [tool.mypy] python_version = "3.9" follow_imports = "silent" diff --git a/tests/test_lease_script.py b/tests/test_lease_script.py index 27c25b10..b59ad286 100644 --- a/tests/test_lease_script.py +++ b/tests/test_lease_script.py @@ -33,6 +33,9 @@ from hades.leases.server import Mode, Server +pytestmark = pytest.mark.needs_build + + # Available since CPython 3.10 F_GETPIPE_SZ = getattr(fcntl, "F_GETPIPE_SZ", 1032) AncillaryData = List[Tuple[int, int, bytes]] From 62052e8818066ab16250344e5c2f55f981f7cf10 Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Sat, 22 Oct 2022 13:58:14 +0200 Subject: [PATCH 5/5] [ci] pin transitive markupsafe dependency --- requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requirements.txt b/requirements.txt index c1066c96..ff2fccc7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,15 @@ +# These requirements should be `install_requires`, +# pinned to the versions packaged in the respective debian release. arpreq~=0.3.4 Babel~=2.8.0 celery~=5.0.0 Flask~=1.1.2 Flask-Babel~=0.12.2 Jinja2~=2.11.3 +# transitive pin, because Jinja2~=2.11.3 does not work with MarkupSafe>=2.1.0 +# Pinning a little more strict (1.x instead of 2.0.x) to be consistent with +# the rule of pinning to the versions packaged in debian. +MarkupSafe~=1.1.1,<2.1.0 kombu~=5.0.2 netaddr~=0.7.19 psycopg2-binary~=2.8.6