Skip to content

Commit

Permalink
Merge pull request #11 from vladistan/add-python-checks
Browse files Browse the repository at this point in the history
Merging this pull request because this code has not yet broken at runtime and adding the right tooling comes first.
  • Loading branch information
AdamFinkle authored Jul 30, 2024
2 parents f82c41a + dc32b98 commit 48a09e2
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 84 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pre-commit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ name: Run pre-commit hooks

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: python

on: [push]


jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install Nox
run: pip install '.[dev]'
- name: Test with Nox
run: nox -s tests-${{ matrix.python-version }}
types:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: pip
- name: Install Nox and group dependencies
run: pip install '.[dev]'
- name: Test with Nox
run: nox -s mypy-3.12
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ venv/
build/
dist/
*.egg-info/
.coverage*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Simple steps for development setup:
1. Clone the git repository.
3. Navigate to any directory and create a [virtual environment](https://docs.python.org/3/library/venv.html#creating-virtual-environments) and activate it
4. The following commands can be run from inside the top-level greenbutton_objects folder while the virtual environment is active
2. `pip install -e .` builds the [python egg](https://stackoverflow.com/questions/2051192/what-is-a-python-egg) for greenbutton_objects and then installs greenbutton_objects
3. `pip install -r requirements-dev.txt` which installs the libraries required to develop greenbutton_objects
5. `pip install -e .` installs the greenbutton_objects package into the virtual environment as an editable package. Meaning that any changes you make to the code will be reflected immediately without having to reinstall.
6. `pip install '.[dev]'` which installs the libraries required to develop greenbutton_objects. Make sure to include single quotes around `[dev]` they are important.

Then, you should be able to run `pytest`, also from any directory, and see the test run successfully.

Expand Down
35 changes: 35 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Nox sessions."""

import nox

package = "greenbutton_objects"
python_versions = ["3.12", "3.11", "3.10", "3.9"]
nox.needs_version = ">= 2024.4.15"
nox.options.sessions = (
"safety",
"mypy",
"tests",
)


@nox.session(python=python_versions[0])
def safety(session) -> None:
"""Scan dependencies for insecure packages."""
session.install(".[dev]")
session.install("safety")
session.run("safety", "check", "--full-report")


@nox.session(python=python_versions)
def mypy(session) -> None:
"""Type-check using mypy."""
args = session.posargs or ["src"]
session.install(".[dev]")
session.run("mypy", *args)


@nox.session(python=python_versions)
def tests(session) -> None:
"""Run the test suite."""
session.install(".[dev]")
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
25 changes: 16 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ classifiers = [
"Programming Language :: Python :: 3"
]
keywords = ["feed", "reader", "tutorial"]
requires-python = ">=2.7"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
"black",
"bumpver",
"mypy",
"pip-tools",
"pydocstyle",
"pytest",
"pytest-cov",
"ruff"
"black==24.4.2",
"bumpver==2023.1129",
"mypy==1.11.0",
"nox==2024.4.15",
"pip-tools==7.4.1",
"pytest==8.3.2",
"pytest-cov==5.0.0",
"pytest_sugar==1.0.0",
"ruff==0.5.5"
]

[project.urls]
Expand Down Expand Up @@ -72,6 +73,12 @@ push = true
profile = "black"
line_length = 110

[tool.mypy]
strict = true
# TODO: Remove this when explicit-override is enabled by default in strict mode
# https://github.com/python/mypy/issues/17511
enable_error_code = ["explicit-override"]

[tool.ruff]
line-length = 110
target-version = "py38"
Expand Down
66 changes: 0 additions & 66 deletions requirements-dev.txt

This file was deleted.

6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

0 comments on commit 48a09e2

Please sign in to comment.