Skip to content

Commit

Permalink
chore: Use pdm instead of pipenv. (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Dec 21, 2023
1 parent 008caa4 commit ae62160
Show file tree
Hide file tree
Showing 53 changed files with 1,649 additions and 1,230 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ updates:
schedule:
interval: weekly
- commit-message:
prefix: build(requirements)
prefix: build(dependencies)
directory: /
groups:
dev:
Expand Down
57 changes: 6 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
name: CI
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
ci:
if: ${{ !cancelled() && ! failure() }}
needs: dependabot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: pdm-project/setup-pdm@v3
with:
cache: pip
cache: true
python-version: ${{ matrix.python-version }}
- run: env | sort
- run: make dev
Expand All @@ -28,74 +27,30 @@ jobs:
- '3.12'
consistency:
if: ${{ !cancelled() && ! failure() }}
needs: dependabot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Set up Python
uses: actions/setup-python@v5
- uses: pdm-project/setup-pdm@v3
with:
cache: pip
cache: true
python-version: '3.12'
- run: env | sort
- name: Install copier for template rendering using pipx
run: pipx install copier
- name: Generate the project with the default value
run: |
find . -maxdepth 1 | grep -vE '(\.|template|includes|\.git|copier\.yaml)$' | xargs -I {} rm -r {}
find . -maxdepth 1 | grep -vE '(\.|template|includes|\.git|copier\.yaml|pdm\.lock)$' | xargs -I {} rm -r {}
copier copy -d repo_host_type=gitlab.com -r HEAD -f . .
rm .copier-answers.yml
copier copy -r HEAD -f . .
rm .copier-answers.yml
- run: git diff
- run: git status --porcelain
- run: test -z "$(git status --porcelain)"
dependabot:
if: ${{ github.actor == 'dependabot[bot]' && startsWith(github.head_ref, 'dependabot/pip/') }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Set up Git
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Set up Python with multiple versions.
uses: actions/setup-python@v5
with:
cache: pip
python-version: |
3.8
3.9
3.10
3.11
3.12
- name: Install pipenv using pipx
run: pipx install pipenv
- name: Generate constraints for all supported Python versions
run: |
CI= PYTHON_VERSION=3.8 make constraints
CI= PYTHON_VERSION=3.9 make constraints
CI= PYTHON_VERSION=3.10 make constraints
CI= PYTHON_VERSION=3.11 make constraints
CI= PYTHON_VERSION=3.12 make constraints
- name: Sync template
run: cp -v constraints/* template/constraints/
- name: Push changes if applicable
run: |
if [[ -n `git status --porcelain` ]]; then
git commit -a -m "build: Update constraints for dependabot."
git push
fi
name: CI
on:
pull_request:
types:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Lint pull request title
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -12,7 +13,6 @@ jobs:
echo 'Please refer to "https://www.conventionalcommits.org/"'
exit 1
fi
name: Lint pull request title
on:
pull_request:
types:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/readthedocs-preview.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Read the Docs Pull Request Preview
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -8,7 +9,6 @@ jobs:
- uses: readthedocs/actions/preview@v1
with:
project-slug: ss-python
name: Read the Docs Pull Request Preview
on:
pull_request_target:
types:
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
name: Release
jobs:
package:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: pdm-project/setup-pdm@v3
with:
cache: pip
cache: true
python-version: '3.12'
- run: env | sort
- run: make dev-package
- run: make build
- env:
TWINE_NON_INTERACTIVE: true
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_USERNAME: ${{ vars.TWINE_USERNAME != '' && vars.TWINE_USERNAME || '__token__' }}
run: make upload
PDM_PUBLISH_PASSWORD: ${{ secrets.PDM_PUBLISH_PASSWORD }}
PDM_PUBLISH_USERNAME: ${{ vars.PDM_PUBLISH_USERNAME != '' && vars.PDM_PUBLISH_USERNAME || '__token__' }}
run: make publish
pages-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
- uses: pdm-project/setup-pdm@v3
with:
cache: pip
cache: true
python-version: '3.12'
- run: env | sort
- run: make dev-docs
Expand Down Expand Up @@ -81,7 +77,6 @@ jobs:
with:
body_path: release-notes.md
prerelease: ${{ steps.prerelease.outputs.is_prerelease }}
name: Release
on:
push:
tags:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
*.swp
.DS_Store
.copier-answers.yml
# TODO: Move `.pdm-python` out of custom section when upstream pull request merged.
# Reference: https://github.com/github/gitignore/pull/4279
.pdm-python
Pipfile
public
release-notes.md
Expand Down
6 changes: 1 addition & 5 deletions .gitlab/ci/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ package:
- /^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:
- env | sort
- make dev-package
- make build
- make upload
- make publish
stage: release
variables:
TWINE_NON_INTERACTIVE: 'true'
pages:
artifacts:
paths:
Expand Down
44 changes: 27 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
default_install_hook_types:
- post-checkout
- post-merge
- pre-push
default_stages:
- manual
- pre-push
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -17,30 +24,33 @@ repos:
- id: name-tests-test
- id: no-commit-to-branch
stages:
- push
- pre-push
- id: pretty-format-json
args:
- '--autofix'
- id: requirements-txt-fixer
args:
- constraints/3.8.txt
- constraints/3.9.txt
- constraints/3.10.txt
- constraints/3.11.txt
- constraints/3.12.txt
- requirements.txt
- requirements/docs.txt
- requirements/lint.txt
- requirements/package.txt
- requirements/test.txt
- id: sort-simple-yaml
files: .pre-commit-config.yaml
- id: trailing-whitespace
- repo: local
hooks:
- id: pdm-sync
name: pdm-sync
entry: pdm sync
language: python
stages:
- post-checkout
- post-merge
always_run: true
pass_filenames: false
- id: pdm-lock
name: pdm-lock
entry: pdm lock
language: python
files: ^pyproject.toml$
pass_filenames: false
- id: mypy
name: mypy
entry: pipenv run python -m mypy
entry: pdm run python -m mypy
language: system
exclude: ^template/.*
types_or:
Expand All @@ -49,23 +59,23 @@ repos:
require_serial: true
- id: ruff
name: ruff
entry: pipenv run python -m ruff check --force-exclude
entry: pdm run python -m ruff check --force-exclude
language: system
types_or:
- python
- pyi
require_serial: true
- id: ruff-format
name: ruff-format
entry: pipenv run python -m ruff format --force-exclude
entry: pdm run python -m ruff format --force-exclude
language: system
types_or:
- python
- pyi
require_serial: true
- id: toml-sort
name: toml-sort
entry: pipenv run toml-sort
entry: pdm run toml-sort
language: system
types:
- toml
Expand Down
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build:
post_checkout:
- git fetch --unshallow || true
post_install:
- python -m pip install --upgrade --no-cache-dir pdm
- make dev-docs
pre_build:
- make changelog
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"pipx",
"pycache",
"pydantic",
"pyproject",
"pytest",
"Quickstart",
"setuptools",
Expand Down
Loading

0 comments on commit ae62160

Please sign in to comment.