Skip to content

Commit

Permalink
Synchronize CI with other reactive-python repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Dec 2, 2024
1 parent 28d60a2 commit 69f6dd8
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 62 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/publish-develop-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- main
jobs:
deploy:
publish-develop-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -17,14 +17,12 @@ jobs:
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install --upgrade hatch uv
run: pip install --upgrade pip hatch uv
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Publish Develop Docs
run: |
hatch run docs:deploy_develop
run: hatch run docs:deploy_develop
concurrency:
group: publish-docs
7 changes: 3 additions & 4 deletions .github/workflows/publish-latest-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ jobs:
python-version: 3.x
- name: Install dependencies
run: |
pip install --upgrade hatch uv
pip install --upgrade pip hatch uv
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Publish Develop Docs
run: |
hatch run docs:deploy_latest ${{ github.ref_name }}
- name: Publish ${{ github.event.release.name }} Docs
run: hatch run docs:deploy_latest ${{ github.ref_name }}
concurrency:
group: publish-docs
18 changes: 6 additions & 12 deletions .github/workflows/publish-py.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Publish Python

on:
release:
types: [published]

jobs:
publish-package:
publish-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -20,14 +17,11 @@ jobs:
with:
python-version: "3.x"
- name: Install dependencies
run: |
pip3 --quiet install --upgrade hatch uv twine
run: pip install --upgrade pip hatch uv
- name: Build Package
run: |
hatch build --clean
run: hatch build --clean
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }}
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
run: hatch publish --yes
12 changes: 5 additions & 7 deletions .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ jobs:
with:
python-version: 3.x
- name: Install Python Dependencies
run: |
pip3 --quiet install --upgrade hatch uv ruff
run: pip install --upgrade pip hatch uv
- name: Check documentation links
run: hatch run docs:linkcheck
- name: Check docs build
run: |
hatch run docs:build
hatch run docs:linkcheck
run: hatch run docs:build
- name: Check docs examples
run: |
ruff check docs/examples/python/
run: hatch fmt docs --check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Style
name: Test

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- main

jobs:
test-style:
javascript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -18,10 +18,8 @@ jobs:
bun-version: latest
- uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: 3.x
- name: Install Python Dependencies
run: |
pip3 install hatch uv
run: pip install --upgrade pip hatch uv
- name: Run Tests
run: |
hatch fmt --check
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-source:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -26,8 +26,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: |
pip3 install hatch uv
run: pip install --upgrade pip hatch uv
- name: Run Tests
run: |
hatch test --cover --python ${{ matrix.python-version }}
Expand All @@ -40,18 +39,18 @@ jobs:
if-no-files-found: error
include-hidden-files: true
retention-days: 7
coverage:

python-coverage:
needs:
- source
- python-source
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Latest Python
uses: actions/setup-python@v5
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Python Dependencies
run: python -m pip install --upgrade coverage[toml]
run: pip install --upgrade coverage[toml]
- name: Download data
uses: actions/download-artifact@v4
with:
Expand All @@ -66,3 +65,18 @@ jobs:
with:
name: coverage-report
path: htmlcov

python-formatting:
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: Check Python formatting
run: hatch fmt src tests --check
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Using the following categories, list your changes in this order:

## [Unreleased]

- Nothing (yet)!
### Changed

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

## [1.0.3] - 2024-11-21

Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ site_description: It's React-Router, but in Python.
copyright: '&copy;<div id="year"> </div> <script> document.getElementById("year").innerHTML = new Date().getFullYear(); </script>Reactive Python and affiliates.<div class="legal-footer-right">This project has no affiliation to ReactJS or Meta Platforms, Inc.</div>'
repo_url: https://github.com/reactive-python/reactpy-router
site_url: https://reactive-python.github.io/reactpy-router
repo_name: ReactPy Router (GitHub)
repo_name: ReactPy Router
edit_uri: edit/main/docs/src/
docs_dir: src
4 changes: 4 additions & 0 deletions docs/src/about/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ If you plan to make code changes to this repository, you will need to install th
- [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:

Expand Down Expand Up @@ -40,6 +41,8 @@ By utilizing `hatch`, the following commands are available to manage the develop
| `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"

Expand All @@ -54,6 +57,7 @@ By utilizing `hatch`, the following commands are available to manage the develop
| `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 fmt docs --check` | Run linter on code examples in the documentation |

### Environment Management

Expand Down
52 changes: 35 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-build-scripts"]

##############################
# >>> Hatch Build Config <<< #
##############################

[project]
name = "reactpy_router"
description = "A URL router for ReactPy."
Expand All @@ -24,7 +28,7 @@ classifiers = [
"Environment :: Web Environment",
"Typing :: Typed",
]
dependencies = ["reactpy>=1.0.0", "typing_extensions"]
dependencies = ["reactpy>=1.0.0, <2.0.0", "typing_extensions"]
dynamic = ["version"]
urls.Changelog = "https://reactive-python.github.io/reactpy-router/latest/about/changelog/"
urls.Documentation = "https://reactive-python.github.io/reactpy-router/latest/"
Expand All @@ -35,10 +39,10 @@ path = "src/reactpy_router/__init__.py"

[tool.hatch.build.targets.sdist]
include = ["/src"]
artifacts = ["/src/reactpy_router/static/bundle.js"]
artifacts = ["/src/reactpy_router/static/"]

[tool.hatch.build.targets.wheel]
artifacts = ["/src/reactpy_router/static/bundle.js"]
artifacts = ["/src/reactpy_router/static/"]

[tool.hatch.metadata]
license-files = { paths = ["LICENSE.md"] }
Expand All @@ -53,7 +57,9 @@ commands = [
]
artifacts = []

# >>> Hatch Tests <<<
#############################
# >>> Hatch Test Runner <<< #
#############################

[tool.hatch.envs.hatch-test]
extra-dependencies = ["pytest-sugar", "anyio", "reactpy[testing,starlette]"]
Expand All @@ -63,24 +69,30 @@ matrix-name-format = "{variable}-{value}"
[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]

# >>> Hatch Documentation Scripts <<<
[tool.pytest.ini_options]
addopts = """\
--strict-config
--strict-markers
"""

#######################################
# >>> Hatch Documentation Scripts <<< #
#######################################

[tool.hatch.envs.docs]
template = "docs"
detached = true
dependencies = [
"mkdocs",
"mkdocs-git-revision-date-localized-plugin",
"mkdocs-material==9.4.0",
"mkdocs-include-markdown-plugin",
"linkcheckmd",
"mkdocs-spellcheck[all]",
"mkdocs-git-authors-plugin",
"mkdocs-minify-plugin",
"mike",
"mkdocstrings[python]",
"black",
"reactpy_router @ {root:uri}",
"black", # Used by mkdocstrings for auto formatting
"linkcheckmd",
]

[tool.hatch.envs.docs.scripts]
Expand All @@ -94,10 +106,23 @@ linkcheck = [
deploy_latest = ["cd docs && mike deploy --push --update-aliases {args} latest"]
deploy_develop = ["cd docs && mike deploy --push develop"]

############################
# >>> Hatch JS Scripts <<< #
############################

# >>> Generic Tools <<<
[tool.hatch.envs.javascript]
detached = true

[tool.hatch.envs.javascript.scripts]
check = ["cd src/js && bun install", "cd src/js && bun run check"]
fix = ["cd src/js && bun install", "cd src/js && bun run format"]

#########################
# >>> Generic Tools <<< #
#########################

[tool.ruff]
extend-exclude = [".venv/*", ".eggs/*", "build/*"]
line-length = 120
format.preview = true
lint.extend-ignore = [
Expand All @@ -111,13 +136,6 @@ lint.extend-ignore = [
"SLF001", # Private member accessed
]
lint.preview = true
extend-exclude = [".venv/*", ".eggs/*", "build/*"]

[tool.pytest.ini_options]
addopts = """\
--strict-config
--strict-markers
"""

[tool.coverage.run]
branch = true
Expand Down

0 comments on commit 69f6dd8

Please sign in to comment.