Skip to content

INTPYTHON-380 Add task runner and project manager #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@ env:
MONGODB_VERSION: "7.0"

jobs:
pre-commit:
static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
- name: "Run pre-commit"
run: |
pip install -U -q pre-commit
pre-commit run --all-files --hook-stage manual
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- uses: extractions/setup-just@v2
- run: just install
- run: just lint
- run: just docs
- run: uv run pre-commit run --hook-stage manual --all-files
build:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -41,10 +47,12 @@ jobs:
with:
persist-credentials: false
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- uses: extractions/setup-just@v2
- name: Start MongoDB on Linux
if: ${{ startsWith(runner.os, 'Linux') }}
run: |
Expand All @@ -67,10 +75,5 @@ jobs:
mongod --remove
mongod --install --dbpath=$(pwd)/data --logpath=$PWD/mongo.log
net start MongoDB
- name: Install package and pytest
run: |
python -m pip install .
python -m pip install pytest
- name: Run the tests
run: |
pytest .
- run: just install
- run: just test
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ repos:
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
args: [ --fix, --show-fixes ]
# Run the formatter.
- id: ruff-format
13 changes: 10 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
install:
- uv sync
build:
html:
- uv run sphinx-build -T -b html docs $READTHEDOCS_OUTPUT/html
sphinx:
configuration: docs/conf.py
python:
install:
- requirements: docs/requirements.txt
29 changes: 6 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,17 @@ actual bugs and improvement requests.

## Recommended development environment

- MacOS or Linux
- Python 2.7
We use [justfile](https://just.systems/man/en/packages.html) for task running
and [uv](https://docs.astral.sh/uv/getting-started/installation/) for python project management.

Using 2.7 ensures that you don't accidentally break Python2.7 support.
Flask-PyMongo will support Python 2.7 for as long as it is an officially
supported version of Python (util some time in 2020).
To set up your dev environment, run `just install`.

- Run tests with [tox](https://tox.readthedocs.io/en/latest/), eg `tox -e
pymongo30-mongo32-flask0_11`
To run the tests, run `just test`. You can pass arguments through to `pytest`.

Since the build matrix is very big, you may want to select a single
or a few matrix versions to test. Run `tox -l` to see all the builds.
To run the linters, run `just lint`.

All tests, against all supported versions, are run by
[Travis-CI](https://travis-ci.org/dcrosta/flask-pymongo) for each commit
and pull request.
To build the docs, run `just docs` and open `_build/html/index.html` in your browser to view the docs.

- Check style compliance with `tox -e style`


## Building the docs

Build the docs in the `docs` directory using Sphinx:

cd docs
make html

Open `_build/html/index.html` in your browser to view the docs.

## Contributors

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Flask-PyMongo provides helpers for some common tasks:

.. autoclass:: flask_pymongo.helpers.BSONObjectIdConverter

.. autoclass:: flask_pymongo.helpers.JSONEncoder
.. autoclass:: flask_pymongo.helpers.BSONProvider

Configuration
-------------
Expand Down
18 changes: 18 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Default target executed when no arguments are given.
[private]
default:
@just --list

install:
uv sync
uv run pre-commit install

test *args:
uv run pytest {{args}}

lint:
uv run pre-commit run ruff --files
uv run pre-commit run ruff-format --files

docs:
uv run sphinx-build -T -b html docs docs/_build
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ include = [
"/flask_pymongo",
]


[tool.ruff.lint]
select = [
"E", # pycodestyle
Expand All @@ -59,3 +58,11 @@ unfixable = [
"T20", # Removes print statements
"F401", # Unused imports
]

[dependency-groups]
dev = [
"markdown2>=2.5.2",
"pre-commit>=4.0.1",
"pytest>=8.3.4",
"sphinx>=7.4.7",
]
64 changes: 0 additions & 64 deletions tox.ini

This file was deleted.

Loading
Loading