Skip to content

Commit

Permalink
build: split prod and dev lock files for pdm (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Nov 13, 2024
1 parent e476dfe commit fea9391
Show file tree
Hide file tree
Showing 18 changed files with 1,271 additions and 964 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
cache: true
python-version: ${{ matrix.python-version }}
version: 2.20.1
cache-dependency-path: |
./pdm.dev.lock
./pdm.lock
- run: env | sort
- run: make prerequisites
- run: make dev
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/readthedocs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- Makefile
- README.md
- docs/**
- pdm.dev.lock
- pdm.lock
permissions:
pull-requests: write
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
cache: true
python-version: '3.12'
version: 2.20.1
cache-dependency-path: |
./pdm.dev.lock
./pdm.lock
- run: env | sort
- run: make dev-doc
- run: make doc
Expand Down Expand Up @@ -124,6 +127,9 @@ jobs:
cache: true
python-version: '3.12'
version: 2.20.1
cache-dependency-path: |
./pdm.dev.lock
./pdm.lock
- run: env | sort
- env:
PDM_PUBLISH_PASSWORD: ${{ secrets.PDM_PUBLISH_PASSWORD }}
Expand Down
1 change: 1 addition & 0 deletions .gitlab/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ci:
- .venv
key:
files:
- pdm.dev.lock
- pdm.lock
prefix: venv-${PYTHON_VERSION}
coverage: /TOTAL.*? (100(?:\.0+)?\%\|[1-9]?\d(?:\.\d+)?\%)$/
Expand Down
10 changes: 10 additions & 0 deletions .gitlab/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pages-build:
- .venv
key:
files:
- pdm.dev.lock
- pdm.lock
prefix: venv-${PYTHON_VERSION}
policy: pull
Expand Down Expand Up @@ -97,6 +98,15 @@ container-publish:
PYTHON_VERSION: ${PYTHON_VERSION}
SOURCE_DATE_EPOCH: 0
package-publish:
cache:
paths:
- .venv
key:
files:
- pdm.dev.lock
- pdm.lock
prefix: venv-${PYTHON_VERSION}
policy: pull
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
Expand Down
18 changes: 17 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@ repos:
hooks:
- id: pdm-sync
name: pdm-sync
entry: pdm sync --clean
entry: pdm sync
language: python
stages:
- post-checkout
- post-merge
- post-rewrite
always_run: true
pass_filenames: false
- id: pdm-dev-sync
name: pdm-dev-sync
entry: pdm sync --lockfile pdm.dev.lock
language: python
stages:
- post-checkout
Expand All @@ -50,6 +60,12 @@ repos:
language: python
files: ^pyproject.toml$
pass_filenames: false
- id: pdm-dev-lock-check
name: pdm-lock-check
entry: pdm lock --check --lockfile pdm.dev.lock
language: python
files: ^pyproject.toml$
pass_filenames: false
- id: mypy
name: mypy
entry: pdm run python -m mypy
Expand Down
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build:
Makefile \
README.md \
docs/ \
pdm.dev.lock \
pdm.lock;
then
exit 183;
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ install:
pdm sync --prod

# Install the package in editable mode with specific optional dependencies.
dev-%:
pdm sync --dev --group $*
dev-%: install
pdm sync --lockfile pdm.dev.lock --no-default --dev --group $*

# Prepare the development environment.
# Install the package in editable mode with all optional dependencies and pre-commit hook.
dev:
pdm sync
dev: install
pdm sync --lockfile pdm.dev.lock
if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi

# Install standalone tools
Expand Down Expand Up @@ -157,7 +157,7 @@ template-watch:
watchfiles "make template-build" template includes copier.yaml

template-build:
find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock)$$' | xargs -I {} rm -r {}
find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock|pdm\.dev\.lock)$$' | xargs -I {} rm -r {}
copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_platform=gitlab -f . .
rm -rf .copier-answers.yml
copier copy -r HEAD --data-file includes/copier-answers-sample.yml -f . .
Expand Down
1,170 changes: 1,170 additions & 0 deletions pdm.dev.lock

Large diffs are not rendered by default.

965 changes: 13 additions & 952 deletions pdm.lock

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion template/.pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ repos:
hooks:
- id: pdm-sync
name: pdm-sync
entry: pdm sync --clean
entry: pdm sync
language: python
stages:
- post-checkout
- post-merge
- post-rewrite
always_run: true
pass_filenames: false
- id: pdm-dev-sync
name: pdm-dev-sync
entry: pdm sync --lockfile pdm.dev.lock
language: python
stages:
- post-checkout
Expand All @@ -51,6 +61,12 @@ repos:
language: python
files: ^pyproject.toml$
pass_filenames: false
- id: pdm-dev-lock-check
name: pdm-lock-check
entry: pdm lock --check --lockfile pdm.dev.lock
language: python
files: ^pyproject.toml$
pass_filenames: false
- id: mypy
name: mypy
entry: pdm run python -m mypy
Expand Down
1 change: 1 addition & 0 deletions template/.readthedocs.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build:
Makefile \
README.md \
docs/ \
pdm.dev.lock \
pdm.lock;
then
exit 183;
Expand Down
10 changes: 5 additions & 5 deletions template/Makefile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ install:
pdm sync --prod

# Install the package in editable mode with specific optional dependencies.
dev-%:
pdm sync --dev --group $*
dev-%: install
pdm sync --lockfile pdm.dev.lock --no-default --dev --group $*

# Prepare the development environment.
# Install the package in editable mode with all optional dependencies and pre-commit hook.
dev:
pdm sync
dev: install
pdm sync --lockfile pdm.dev.lock
if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi

# Install standalone tools
Expand Down Expand Up @@ -164,7 +164,7 @@ template-watch:
watchfiles "make template-build" template includes copier.yaml

template-build:
find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock)$$' | xargs -I {} rm -r {}
find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock|pdm\.dev\.lock)$$' | xargs -I {} rm -r {}
copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_platform=gitlab -f . .
rm -rf .copier-answers.yml
copier copy -r HEAD --data-file includes/copier-answers-sample.yml -f . .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
cache: true
python-version: {{ '${{ matrix.python-version }}' }}
version: 2.20.1
cache-dependency-path: |
./pdm.dev.lock
./pdm.lock
- run: env | sort
- run: make prerequisites
- run: make dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- Makefile
- README.md
- docs/**
- pdm.dev.lock
- pdm.lock
permissions:
pull-requests: write
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
cache: true
python-version: '{{ default_py }}'
version: 2.20.1
cache-dependency-path: |
./pdm.dev.lock
./pdm.lock
- run: env | sort
- run: make dev-doc
- run: make doc
Expand Down Expand Up @@ -135,6 +138,9 @@ jobs:
cache: true
python-version: '{{ default_py }}'
version: 2.20.1
cache-dependency-path: |
./pdm.dev.lock
./pdm.lock
- run: env | sort
- env:
PDM_PUBLISH_PASSWORD: {{ '${{ secrets.PDM_PUBLISH_PASSWORD }}' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ci:
- .venv
key:
files:
- pdm.dev.lock
- pdm.lock
prefix: venv-${PYTHON_VERSION}
coverage: /TOTAL.*? (100(?:\.0+)?\%\|[1-9]?\d(?:\.\d+)?\%)$/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pages-build:
- .venv
key:
files:
- pdm.dev.lock
- pdm.lock
prefix: venv-${PYTHON_VERSION}
policy: pull
Expand Down Expand Up @@ -108,6 +109,15 @@ container-publish:
PYTHON_VERSION: ${PYTHON_VERSION}
SOURCE_DATE_EPOCH: 0
package-publish:
cache:
paths:
- .venv
key:
files:
- pdm.dev.lock
- pdm.lock
prefix: venv-${PYTHON_VERSION}
policy: pull
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
Expand Down

0 comments on commit fea9391

Please sign in to comment.