Skip to content

Commit

Permalink
Use uv-pre-commit to validate lockfile (aiidateam#6699)
Browse files Browse the repository at this point in the history
The previous uv hook that checked whether uv lockfile is up-to-date required
the developer to have uv installed. Using the official uv-pre-commit hook, this
is no longer the case. The hook also updates the lock automatically, instead of
just checking its status.

Bump minimum version of uv to `0.5.21` fix issue
astral-sh/uv#10689 uv does run the build backend for
projects with dynamic versioning.

Bump astral-sh/setup-uv action to v5.2.1.

Change in `.github/workflows/ci-code.yml` (`file` -> `files`) is related to
fixing a warning in the CI.
  • Loading branch information
danielhollas authored and unkcpz committed Jan 28, 2025
1 parent d0c9572 commit df65548
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/actions/install-aiida-core/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ runs:
python-version: ${{ inputs.python-version }}

- name: Set up uv
uses: astral-sh/[email protected].0
uses: astral-sh/[email protected].1
with:
version: 0.5.x
version: 0.5.22
python-version: ${{ inputs.python-version }}

- name: Install dependencies from uv lock
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: aiida-pytests-py3.9
file: ./coverage.xml
files: ./coverage.xml
fail_ci_if_error: false # don't fail job, if coverage upload fails

tests-presto:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ jobs:
python-version: '3.11'

- name: Set up uv
uses: astral-sh/[email protected].0
uses: astral-sh/[email protected].1
with:
version: 0.5.x
version: latest

- name: Install utils/ dependencies
run: uv pip install --system -r utils/requirements.txt

- name: Validate uv lockfile
run: uv lock --check

- name: Validate conda environment file
run: python ./utils/dependency_management.py validate-environment-yml

Expand Down
20 changes: 7 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
autofix_prs: true
autoupdate_commit_msg: 'Devops: Update pre-commit dependencies'
autoupdate_schedule: quarterly
skip: [mypy, check-uv-lock, generate-conda-environment, validate-conda-environment, verdi-autodocs]
skip: [mypy, generate-conda-environment, validate-conda-environment, verdi-autodocs]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -56,6 +56,12 @@ repos:
environment.yml|
)$
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.22
hooks:
# Check and update the uv lockfile
- id: uv-lock

- repo: local

hooks:
Expand Down Expand Up @@ -187,18 +193,6 @@ repos:
src/aiida/workflows/arithmetic/multiply_add.py|
)$
- id: check-uv-lock
name: Check uv lockfile up to date
# NOTE: This will not automatically update the lockfile
entry: uv lock --check
language: system
pass_filenames: false
files: >-
(?x)^(
pyproject.toml|
uv.lock|
)$
- id: generate-conda-environment
name: Update conda environment file
entry: python ./utils/dependency_management.py generate-environment-yml
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ build:
# https://docs.readthedocs.io/en/stable/build-customization.html#install-dependencies-with-uv
pre_create_environment:
- asdf plugin add uv
- asdf install uv 0.5.20
- asdf global uv 0.5.20
- asdf install uv 0.5.22
- asdf global uv 0.5.22
create_environment:
- uv venv
install:
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,8 @@ commands = molecule {posargs:test}
"""

[tool.uv]
required-version = ">=0.5.20"
# NOTE: When you bump the minimum uv version, you also need to change it in:
# .pre-commit-config.yaml
# .github/actions/install-aiida-core/action.yml
# .readthedocs.yml
required-version = ">=0.5.21"

0 comments on commit df65548

Please sign in to comment.