Skip to content

Commit

Permalink
Switch from Nox to Hatch (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger authored Dec 1, 2024
1 parent 2abe5ce commit c5b5c81
Show file tree
Hide file tree
Showing 46 changed files with 985 additions and 970 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish-develop-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
jobs:
deploy:
publish-develop-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -17,12 +17,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install -r requirements/build-docs.txt
- name: Install dependencies
run: pip install --upgrade pip hatch uv
- name: Publish Develop Docs
run: |
git config user.name github-actions
git config user.email [email protected]
cd docs
mike deploy --push develop
hatch run docs:deploy_develop
concurrency:
group: publish-docs
8 changes: 4 additions & 4 deletions .github/workflows/publish-latest-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [published]

jobs:
deploy:
publish-latest-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -17,12 +17,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install -r requirements/build-docs.txt
- name: Install dependencies
run: pip install --upgrade pip hatch uv
- name: Publish ${{ github.event.release.name }} Docs
run: |
git config user.name github-actions
git config user.email [email protected]
cd docs
mike deploy --push --update-aliases ${{ github.event.release.name }} latest
hatch run docs:deploy_latest ${{ github.ref_name }}
concurrency:
group: publish-docs
8 changes: 3 additions & 5 deletions .github/workflows/publish-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [published]

jobs:
release-package:
publish-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -20,13 +20,11 @@ jobs:
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/build-pkg.txt
run: pip install --upgrade pip hatch uv
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build --sdist --wheel --outdir dist .
hatch build --clean
twine upload dist/*
24 changes: 7 additions & 17 deletions .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * *"

jobs:
docs:
Expand All @@ -23,20 +21,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.x
# - name: Check docs links
# uses: umbrelladocs/action-linkspector@v1
# with:
# github_token: ${{ secrets.github_token }}
# reporter: github-pr-review
# fail_on_error: false
- name: Install Python Dependencies
run: pip install --upgrade pip hatch uv
# DISABLED DUE TO DJANGO DOCS CONSTANTLY THROWING 429 ERRORS
# - name: Check documentation links
# run: hatch run docs:linkcheck
- name: Check docs build
run: |
pip install -r requirements/build-docs.txt
cd docs
mkdocs build --strict
run: hatch run docs:build
- name: Check docs examples
run: |
pip install -r requirements/check-types.txt
pip install -r requirements/check-style.txt
mypy --show-error-codes docs/examples/python/
ruff check docs/examples/python/
run: hatch run docs:check_examples
25 changes: 25 additions & 0 deletions .github/workflows/test-javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
javascript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Python Dependencies
run: pip install --upgrade pip hatch uv
- name: Run Tests
run: hatch run javascript:check
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- cron: "0 0 * * *"

jobs:
source:
python:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -26,6 +26,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: pip install -r requirements/test-run.txt
- name: Run Tests
run: nox -t test
run: pip install --upgrade pip hatch uv
- name: Run Single DB Tests
run: hatch test --python ${{ matrix.python-version }} --ds=test_app.settings_single_db -v
- name: Run Multi-DB Tests
run: hatch test --python ${{ matrix.python-version }} --ds=test_app.settings_multi_db -v
7 changes: 0 additions & 7 deletions .linkspector.yml

This file was deleted.

8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ Don't forget to remove deprecated code on each major release!

## [Unreleased]

- Nothing (yet)!
### Fixed

- Fixed regression in v5.1.0 where components would sometimes not output debug messages when `settings.py:DEBUG` is enabled.

### Changed

- Set upper limit on ReactPy version to `<2.0.0`.

## [5.1.0] - 2024-11-24

Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

4 changes: 1 addition & 3 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ nav:
- Management Commands: reference/management-commands.md
- About:
- Changelog: about/changelog.md
- Contributor Guide:
- Code: about/code.md
- Docs: about/docs.md
- Contributor Guide: about/contributing.md
- Community:
- GitHub Discussions: https://github.com/reactive-python/reactpy-django/discussions
- Discord: https://discord.gg/uNb5P4hA9X
Expand Down
85 changes: 0 additions & 85 deletions docs/src/about/code.md

This file was deleted.

93 changes: 93 additions & 0 deletions docs/src/about/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
## Overview

<p class="intro" markdown>

You will need to set up a Python environment to develop ReactPy-Django.

</p>

!!! abstract "Note"

Looking to contribute features that are not Django specific?

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.

---

## Creating a development environment

If you plan to make code changes to this repository, you will need to install the following dependencies first:

- [Git](https://git-scm.com/downloads)
- [Python 3.9+](https://www.python.org/downloads/)
- [Hatch](https://hatch.pypa.io/latest/)
- [Bun](https://bun.sh/)

Once you finish installing these dependencies, you can clone this repository:

```bash linenums="0"
git clone https://github.com/reactive-python/reactpy-django.git
cd reactpy-django
```

## Executing test environment commands

By utilizing `hatch`, the following commands are available to manage the development environment.

### Tests

| Command | Description |
| --- | --- |
| `hatch test` | Run Python tests using the current environment's Python version |
| `hatch test --all` | Run tests using all compatible Python versions |
| `hatch test --python 3.9` | Run tests using a specific Python version |
| `hatch test --include "django=5.1"` | Run tests using a specific Django version |
| `hatch test -k test_object_in_templatetag` | Run only a specific test |
| `hatch test --ds test_app.settings_multi_db` | Run tests with a specific Django settings file |
| `hatch run django:runserver` | Manually run the Django development server without running tests |

??? question "What other arguments are available to me?"

The `hatch test` command is a wrapper for `pytest`. Hatch "intercepts" a handful of arguments, which can be previewed by typing `hatch test --help`.

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.

### Linting and Formatting

| Command | Description |
| --- | --- |
| `hatch fmt` | Run all linters and formatters |
| `hatch fmt --check` | Run all linters and formatters, but do not save fixes to the disk |
| `hatch fmt --linter` | Run only linters |
| `hatch fmt --formatter` | Run only formatters |
| `hatch run javascript:check` | Run the JavaScript linter/formatter |
| `hatch run javascript:fix` | Run the JavaScript linter/formatter and write fixes to disk |

??? tip "Configure your IDE for linting"

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).

You can install `ruff` as a plugin to your preferred code editor to create a similar environment.

### Documentation

| Command | Description |
| --- | --- |
| `hatch run docs:serve` | Start the [`mkdocs`](https://www.mkdocs.org/) server to view documentation locally |
| `hatch run docs:build` | Build the documentation |
| `hatch run docs:linkcheck` | Check for broken links in the documentation |
| `hatch run docs:check_examples` | Run linter on code examples in the documentation |

### Environment Management

| Command | Description |
| --- | --- |
| `hatch build --clean` | Build the package from source |
| `hatch env prune` | Delete all virtual environments created by `hatch` |
| `hatch python install 3.12` | Install a specific Python version to your system |

??? tip "Check out Hatch for all available commands!"

This documentation only covers commonly used commands.

You can type `hatch --help` to see all available commands.
Loading

0 comments on commit c5b5c81

Please sign in to comment.