Skip to content

Commit

Permalink
switch from poetry to pdm (#77)
Browse files Browse the repository at this point in the history
* first pdm config

* update ruff settings

* add black mirror

* add strict config

* add concurrency to github workflows

* add newer blacken docs

* switch workflows to pdm

* switch to dynamic versioning

* advance contributing explanation
  • Loading branch information
The-Ludwig authored Oct 31, 2023
1 parent 9d89d2c commit 93d63d7
Show file tree
Hide file tree
Showing 11 changed files with 2,000 additions and 2,035 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,28 @@ on:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
strategy:
matrix:
python-version: ["3.8"]
poetry-version: ["1.3"]
corsika-version: ["77500"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${{ matrix.poetry-version }}
- uses: actions/setup-python@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Install dependencies
run: poetry install --with dev
run: |
pdm sync -d -G testing
- name: Cache Corsika7
id: cache-corsika
uses: actions/cache@v3
Expand All @@ -38,10 +41,11 @@ jobs:
env:
CORSIKA_PW: ${{ secrets.CORSIKA_PW }}
CORSIKA_VERSION: ${{ matrix.corsika-version }}
- name: Run tests
run: poetry run coverage run --include="panama/**" -m pytest
- name: Run Tests
run: |
pdm run -v coverage run --include="panama/**" -m pytest
- name: Produce coverage xml
run: poetry run coverage xml
run: pdm run -v coverage xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release:
strategy:
Expand All @@ -16,14 +20,14 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${{ matrix.poetry-version }}
- uses: actions/setup-python@v4
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Install dependencies
run: poetry install --with dev
run: |
pdm sync -d -G testing
- name: Cache Corsika7
id: cache-corsika
uses: actions/cache@v3
Expand All @@ -37,15 +41,14 @@ jobs:
env:
CORSIKA_PW: ${{ secrets.CORSIKA_PW }}
CORSIKA_VERSION: ${{ matrix.corsika-version }}
- name: Run tests
run: poetry run coverage run --include="panama/**" -m pytest
- name: Run Tests
run: |
pdm run -v coverage run --include="panama/**" -m pytest
- name: Produce coverage xml
run: poetry run coverage xml
run: pdm run -v coverage xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Deploy to PyPi
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish --build
run: pdm publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.pdm-python
__pycache__
dist/
corsika_output/
Expand Down
16 changes: 9 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/psf/black
rev: 23.9.1
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.1
hooks:
- id: black
language_version: python3.11
- id: black-jupyter
language_version: python3.11

- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0" # replace with latest tag on GitHub
hooks:
- id: blacken-docs
additional_dependencies:
- black==22.10.0
- black==22.12.0

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.1
hooks:
- id: mypy
args: [--config-file, ./pyproject.toml]
Expand All @@ -48,6 +50,6 @@ repos:
- id: prettier

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.3
hooks:
- id: ruff
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# How to develop

This project uses [`pdm`](https://pdm.fming.dev/latest/) since version 0.7.0.
There are nice tutorials available on how to use `pdm`.

## Installing this in dev mode

1. Install pdm

```bash
pip install pdm # requires at least python 3.7
```

2. Create a new virtual environment for the project and install all dependencies

```bash
pdm venv create
pdm install --venv in-project
```

## Entering the dev shell

1. Activate the virtual environment:

```bash
eval $(pdm venv activate in-project)
```

**or alternatively enter a new sub-shell with the right venv**

```bash
pdm run $SHELL
```
2 changes: 1 addition & 1 deletion panama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .run import CorsikaRunner
from .weights import add_weight_prompt, add_weight_prompt_per_event, get_weights

__version__ = "0.6.1"
__version__ = "0.7.0"

__all__ = (
"read_DAT",
Expand Down
Loading

0 comments on commit 93d63d7

Please sign in to comment.