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

test: migrate to uv #53

Merged
merged 11 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 11 additions & 17 deletions .github/workflows/assets.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
name: Assets

on:
schedule:
- cron: "37 3 * * 0"
workflow_dispatch:

jobs:
update:
name: Update DocSearch assets
name: Update dependencies
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install poetry
python-version: "3.13"
- name: Update dependencies
run: |
pip install -U pip poetry
poetry --version
poetry install --with dev

uv sync -U
- name: Update assets
run: poetry run python update_assets.py

run: |
uv run --with httpx update_assets.py
- name: Create PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -37,11 +31,11 @@ jobs:
git config --global user.email "[email protected]"
git checkout -b "${branch}"
git add .
git commit --message "chore: update DocSearch assets"
git commit --message "chore: update dependencies"
git push --force --set-upstream origin "${branch}"
if ! [[ "$(gh pr list --base main --head ${branch})" ]]; then
gh pr create --title "Update DocSearch assets" --body "Update DocSearch assets"
gh pr create --title "Update dependencies" --body "Update dependencies"
fi
else
echo "DocSearch assets up to date."
echo "Dependencies up to date."
fi
122 changes: 65 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,110 @@
name: CI

on:
push:
branches: [main]
tags:
- "*.*.*"
pull_request:

jobs:
docs:
strategy:
matrix:
python-version:
- 3.9
- 3.13
theme: ["alabaster", "awesome", "furo", "pydata", "rtd"]
name: Build docs with ${{ matrix.theme }} theme on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install nox
run: |
uv tool install nox
- name: Build docs with ${{ matrix.theme }}
run: |
nox -p ${{ matrix.python-version }} -s docs -- -t ${{ matrix.theme }}
env:
DOCSEARCH_APP_ID: test
DOCSEARCH_API_KEY: test
DOCSEARCH_INDEX_NAME: test
test:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

python-version: ["3.9", "3.13"]
name: Test with Python ${{ matrix.python-version }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install nox and poetry
- name: Install nox
run: |
pip install -U pip nox poetry poetry-plugin-export
nox --version
pip --version
poetry --version

- name: Run tests
uv tool install nox
- name: Run workflow
run: |
nox -p ${{ matrix.python-version }}
env:
DOCSEARCH_APP_ID: test
DOCSEARCH_API_KEY: test
DOCSEARCH_INDEX_NAME: test

lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install nox and poetry
python-version: 3.13
- name: Install nox
run: |
pip install -U pip nox poetry poetry-plugin-export
nox --version
pip --version
poetry --version

uv tool install nox
- name: Lint Python code
run: nox -s lint

- name: Check links
run: nox -s check_links

release:
name: Publish to PyPI
needs: [test, lint]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

build:
name: Build the package
runs-on: ubuntu-latest

needs:
- test
- lint
- docs
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install nox and poetry
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build packages
run: |
pip install -U pip nox poetry poetry-plugin-export
nox --version
pip --version
poetry --version

- name: Publish package
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: nox -s publish

tag-release:
name: Tag new release
needs: release
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

uv build
- uses: actions/upload-artifact@v4
with:
name: python-packages
path: dist/
publish:
name: Publish package to PyPI
runs-on: ubuntu-latest
needs:
- build
permissions:
id-token: write
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: marvinpinto/action-automatic-releases@latest
- uses: actions/download-artifact@v4
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
name: python-packages
path: dist/
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
41 changes: 36 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,51 @@

# Support building the docs with different themes
# Add `-t alabaster` or `-t rtd` to the build arguments
if tags.has("rtd"): # noqa
if tags.has("rtd"): # type: ignore # noqa
html_theme = "sphinx_rtd_theme"
html_theme_options = {
"style_external_links": True,
}
elif tags.has("alabaster"): # noqa
elif tags.has("alabaster"): # noqa # type:ignore
html_theme = "alabaster"
elif tags.has("furo"): # noqa
elif tags.has("furo"): # noqa # type: ignore
html_theme = "furo"
elif tags.has("pydata"): # noqa
elif tags.has("pydata"): # noqa # type: ignore
html_theme = "pydata_sphinx_theme"
else:
from sphinxawesome_theme.postprocess import Icons

html_theme = "sphinxawesome_theme"
html_permalinks_icon = Icons.permalinks_icon
html_theme_options = {"awesome_external_links": True}
html_theme_options = {
"awesome_external_links": True,
"extra_header_link_icons": {
"repository on GitHub": {
"link": "https://github.com/algolia/sphinx-docsearch",
"icon": (
'<svg height="26px" style="margin-top:-2px;display:inline" '
'viewBox="0 0 45 44" '
'fill="currentColor" xmlns="http://www.w3.org/2000/svg">'
'<path fill-rule="evenodd" clip-rule="evenodd" '
'd="M22.477.927C10.485.927.76 10.65.76 22.647c0 9.596 6.223 17.736 '
"14.853 20.608 1.087.2 1.483-.47 1.483-1.047 "
"0-.516-.019-1.881-.03-3.693-6.04 "
"1.312-7.315-2.912-7.315-2.912-.988-2.51-2.412-3.178-2.412-3.178-1.972-1.346.149-1.32.149-1.32 " # noqa
"2.18.154 3.327 2.24 3.327 2.24 1.937 3.318 5.084 2.36 6.321 "
"1.803.197-1.403.759-2.36 "
"1.379-2.903-4.823-.548-9.894-2.412-9.894-10.734 "
"0-2.37.847-4.31 2.236-5.828-.224-.55-.969-2.759.214-5.748 0 0 "
"1.822-.584 5.972 2.226 "
"1.732-.482 3.59-.722 5.437-.732 1.845.01 3.703.25 5.437.732 "
"4.147-2.81 5.967-2.226 "
"5.967-2.226 1.185 2.99.44 5.198.217 5.748 1.392 1.517 2.232 3.457 "
"2.232 5.828 0 "
"8.344-5.078 10.18-9.916 10.717.779.67 1.474 1.996 1.474 4.021 0 "
"2.904-.027 5.247-.027 "
"5.96 0 .58.392 1.256 1.493 1.044C37.981 40.375 44.2 32.24 44.2 "
'22.647c0-11.996-9.726-21.72-21.722-21.72" '
'fill="currentColor"/></svg>'
),
},
},
}
107 changes: 54 additions & 53 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
accessible-pygments==0.0.4 ; python_version >= "3.8" and python_version < "4.0"
alabaster==0.7.13 ; python_version >= "3.8" and python_version < "3.9"
alabaster==0.7.16 ; python_version >= "3.9" and python_version < "3.10"
alabaster==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
babel==2.16.0 ; python_version >= "3.8" and python_version < "4.0"
beautifulsoup4==4.12.3 ; python_version >= "3.8" and python_version < "4.0"
certifi==2024.8.30 ; python_version >= "3.8" and python_version < "4.0"
charset-normalizer==3.3.2 ; python_version >= "3.8" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0"
docutils==0.20.1 ; python_version >= "3.8" and python_version < "4.0"
furo==2024.8.6 ; python_version >= "3.8" and python_version < "4.0"
idna==3.10 ; python_version >= "3.8" and python_version < "4.0"
imagesize==1.4.1 ; python_version >= "3.8" and python_version < "4.0"
importlib-metadata==8.5.0 ; python_version >= "3.8" and python_version < "3.10"
jinja2==3.1.4 ; python_version >= "3.8" and python_version < "4.0"
livereload==2.7.0 ; python_version >= "3.8" and python_version < "4.0"
markdown-it-py==3.0.0 ; python_version >= "3.8" and python_version < "4.0"
markupsafe==2.1.5 ; python_version >= "3.8" and python_version < "4.0"
mdit-py-plugins==0.4.2 ; python_version >= "3.8" and python_version < "4.0"
mdurl==0.1.2 ; python_version >= "3.8" and python_version < "4.0"
myst-parser==3.0.1 ; python_version >= "3.8" and python_version < "3.10"
myst-parser==4.0.0 ; python_version >= "3.10" and python_version < "4.0"
packaging==24.1 ; python_version >= "3.8" and python_version < "4.0"
pydata-sphinx-theme==0.14.4 ; python_version >= "3.8" and python_version < "4.0"
pygments==2.18.0 ; python_version >= "3.8" and python_version < "4.0"
python-dotenv==1.0.1 ; python_version >= "3.8" and python_version < "4.0"
pytz==2024.2 ; python_version >= "3.8" and python_version < "3.9"
pyyaml==6.0.2 ; python_version >= "3.8" and python_version < "4.0"
requests==2.32.3 ; python_version >= "3.8" and python_version < "4.0"
snowballstemmer==2.2.0 ; python_version >= "3.8" and python_version < "4.0"
soupsieve==2.6 ; python_version >= "3.8" and python_version < "4.0"
sphinx-autobuild==2021.3.14 ; python_version >= "3.8" and python_version < "4.0"
sphinx-basic-ng==1.0.0b2 ; python_version >= "3.8" and python_version < "4.0"
sphinx==7.1.2 ; python_version >= "3.8" and python_version < "3.9"
sphinx==7.4.7 ; python_version >= "3.9" and python_version < "3.10"
sphinx==8.0.2 ; python_version >= "3.10" and python_version < "4.0"
sphinxawesome-theme==5.3.0 ; python_version >= "3.8" and python_version < "4.0"
sphinxcontrib-applehelp==1.0.4 ; python_version >= "3.8" and python_version < "3.9"
sphinxcontrib-applehelp==2.0.0 ; python_version >= "3.9" and python_version < "4.0"
sphinxcontrib-devhelp==1.0.2 ; python_version >= "3.8" and python_version < "3.9"
sphinxcontrib-devhelp==2.0.0 ; python_version >= "3.9" and python_version < "4.0"
sphinxcontrib-htmlhelp==2.0.1 ; python_version >= "3.8" and python_version < "3.9"
sphinxcontrib-htmlhelp==2.1.0 ; python_version >= "3.9" and python_version < "4.0"
sphinxcontrib-jsmath==1.0.1 ; python_version >= "3.8" and python_version < "4.0"
sphinxcontrib-qthelp==1.0.3 ; python_version >= "3.8" and python_version < "3.9"
sphinxcontrib-qthelp==2.0.0 ; python_version >= "3.9" and python_version < "4.0"
sphinxcontrib-serializinghtml==1.1.5 ; python_version >= "3.8" and python_version < "3.9"
sphinxcontrib-serializinghtml==2.0.0 ; python_version >= "3.9" and python_version < "4.0"
tomli==2.0.2 ; python_version >= "3.9" and python_version < "3.11"
tornado==6.4.1 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.12.2 ; python_version >= "3.8" and python_version < "4.0"
urllib3==2.2.3 ; python_version >= "3.8" and python_version < "4.0"
zipp==3.20.2 ; python_version >= "3.8" and python_version < "3.10"
# This file was autogenerated by uv via the following command:
# uv export --group=docs --no-hashes --output-file=docs/requirements.txt
-e .
accessible-pygments==0.0.5
alabaster==0.7.16
anyio==4.6.2.post1
babel==2.16.0
beautifulsoup4==4.9.3
certifi==2024.8.30
charset-normalizer==3.4.0
click==8.1.7
colorama==0.4.6
docutils==0.21.2
exceptiongroup==1.2.2 ; python_full_version < '3.11'
furo==2024.8.6
h11==0.14.0
idna==3.10
imagesize==1.4.1
importlib-metadata==8.5.0 ; python_full_version < '3.10'
jinja2==3.1.4
markdown-it-py==3.0.0
markupsafe==3.0.2
mdit-py-plugins==0.4.2
mdurl==0.1.2
myst-parser==3.0.1
packaging==24.2
pydata-sphinx-theme==0.16.0
pygments==2.18.0
python-dotenv==1.0.1
pyyaml==6.0.2
requests==2.32.3
sniffio==1.3.1
snowballstemmer==2.2.0
soupsieve==2.6
sphinx==7.4.7
sphinx-autobuild==2024.10.3
sphinx-basic-ng==1.0.0b2
sphinx-rtd-theme==3.0.2
sphinxawesome-theme==6.0.0b1
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
starlette==0.41.3
tomli==2.2.1 ; python_full_version < '3.11'
typing-extensions==4.12.2
urllib3==2.2.3
uvicorn==0.32.1
watchfiles==1.0.0
websockets==14.1
zipp==3.21.0 ; python_full_version < '3.10'
Loading
Loading