Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance/review and update template #2

Merged
merged 22 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ jobs:

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- name: Install package
run: |
pip install .[dev]

- name: Build documentstion
- name: Build documentation
run: |
mkdocs build

- name: Publish to GitHub Pages
uses: peaceiris/actions-gh-pages@v3.6.1
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site
41 changes: 41 additions & 0 deletions .github/workflows/full_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Full test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1 # Fail fast if there are any linting errors
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
- name: Install my_library
run: |
pip install .[test]
- name: Static type check
run: make typecheck
- name: Test with pytest
run: |
make test
- name: Test docstrings with pytest
run: |
make doctest
37 changes: 0 additions & 37 deletions .github/workflows/python-app.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/python-publish.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/python_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Publish Python Package

on:
workflow_dispatch:

release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel twine

- name: Install package
run: pip install .[test]

- name: Test package
run: pytest

- name: Build package
run: python -m build

- name: Archive distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

# using a trusted publisher is recommended:
# https://docs.pypi.org/trusted-publishers/
# uncomment if you want to upload to PyPI
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
57 changes: 57 additions & 0 deletions .github/workflows/python_publish_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Use this file to test publishing your package to TestPyPI
#
# Same as python_publish.yml, but:
#
# - Manually triggered
# - No publishing to PyPI, instead it published to TestPyPI
#

name: Test Publish Python Package

on:
workflow_dispatch:

# release:
# types: [created]

jobs:
deploy:
runs-on: ubuntu-latest

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel twine

- name: Install package
run: pip install .[test]

- name: Test package
run: pytest

- name: Build package
run: python -m build

- name: Archive distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

10 changes: 6 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
},
"python.testing.pytestArgs": [
"tests"
],
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
}
"notebook.formatOnSave.enabled": true,
}
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
LIB = my_library

check: lint typecheck test doctest

build: typecheck test
python -m build

lint:
ruff check $(LIB)

format:
ruff format $(LIB)

test:
pytest --disable-warnings

typecheck:
mypy $(LIB)/ --config-file pyproject.toml

doctest:
pytest --doctest-modules $(LIB)

coverage:
pytest --cov-report html --cov=$(LIB) tests/

docs: FORCE
mkdocs build

clean:
python -c "import shutil; shutil.rmtree('dist', ignore_errors=True)"
python -c "import shutil; shutil.rmtree('htmlcov', ignore_errors=True)"
python -c "import os; os.remove('.coverage') if os.path.exists('.coverage') else None"
python -c "import shutil; shutil.rmtree('site', ignore_errors=True)"

FORCE:
2 changes: 1 addition & 1 deletion my_library/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""My Library has useful functionality"""
"""My Library has useful functionality"""
1 change: 1 addition & 0 deletions my_library/simulation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The simulation module"""

import numpy as np


Expand Down
Loading
Loading