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

Use uv-pre-commit to validate lockfile #6699

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/actions/install-aiida-core/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
python-version: ${{ inputs.python-version }}

- name: Set up uv
uses: astral-sh/setup-uv@v5
uses: astral-sh/setup-uv@v5.2.0
with:
version: 0.5.x
python-version: ${{ inputs.python-version }}
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ jobs:
AIIDA_WARN_v3: 1
# NOTE1: Python 3.12 has a performance regression when running with code coverage
# so run code coverage only for python 3.9.
# TODO: Remove a workaround for VIRTUAL_ENV once the setup-uv action is updated
# https://github.com/astral-sh/setup-uv/issues/219
run: |
${{ matrix.python-version == '3.9' && 'VIRTUAL_ENV=$PWD/.venv' || '' }}
pytest -n auto --db-backend ${{ matrix.database-backend }} -m 'not nightly' tests/ ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}
- name: Upload coverage report
Expand Down
8 changes: 1 addition & 7 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/setup-uv@v5
uses: astral-sh/setup-uv@v5.2.0
with:
version: 0.5.x

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

- name: Validate uv lockfile
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to have this check only in one place.

run: uv lock --check

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

Expand Down Expand Up @@ -211,8 +208,5 @@ jobs:
env:
AIIDA_TEST_PROFILE: test_aiida
AIIDA_WARN_v3: 1
# TODO: Remove a workaround for VIRTUAL_ENV once the setup-uv action is updated
# https://github.com/astral-sh/setup-uv/issues/219
run: |
${{ matrix.python-version == '3.9' && 'VIRTUAL_ENV=$PWD/.venv' || '' }}
pytest -n auto --db-backend psql -m 'not nightly' tests/
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.20
hooks:
# 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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,6 @@ passenv =
AIIDA_TEST_WORKERS
commands = molecule {posargs:test}
"""

[tool.uv]
required-version = ">=0.5.20"
Loading