Skip to content

Commit

Permalink
switch to pdm
Browse files Browse the repository at this point in the history
  • Loading branch information
AbstractUmbra committed Dec 15, 2024
1 parent 522369d commit c1f1886
Show file tree
Hide file tree
Showing 7 changed files with 1,272 additions and 1,918 deletions.
69 changes: 21 additions & 48 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,62 +26,36 @@ jobs:
with:
fetch-depth: 0

- name: "Load cached poetry installation @ ${{ matrix.python-version }}"
id: cached-poetry
uses: actions/cache@v4
- name: "Setup PDM @ ${{ matrix.python-version }}"
uses: pdm-project/setup-pdm@v4
with:
path: ~/.local
key: poetry-0
python-version: ${{matrix.python-version}}
cache: true

- name: "Setup Poetry @ ${{ matrix.python-version }}"
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv

- name: "Setup Python @ ${{ matrix.python-version }}"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
cache: "poetry"

- name: "Load cached venv @ ${{ matrix.python-version }}"
id: cached-pip-wheels
uses: actions/cache@v4
with:
path: .venv/
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: "Install Python deps @ ${{ matrix.python-version }}"
if: ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
id: install-deps
- name: "Install deps @ ${{ matrix.python-version }}"
run: |
poetry install --no-interaction
pdm install --prod --check --no-editable
- name: Activate venv @ ${{ matrix.python-version }}
- name: "Activate venv @ ${{ matrix.python-version }}"
run: |
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
echo "$(pdm info --where)/.venv/bin" >> $GITHUB_PATH
- name: "Check it imports @ ${{ matrix.python-version }}"
run: |
poetry run python -c 'import hondana'
pdm run python -c 'import hondana'
- name: "Test Suite @ ${{ matrix.python-version }}"
run: |
poetry run pytest
pdm run tests
- name: "Build wheels @ ${{ matrix.python-version}}"
run: |
poetry build
pdm build
- name: "Build docs @ ${{ matrix.python-version}}"
working-directory: docs/
run: |
cd docs/
poetry run sphinx-build -aETW --keep-going . build
pdm run docs
- name: "Upload artifacts @ ${{ matrix.python-version}}"
if: matrix.python-version == '3.11'
Expand All @@ -97,6 +71,9 @@ jobs:
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4
Expand All @@ -123,16 +100,12 @@ jobs:
tag_name="${GITHUB_REF##*/}"
gh release create "$tag_name" -F "CHANGELOG.md" "${assets[@]}"
- name: "Set up Poetry"
uses: snok/install-poetry@v1
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
version: 1.2.0
virtualenvs-create: true
virtualenvs-in-project: false
python-version: 3.11
cache: true

- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish
pdm publish
33 changes: 7 additions & 26 deletions .github/workflows/coverage_and_lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,19 @@ jobs:
with:
fetch-depth: 0

- name: "Load cached poetry installation @ ${{ matrix.python-version }}"
id: cached-poetry
uses: actions/cache@v4
- name: Setup PDM @ ${{ matrix.python-version }}
uses: pdm-project/setup-pdm@v4
with:
path: ~/.local
key: poetry-0
python-version: ${{ matrix.python-version }}
cache: true

- name: "Setup Poetry @ ${{ matrix.python-version }}"
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: "Setup Python @ ${{ matrix.python-version }}"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
cache: "poetry"

- name: "Install Python deps @ ${{ matrix.python-version }}"
if: ${{ steps.setup-python.outputs.cache-hit != 'true' }}
id: install-deps
- name: Install deps @ ${{ matrix.python-version }}
run: |
poetry install --without=dev --no-interaction
pdm install --check --no-editable
- name: Activate venv @ ${{ matrix.python-version }}
run: |
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
echo "$(pdm info --where)/.venv/bin" >> $GITHUB_PATH
- name: "Run Pyright @ ${{ matrix.python-version }}"
uses: jakebailey/pyright-action@v2
Expand All @@ -65,5 +47,4 @@ jobs:
annotate: ${{ matrix.python-version != '3.x' && 'all' || 'none' }}

- name: Lint
if: ${{ always() && steps.install-deps.outcome == 'success' }}
uses: astral-sh/ruff-action@v2
21 changes: 10 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# python ignores
__pycache__/
env/
build/
*.py[cod]
.venv/
dist/
build/
target/
.pdm-python

# docs related
docs/build
docs/_build
hondana.log
target/
.vscode/settings.json

# local testing
_api*.yaml
.hondana-refresh-token
_testing/
*.ipynb
_api*.ya?ml
_*.py
docker-compose.yml
_*
.vscode/settings.json

# media files
*.png
Expand Down
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
build:
jobs:
post_create_environment:
- pip install -U poetry
- poetry config virtualenvs.create false
- pip install -U pdm
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --without speedups
- pdm config python.use_venv true
- VIRTUAL_ENV=$(dirname $(dirname $(which python))) pdm install -dG docs
os: ubuntu-22.04
tools:
python: "3.11"
Expand Down
Loading

0 comments on commit c1f1886

Please sign in to comment.