Skip to content
Merged
45 changes: 45 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
pip install poetry
# Install poetry dependencies only.
poetry install
#### pip install tox tox-gh-actions
- name: Pylint checks
run: |
tox -e lint
- name: Formatting checks
run: |
tox -e format
- name: Pytest
run: |
tox -e pytest
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "range-query-intervals"
name = "intervals"
version = "0.1.0"
description = "Tools and implementations of Range Queries"
authors = ["Alan Ponte <alanjponte@gmail.com>"]
Expand All @@ -18,6 +18,6 @@ pytest="^8.4.1"
SQLAlchemy = "^2.0"
pylint = "3.3.7"

#[build-system]
#requires = ["poetry-core"]
#build-backend = "poetry.core.masonry.api"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
48 changes: 29 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# by letting tox manage the environment.
[tox]
min_version = 4.0
env_list = py313, pytest, format
env_list = py313, pytest, lint, format

# ---
# This is the base configuration for all test environments.
Expand All @@ -12,43 +12,53 @@ description = Setup tox project
# Tox will automatically use the pyproject.toml build backend (poetry)
# to install the package in an isolated way.
isolated_build = True

# We need to tell tox where to find our dependencies from pyproject.toml
# Tox can read the dependencies directly.
# The `.[test]` syntax tells tox to install the main package and the `test` extra.
# You need to define the test dependencies in your pyproject.toml as well.
# For example: [tool.poetry.group.test.dependencies]
;deps =
; # The build system itself (poetry-core) will be handled automatically by tox.
; poetry
# The command to execute after dependencies are installed.
;commands =
; pytest
# This is the key change. We tell tox to install the project itself.
# This makes all the dependencies from pyproject.toml available to the env.
deps =
-e .

# ---
# This section defines the specific environment for Python 3.13 testing.
[testenv:py313]
# Use the Python 3.13 interpreter.
base_python = python3.13


[testenv:pytest]
description = Run pytests for the project
# This environment now inherits deps from the base `[testenv]`.
# `pytest` is installed from the base `[testenv]` and project dependencies.
# The `pytest` dependency should be defined in `pyproject.toml`
# under `[tool.poetry.group.test.dependencies]`.
deps =
pytest
# There should be a way to install this from pyproject.toml
sqlalchemy
commands =
pytest
# This is the fix: we explicitly allow the `pytest` command to run.
allowlist_externals =
pytest

[testenv:lint]
description = run linter
# This environment now inherits deps from the base `[testenv]`.
# `pylint` is installed from the base `[testenv]`.
# The `pylint` dependency should be defined in `pyproject.toml`
# under `[tool.poetry.group.test.dependencies]`.
deps =
pylint
commands =
pylint --rc-file=.pylintrc
pylint --rc-file=.pylintrc intervals/
allowlist_externals =
pylint

[testenv:format]
description = format with black
commands =
black intervals --check --diff
# This environment now inherits deps from the base `[testenv]`.
# `black` is installed from the base `[testenv]`.
# The `black` dependency should be defined in `pyproject.toml`
# under `[tool.poetry.group.test.dependencies]`.
deps =
black
commands =
black intervals --check --diff
allowlist_externals =
black