Skip to content
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

Switch testing/build suite from Nox to Hatch #260

Merged
merged 31 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4a746be
switch CI to use hatch commands
Archmonger Nov 26, 2024
f3c0ee8
semi-functional test runner with hatch
Archmonger Nov 27, 2024
f7a2923
Add example check workflow
Archmonger Nov 27, 2024
5804c4c
Add JavaScript check
Archmonger Nov 27, 2024
3d46f36
Merge remote-tracking branch 'upstream/main' into switch-from-nox-to-…
Archmonger Nov 27, 2024
a22efb5
Remove `reactpy_django.config.REACTPY_DEBUG_MODE`
Archmonger Nov 27, 2024
2ca4e28
Add runserver command
Archmonger Nov 27, 2024
3353d48
Switch to servestatic
Archmonger Nov 27, 2024
c06ba86
Get the `hatch test` command working
Archmonger Nov 27, 2024
0221585
use head method for the bulk of link checking
Archmonger Nov 27, 2024
437f87f
Auto install playwright in conftest
Archmonger Nov 27, 2024
a75309a
Run multi-db tests
Archmonger Nov 27, 2024
f5976b2
Greater separation of tests
Archmonger Nov 27, 2024
9131a4a
avoid debug keyword
Archmonger Nov 27, 2024
83acfaa
go back to snapshotting Django's debug value
Archmonger Nov 27, 2024
e563287
hatch local builds are fucked, so just re-use the base env
Archmonger Nov 27, 2024
a74c2dd
Add sleep to hello world test
Archmonger Nov 28, 2024
1f1df86
Fix warning on calling DB functions in appconfig.ready
Archmonger Nov 28, 2024
3aac221
Make github test runner more verbose
Archmonger Nov 28, 2024
5178af8
Add docs for new hatch commands
Archmonger Nov 28, 2024
9af272f
Disable link checking
Archmonger Nov 28, 2024
d9eaf07
Put sleep on the correct pyscript file
Archmonger Nov 28, 2024
0e12980
Remove sleep, add longer page timeout for pyscript
Archmonger Nov 28, 2024
4aec1b5
Add notice about ReactPy upper limit change
Archmonger Nov 28, 2024
1048ff3
Rename workflows
Archmonger Nov 28, 2024
1597441
new format for eslint config
Archmonger Nov 28, 2024
0092316
fix javascript:fix command
Archmonger Nov 28, 2024
47cc484
Remove old manifest file
Archmonger Nov 28, 2024
9cb9240
remove duplicates from teardownclass
Archmonger Dec 1, 2024
d4a6649
Increase default timeout
Archmonger Dec 1, 2024
56d0990
self review
Archmonger Dec 1, 2024
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
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
Loading