Skip to content

Commit

Permalink
chore: Use pdm instead of pipenv.
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan committed Dec 18, 2023
1 parent ae5a4de commit 045661e
Show file tree
Hide file tree
Showing 25 changed files with 1,460 additions and 588 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
55 changes: 5 additions & 50 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,18 +27,16 @@ 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
Expand All @@ -54,48 +51,6 @@ jobs:
- 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_USERNAME: ${{ 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
8 changes: 2 additions & 6 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 All @@ -48,4 +44,4 @@ release:
tag_name: $CI_COMMIT_TAG
script:
- env | sort
stage: release
stage: release
20 changes: 4 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,14 @@ repos:
- 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: 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 +37,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
Loading

0 comments on commit 045661e

Please sign in to comment.