Skip to content

Commit

Permalink
Move CI to pdm (os-climate#42)
Browse files Browse the repository at this point in the history
* Changes to remove tox and move CI to use pdm.

Signed-off-by: Joe Moorhouse <5102656+joemoorhouse@users.noreply.github.com>

---------

Signed-off-by: Joe Moorhouse <5102656+joemoorhouse@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
joemoorhouse and pre-commit-ci[bot] authored Mar 31, 2024
1 parent 608f570 commit 10ba9b3
Show file tree
Hide file tree
Showing 25 changed files with 187 additions and 4,010 deletions.
39 changes: 20 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@ on:
pull_request:
branches: [ main ]

env:
python-version: "3.8"

jobs:
ci:
runs-on: ubuntu-latest

runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.9, '3.10', '3.11']
os: [ubuntu-latest]
# add, if needed: [macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v4

- name: "Setup Python"
uses: actions/setup-python@v4.7.0
with:
python-version: ${{ env.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run auto-tests
run: tox
- uses: actions/checkout@v3
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pdm config venv.with_pip True
pdm sync -d -G testing
- name: Run Tests and Checks
run: |
pdm run all
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ src/inventories/hazard/inventory_live.json
.vscode/launch.json
.vscode/settings.json
.pdm-python
.python-version
39 changes: 37 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict

- id: end-of-file-fixer
- id: name-tests-test
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-toml
- id: check-yaml
- id: check-symlinks
- id: detect-private-key
- id: check-ast
- id: debug-statements

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-tabs

- repo: https://github.com/psf/black
rev: '24.2.0'
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/s-weigand/flake8-nb
rev: v0.5.3
hooks:
- id: flake8-nb
additional_dependencies:
- pep8-naming
# Ignore all format-related checks as Black takes care of those.
args:
- --ignore=E2, W5, F401, E401, E704
- --select=E, W, F, N
- --max-line-length=120
21 changes: 7 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ consistent working environment. Install via, e.g.:
pip install pdm
```

For use with Jupyter, the configuration is convenient:
For use with Jupyter and mypy, the configuration is needed:
```
pdm config venv.with_pip True
```
Expand All @@ -32,7 +32,7 @@ testing or development, `pdm add -dG <group> <package-name>`.
### JupyterHub and requirements.txt
It may be useful to generate a requirements.txt file:
```
pipenv requirements > requirements.txt
pdm export -o requirements.txt --without-hashes
```

## Development
Expand All @@ -42,6 +42,11 @@ https://github.com/os-climate/hazard.
All changes must pass the automated test suite, along with various static
checks.

The easiest way to run these is via:
```
pdm run all
```

[Black](https://black.readthedocs.io/) code style and
[isort](https://pycqa.github.io/isort/) import ordering are enforced
and enabling automatic formatting via [pre-commit](https://pre-commit.com/)
Expand All @@ -60,18 +65,6 @@ isort .
black .
```

Code can then be tested using tox.
```
# run static checks and unit tests
tox
# run only tests
tox -e py3
# run only static checks
tox -e static
# run unit tests and produce an HTML code coverage report (/htmlcov)
tox -e cov
```

## IDE set-up
For those using VS Code, configure tests ('Python: Configure Tests') to use 'pytest'
to allow running of tests within the IDE.
Expand Down
Loading

0 comments on commit 10ba9b3

Please sign in to comment.