Skip to content

Commit c5b5c81

Browse files
authored
Switch from Nox to Hatch (#260)
1 parent 2abe5ce commit c5b5c81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+985
-970
lines changed

.github/workflows/publish-develop-docs.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- main
77
jobs:
8-
deploy:
8+
publish-develop-docs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
@@ -17,12 +17,12 @@ jobs:
1717
- uses: actions/setup-python@v5
1818
with:
1919
python-version: 3.x
20-
- run: pip install -r requirements/build-docs.txt
20+
- name: Install dependencies
21+
run: pip install --upgrade pip hatch uv
2122
- name: Publish Develop Docs
2223
run: |
2324
git config user.name github-actions
2425
git config user.email [email protected]
25-
cd docs
26-
mike deploy --push develop
26+
hatch run docs:deploy_develop
2727
concurrency:
2828
group: publish-docs

.github/workflows/publish-latest-docs.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
types: [published]
66

77
jobs:
8-
deploy:
8+
publish-latest-docs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
@@ -17,12 +17,12 @@ jobs:
1717
- uses: actions/setup-python@v5
1818
with:
1919
python-version: 3.x
20-
- run: pip install -r requirements/build-docs.txt
20+
- name: Install dependencies
21+
run: pip install --upgrade pip hatch uv
2122
- name: Publish ${{ github.event.release.name }} Docs
2223
run: |
2324
git config user.name github-actions
2425
git config user.email [email protected]
25-
cd docs
26-
mike deploy --push --update-aliases ${{ github.event.release.name }} latest
26+
hatch run docs:deploy_latest ${{ github.ref_name }}
2727
concurrency:
2828
group: publish-docs

.github/workflows/publish-py.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
types: [published]
99

1010
jobs:
11-
release-package:
11+
publish-python:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
@@ -20,13 +20,11 @@ jobs:
2020
with:
2121
python-version: "3.x"
2222
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install -r requirements/build-pkg.txt
23+
run: pip install --upgrade pip hatch uv
2624
- name: Build and publish
2725
env:
2826
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2927
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3028
run: |
31-
python -m build --sdist --wheel --outdir dist .
29+
hatch build --clean
3230
twine upload dist/*

.github/workflows/test-docs.yml

+7-17
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
pull_request:
88
branches:
99
- main
10-
schedule:
11-
- cron: "0 0 * * *"
1210

1311
jobs:
1412
docs:
@@ -23,20 +21,12 @@ jobs:
2321
- uses: actions/setup-python@v5
2422
with:
2523
python-version: 3.x
26-
# - name: Check docs links
27-
# uses: umbrelladocs/action-linkspector@v1
28-
# with:
29-
# github_token: ${{ secrets.github_token }}
30-
# reporter: github-pr-review
31-
# fail_on_error: false
24+
- name: Install Python Dependencies
25+
run: pip install --upgrade pip hatch uv
26+
# DISABLED DUE TO DJANGO DOCS CONSTANTLY THROWING 429 ERRORS
27+
# - name: Check documentation links
28+
# run: hatch run docs:linkcheck
3229
- name: Check docs build
33-
run: |
34-
pip install -r requirements/build-docs.txt
35-
cd docs
36-
mkdocs build --strict
30+
run: hatch run docs:build
3731
- name: Check docs examples
38-
run: |
39-
pip install -r requirements/check-types.txt
40-
pip install -r requirements/check-style.txt
41-
mypy --show-error-codes docs/examples/python/
42-
ruff check docs/examples/python/
32+
run: hatch run docs:check_examples

.github/workflows/test-javascript.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
javascript:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: oven-sh/setup-bun@v2
17+
with:
18+
bun-version: latest
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: 3.x
22+
- name: Install Python Dependencies
23+
run: pip install --upgrade pip hatch uv
24+
- name: Run Tests
25+
run: hatch run javascript:check

.github/workflows/test-src.yml renamed to .github/workflows/test-python.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- cron: "0 0 * * *"
1212

1313
jobs:
14-
source:
14+
python:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
@@ -26,6 +26,8 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install Python Dependencies
29-
run: pip install -r requirements/test-run.txt
30-
- name: Run Tests
31-
run: nox -t test
29+
run: pip install --upgrade pip hatch uv
30+
- name: Run Single DB Tests
31+
run: hatch test --python ${{ matrix.python-version }} --ds=test_app.settings_single_db -v
32+
- name: Run Multi-DB Tests
33+
run: hatch test --python ${{ matrix.python-version }} --ds=test_app.settings_multi_db -v

.linkspector.yml

-7
This file was deleted.

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ Don't forget to remove deprecated code on each major release!
1919

2020
## [Unreleased]
2121

22-
- Nothing (yet)!
22+
### Fixed
23+
24+
- Fixed regression in v5.1.0 where components would sometimes not output debug messages when `settings.py:DEBUG` is enabled.
25+
26+
### Changed
27+
28+
- Set upper limit on ReactPy version to `<2.0.0`.
2329

2430
## [5.1.0] - 2024-11-24
2531

MANIFEST.in

-3
This file was deleted.

docs/mkdocs.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ nav:
1616
- Management Commands: reference/management-commands.md
1717
- About:
1818
- Changelog: about/changelog.md
19-
- Contributor Guide:
20-
- Code: about/code.md
21-
- Docs: about/docs.md
19+
- Contributor Guide: about/contributing.md
2220
- Community:
2321
- GitHub Discussions: https://github.com/reactive-python/reactpy-django/discussions
2422
- Discord: https://discord.gg/uNb5P4hA9X

docs/src/about/code.md

-85
This file was deleted.

docs/src/about/contributing.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## Overview
2+
3+
<p class="intro" markdown>
4+
5+
You will need to set up a Python environment to develop ReactPy-Django.
6+
7+
</p>
8+
9+
!!! abstract "Note"
10+
11+
Looking to contribute features that are not Django specific?
12+
13+
Everything within the `reactpy-django` repository must be specific to Django integration. Check out the [ReactPy Core documentation](https://reactpy.dev/docs/about/contributor-guide.html) to contribute general features such as components, hooks, and events.
14+
15+
---
16+
17+
## Creating a development environment
18+
19+
If you plan to make code changes to this repository, you will need to install the following dependencies first:
20+
21+
- [Git](https://git-scm.com/downloads)
22+
- [Python 3.9+](https://www.python.org/downloads/)
23+
- [Hatch](https://hatch.pypa.io/latest/)
24+
- [Bun](https://bun.sh/)
25+
26+
Once you finish installing these dependencies, you can clone this repository:
27+
28+
```bash linenums="0"
29+
git clone https://github.com/reactive-python/reactpy-django.git
30+
cd reactpy-django
31+
```
32+
33+
## Executing test environment commands
34+
35+
By utilizing `hatch`, the following commands are available to manage the development environment.
36+
37+
### Tests
38+
39+
| Command | Description |
40+
| --- | --- |
41+
| `hatch test` | Run Python tests using the current environment's Python version |
42+
| `hatch test --all` | Run tests using all compatible Python versions |
43+
| `hatch test --python 3.9` | Run tests using a specific Python version |
44+
| `hatch test --include "django=5.1"` | Run tests using a specific Django version |
45+
| `hatch test -k test_object_in_templatetag` | Run only a specific test |
46+
| `hatch test --ds test_app.settings_multi_db` | Run tests with a specific Django settings file |
47+
| `hatch run django:runserver` | Manually run the Django development server without running tests |
48+
49+
??? question "What other arguments are available to me?"
50+
51+
The `hatch test` command is a wrapper for `pytest`. Hatch "intercepts" a handful of arguments, which can be previewed by typing `hatch test --help`.
52+
53+
Any additional arguments in the `test` command are directly passed on to pytest. See the [pytest documentation](https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags) for what additional arguments are available.
54+
55+
### Linting and Formatting
56+
57+
| Command | Description |
58+
| --- | --- |
59+
| `hatch fmt` | Run all linters and formatters |
60+
| `hatch fmt --check` | Run all linters and formatters, but do not save fixes to the disk |
61+
| `hatch fmt --linter` | Run only linters |
62+
| `hatch fmt --formatter` | Run only formatters |
63+
| `hatch run javascript:check` | Run the JavaScript linter/formatter |
64+
| `hatch run javascript:fix` | Run the JavaScript linter/formatter and write fixes to disk |
65+
66+
??? tip "Configure your IDE for linting"
67+
68+
This repository uses `hatch fmt` for linting and formatting, which is a [modestly customized](https://hatch.pypa.io/latest/config/internal/static-analysis/#default-settings) version of [`ruff`](https://github.com/astral-sh/ruff).
69+
70+
You can install `ruff` as a plugin to your preferred code editor to create a similar environment.
71+
72+
### Documentation
73+
74+
| Command | Description |
75+
| --- | --- |
76+
| `hatch run docs:serve` | Start the [`mkdocs`](https://www.mkdocs.org/) server to view documentation locally |
77+
| `hatch run docs:build` | Build the documentation |
78+
| `hatch run docs:linkcheck` | Check for broken links in the documentation |
79+
| `hatch run docs:check_examples` | Run linter on code examples in the documentation |
80+
81+
### Environment Management
82+
83+
| Command | Description |
84+
| --- | --- |
85+
| `hatch build --clean` | Build the package from source |
86+
| `hatch env prune` | Delete all virtual environments created by `hatch` |
87+
| `hatch python install 3.12` | Install a specific Python version to your system |
88+
89+
??? tip "Check out Hatch for all available commands!"
90+
91+
This documentation only covers commonly used commands.
92+
93+
You can type `hatch --help` to see all available commands.

0 commit comments

Comments
 (0)