From 3db275cbe2426624b8a7c339dfe6b91ef36ab347 Mon Sep 17 00:00:00 2001 From: oikarinen <7252104+oikarinen@users.noreply.github.com> Date: Fri, 29 Nov 2024 04:39:42 +0200 Subject: [PATCH] fix(ci): use poetry (#1183) For managing the python dependencies, running the unit tests and spellchecker. This makes it easier for everyone to have same environment as CI. Also includes few cosmetic edits for style for the ci.yml --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++------------ tests/poetry.lock | 29 ++++++++++++++++++++------- tests/pyproject.toml | 7 ++++++- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4a0393..ba5557a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: branches: [main] jobs: lint: - runs-on: 'ubuntu-latest' + runs-on: ubuntu-latest steps: - name: Check out code. uses: actions/checkout@v4 @@ -44,26 +44,46 @@ jobs: steps: - name: Check out code. uses: actions/checkout@v4 + - name: Install poetry + run: pip install poetry + - name: Set up Python + uses: actions/setup-python@v5 + with: + cache: 'poetry' + cache-dependency-path: "tests/pyproject.toml" + python-version-file: "tests/pyproject.toml" + - name: Install dependencies + run: | + cd tests || exit + poetry install --only dev - name: spell check run: | - pip install codespell==2.2 - git grep --cached -l '' | grep -v -e 'History\.md' -e 'AUTHORS' -e 'man/.*\.1' -e 'man/.*\.html' | xargs codespell --ignore-words=.github/.ignore_words + cd tests + git grep --cached -l '' .. | \ + grep -v -e 'History\.md' -e 'AUTHORS' -e 'man/.*\.1' -e 'man/.*\.html' | \ + xargs poetry run codespell --ignore-words=../.github/.ignore_words test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python 3.12 + - name: Install poetry + run: pip install poetry + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.12' + cache: 'poetry' + cache-dependency-path: "tests/pyproject.toml" + python-version-file: "tests/pyproject.toml" - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install pytest==8.1.2 GitPython==3.1.43 testpath==0.6.0 + cd tests || exit + poetry install --only test - name: Unit test - run: make test + run: | + cd tests + poetry run pytest build: strategy: @@ -78,11 +98,9 @@ jobs: uses: actions/checkout@v4 - name: Linux Install if: matrix.platform == 'ubuntu-latest' - run: | - sudo apt-get install -y bsdmainutils + run: sudo apt-get install -y bsdmainutils - name: Script - run: | - ./check_integrity.sh + run: ./check_integrity.sh - name: Brew release if: matrix.platform == 'macos-latest' run: | diff --git a/tests/poetry.lock b/tests/poetry.lock index 5fa5e29..bb52a52 100644 --- a/tests/poetry.lock +++ b/tests/poetry.lock @@ -1,4 +1,19 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. + +[[package]] +name = "codespell" +version = "2.2.0" +description = "Codespell" +optional = false +python-versions = ">=3.6" +files = [ + {file = "codespell-2.2.0-py3-none-any.whl", hash = "sha256:3cc3fcb484a8302683add19e7d11504c79c79b10d4ea0675409417a044b27374"}, + {file = "codespell-2.2.0.tar.gz", hash = "sha256:3dce0cd1348d277f8d934d1d4dcbbf510f9ddfd1b9005e9b25fb983189962561"}, +] + +[package.extras] +dev = ["check-manifest", "flake8", "pytest", "pytest-cov", "pytest-dependency"] +hard-encoding-detection = ["chardet"] [[package]] name = "colorama" @@ -56,13 +71,13 @@ files = [ [[package]] name = "packaging" -version = "24.0" +version = "24.2" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, - {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, ] [[package]] @@ -127,5 +142,5 @@ test = ["pytest"] [metadata] lock-version = "2.0" -python-versions = "^3.11" -content-hash = "e73f9840c5f034acbd9b1ebc082e7ce4600ac3235991e57cd825c261a5f2e14e" +python-versions = "^3.12" +content-hash = "e730a1e6e7fd2f51858e8c8cfa8b56d606eadd7a0a629ca8af078904721a5159" diff --git a/tests/pyproject.toml b/tests/pyproject.toml index f12d487..f04e61d 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -8,11 +8,16 @@ license = "MIT" readme = "README.md" [tool.poetry.dependencies] -python = "^3.11" +python = "^3.12" + +[tool.poetry.group.test.dependencies] pytest = "8.1.2" gitpython = "3.1.43" testpath = "0.6.0" +[tool.poetry.group.dev.dependencies] +codespell = "2.2" + [tool.pytest.ini_options] minversion = "7.4" addopts = "-ra -q"