Skip to content

Commit edfb8c9

Browse files
authored
INTPYTHON-380 Add task runner and project manager (#175)
1 parent eff7c03 commit edfb8c9

File tree

9 files changed

+879
-111
lines changed

9 files changed

+879
-111
lines changed

.github/workflows/test-python.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,23 @@ env:
1717
MONGODB_VERSION: "7.0"
1818

1919
jobs:
20-
pre-commit:
20+
static:
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v4
24-
with:
25-
persist-credentials: false
26-
- uses: actions/setup-python@v5
27-
- name: "Run pre-commit"
28-
run: |
29-
pip install -U -q pre-commit
30-
pre-commit run --all-files --hook-stage manual
23+
- uses: actions/checkout@v4
24+
with:
25+
persist-credentials: false
26+
fetch-depth: 0
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v5
29+
with:
30+
enable-cache: true
31+
python-version: ${{ matrix.python-version }}
32+
- uses: extractions/setup-just@v2
33+
- run: just install
34+
- run: just lint
35+
- run: just docs
36+
- run: uv run pre-commit run --hook-stage manual --all-files
3137
build:
3238
runs-on: ${{ matrix.os }}
3339
strategy:
@@ -41,10 +47,12 @@ jobs:
4147
with:
4248
persist-credentials: false
4349
fetch-depth: 0
44-
- name: Setup Python
45-
uses: actions/setup-python@v5
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v5
4652
with:
53+
enable-cache: true
4754
python-version: ${{ matrix.python-version }}
55+
- uses: extractions/setup-just@v2
4856
- name: Start MongoDB on Linux
4957
if: ${{ startsWith(runner.os, 'Linux') }}
5058
run: |
@@ -67,10 +75,5 @@ jobs:
6775
mongod --remove
6876
mongod --install --dbpath=$(pwd)/data --logpath=$PWD/mongo.log
6977
net start MongoDB
70-
- name: Install package and pytest
71-
run: |
72-
python -m pip install .
73-
python -m pip install pytest
74-
- name: Run the tests
75-
run: |
76-
pytest .
78+
- run: just install
79+
- run: just test

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ repos:
4141
hooks:
4242
# Run the linter.
4343
- id: ruff
44-
args: [ --fix ]
44+
args: [ --fix, --show-fixes ]
4545
# Run the formatter.
4646
- id: ruff-format

.readthedocs.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ build:
33
os: ubuntu-22.04
44
tools:
55
python: "3.11"
6+
jobs:
7+
create_environment:
8+
- asdf plugin add uv
9+
- asdf install uv latest
10+
- asdf global uv latest
11+
install:
12+
- uv sync
13+
build:
14+
html:
15+
- uv run sphinx-build -T -b html docs $READTHEDOCS_OUTPUT/html
616
sphinx:
717
configuration: docs/conf.py
8-
python:
9-
install:
10-
- requirements: docs/requirements.txt

CONTRIBUTING.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,17 @@ actual bugs and improvement requests.
3636

3737
## Recommended development environment
3838

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

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

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

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

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

56-
- Check style compliance with `tox -e style`
57-
58-
59-
## Building the docs
60-
61-
Build the docs in the `docs` directory using Sphinx:
62-
63-
cd docs
64-
make html
65-
66-
Open `_build/html/index.html` in your browser to view the docs.
6750

6851
## Contributors
6952

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Flask-PyMongo provides helpers for some common tasks:
8383

8484
.. autoclass:: flask_pymongo.helpers.BSONObjectIdConverter
8585

86-
.. autoclass:: flask_pymongo.helpers.JSONEncoder
86+
.. autoclass:: flask_pymongo.helpers.BSONProvider
8787

8888
Configuration
8989
-------------

justfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Default target executed when no arguments are given.
2+
[private]
3+
default:
4+
@just --list
5+
6+
install:
7+
uv sync
8+
uv run pre-commit install
9+
10+
test *args:
11+
uv run pytest {{args}}
12+
13+
lint:
14+
uv run pre-commit run ruff --files
15+
uv run pre-commit run ruff-format --files
16+
17+
docs:
18+
uv run sphinx-build -T -b html docs docs/_build

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ include = [
4545
"/flask_pymongo",
4646
]
4747

48-
4948
[tool.ruff.lint]
5049
select = [
5150
"E", # pycodestyle
@@ -59,3 +58,11 @@ unfixable = [
5958
"T20", # Removes print statements
6059
"F401", # Unused imports
6160
]
61+
62+
[dependency-groups]
63+
dev = [
64+
"markdown2>=2.5.2",
65+
"pre-commit>=4.0.1",
66+
"pytest>=8.3.4",
67+
"sphinx>=7.4.7",
68+
]

tox.ini

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)