Skip to content

Commit

Permalink
build: update hatch envs (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
afuetterer authored Aug 21, 2024
1 parent 51995a5 commit 2db9a2b
Show file tree
Hide file tree
Showing 9 changed files with 1,185 additions and 428 deletions.
5 changes: 0 additions & 5 deletions .github/requirements/ci.in

This file was deleted.

365 changes: 0 additions & 365 deletions .github/requirements/ci.txt

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
key: docs-${{ hashFiles('pyproject.toml') }}
path: ~/.cache/pip
- name: Install pre-requisites (e.g. hatch)
run: python -m pip install --require-hashes --requirement=.github/requirements/ci.txt
run: python -m pip install --require-hashes --requirement=requirements/ci
- run: hatch run docs:build
if: github.event_name == 'pull_request'
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version: '3.12'
cache: pip
- name: Install pre-requisites (e.g. hatch)
run: python -m pip install --require-hashes --requirement=.github/requirements/ci.txt
run: python -m pip install --require-hashes --requirement=requirements/ci
- run: python -m build --installer=uv
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install pre-requisites (e.g. hatch)
run: python -m pip install --require-hashes --requirement=.github/requirements/ci.txt
run: python -m pip install --require-hashes --requirement=requirements/ci
- name: Run test suite
run: hatch run cov
- name: Generate coverage report
Expand Down Expand Up @@ -73,16 +73,16 @@ jobs:
- run: python -Ic 'import oaipmh_scythe.__about__; print(oaipmh_scythe.__about__.__version__)'
- name: Set up pipdeptree
if: matrix.os == 'ubuntu-latest'
run: python -m pip install --require-hashes --requirement=.github/requirements/ci.txt
run: python -m pip install --require-hashes --requirement=requirements/ci
- name: Write info to step summary
if: matrix.os == 'ubuntu-latest'
run: |
{
echo -e "### ✓ All dependencies installed successfully\n\n"
echo '<details><summary>Installed Python packages (dependency tree)</summary>'
echo -e "\n\`\`\`console"
echo "$ python -m pipdeptree --local-only --exclude=pip,pipdeptree"
python -m pipdeptree --local-only --exclude=pip,pipdeptree
echo "$ uv pip tree --package=oaipmh-scythe"
uv pip tree --package=oaipmh-scythe
echo -e "\`\`\`\n</details>"
echo '<details><summary>Outdated Python packages</summary>'
echo -e "\n\`\`\`console"
Expand Down
47 changes: 5 additions & 42 deletions .github/workflows/upgrade-requirements.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# This CI job is adapted from:
# build-and-inspect-python-package (2024-03-25), MIT license
# Ref: https://github.com/hynek/build-and-inspect-python-package/blob/v2.2.1/.github/workflows/update-dependencies.yml

name: Upgrade requirements

on:
Expand All @@ -10,45 +6,12 @@ on:
- cron: 0 0 1 * *
workflow_dispatch: # run manually from actions tab

permissions:
contents: read
# Set permissions at the job level.
permissions: {}

jobs:
upgrade:
permissions:
contents: write # for peter-evans/create-pull-request to create branch
pull-requests: write # for peter-evans/create-pull-request to create a PR
name: Upgrade requirements
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Upgrade requirements
run: >
uv pip compile
--upgrade
--generate-hashes
--python-version=3.10
--output-file=.github/requirements/ci.txt
.github/requirements/ci.in
# Ref: https://github.com/peter-evans/create-pull-request
- uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: requirement-upgrades
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
title: 'build(deps-dev): upgrade ci requirements'
commit-message: 'build(deps-dev): upgrade ci requirements'
body: |
Monthly scheduled CI requirements upgrade (`uv pip compile --upgrade`).
> [!NOTE]
> Mark this PR as "ready for review" to trigger additional checks.
add-paths: .github/requirements/ci.txt
labels: |
type: build
deps: python
delete-branch: true
draft: true
contents: write
pull-requests: write
uses: afuetterer/.github/.github/workflows/_upgrade-requirements.yml@main
46 changes: 36 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,28 @@ dynamic = [
"version",
]
dependencies = [
"httpx>=0.25",
"lxml>=5.1",
"httpx>=0.27",
"lxml>=5.3",
]
optional-dependencies.dev = [
"pre-commit~=3.6",
"pre-commit~=3.8",
]
optional-dependencies.docs = [
"mike~=2.0",
"mkdocs~=1.5",
"mike~=2.1",
"mkdocs~=1.6",
"mkdocs-include-markdown-plugin~=6.0",
"mkdocs-material~=9.5",
"mkdocstrings[python]~=0.24",
"mkdocs-minify-plugin~=0.7",
"mkdocstrings[python]~=0.25",
]
optional-dependencies.test = [
"pytest~=8.0",
"pytest~=8.2",
"pytest-cov~=5.0",
"pytest-mock~=3.12",
"pytest-mock~=3.14",
"pytest-randomly~=3.15",
"pytest-recording~=0.13",
"pytest-xdist~=3.5",
"respx~=0.20",
"pytest-xdist~=3.6",
"respx~=0.21",
]
urls.Changelog = "https://github.com/afuetterer/oaipmh-scythe/blob/main/CHANGELOG.md"
urls.Documentation = "https://afuetterer.github.io/oaipmh-scythe"
Expand All @@ -73,11 +74,17 @@ include = [
]

[tool.hatch.build.targets.wheel]
only-packages = true
packages = [ "src/oaipmh_scythe" ]

[tool.hatch.version]
path = "src/oaipmh_scythe/__about__.py"

[tool.hatch.env]
requires = [
"hatch-pip-compile",
]

[tool.hatch.envs.default]
installer = "uv"
features = [ "dev", "test" ]
Expand All @@ -94,9 +101,28 @@ cov-total = """
python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])"
"""

[tool.hatch.envs.ci]
dependencies = [
"build[uv]",
"hatch",
"pip",
]
detached = true # ignore the project installation itself
type = "pip-compile"
pip-compile-hashes = true
pip-compile-installer = "uv"
pip-compile-resolver = "uv"
lock-filename = "requirements/{env_name}" # no .txt suffix, otherwise Dependabot will update this file as well

[tool.hatch.envs.docs]
features = [ "docs" ]
template = "docs"
type = "pip-compile"
pip-compile-hashes = true
pip-compile-installer = "uv"
pip-compile-resolver = "uv"
lock-filename = "requirements/{env_name}" # no .txt suffix, otherwise Dependabot will update this file as well

[tool.hatch.envs.docs.scripts]
build = "mkdocs build --config-file=docs/mkdocs.yml"
serve = "mkdocs serve --verbose --config-file=docs/mkdocs.yml"
Expand Down
Loading

0 comments on commit 2db9a2b

Please sign in to comment.