Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
cooldown:
default-days: 7
schedule:
interval: "weekly"
day: "monday"
groups:
minor-and-patch:
applies-to: version-updates
patterns:
- "*"
update-types:
- "minor"
- "patch"
70 changes: 16 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,42 @@ on:
- '*'
pull_request:
env:
LATEST_PY_VERSION: '3.10'
LATEST_PY_VERSION: '3.14'

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
python-version: ['3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
version: "0.9.*"
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install module
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .["test"]
uv sync

- name: run pre-commit
- name: Run pre-commit
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
run: |
python -m pip install pre-commit
pre-commit run --all-files
uv run pre-commit run --all-files

- name: Run tests
run: python -m pytest --cov supermorecado --cov-report term-missing --cov-report xml
run: uv run pytest --cov supermorecado --cov-report xml --cov-report term-missing

- name: Upload Results
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192 # v1
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6
with:
file: ./coverage.xml
files: ./coverage.xml
flags: unittests
name: Python${{ matrix.python-version }}
fail_ci_if_error: false

publish:
needs: [tests]
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Set up Python
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
with:
python-version: ${{ env.LATEST_PY_VERSION }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flit
python -m pip install .

- name: Set tag version
id: tag
run: |
echo "version=${GITHUB_REF#refs/*/}"
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Set module version
id: module
run: |
echo version=$(python -c'import supermorecado; print(supermorecado.__version__)') >> $GITHUB_OUTPUT

- name: Build and publish
if: ${{ steps.tag.outputs.version }} == ${{ steps.module.outputs.version}}
env:
FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }}
FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: flit publish
token: ${{ secrets.CODECOV_TOKEN }}
17 changes: 7 additions & 10 deletions .github/workflows/deploy_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Set up Python 3.8
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install mkdocs mkdocs-material pygments
version: "0.9.*"
enable-cache: true

- name: Deploy docs
run: mkdocs gh-deploy --force -f docs/mkdocs.yml
run: uv run --frozen --group docs mkdocs gh-deploy --force -f docs/mkdocs.yml

73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release

on:
push:
tags:
- '*'
env:
LATEST_PY_VERSION: '3.14'

jobs:
build:
name: Build dist
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.9.*"
enable-cache: true
python-version: ${{ env.LATEST_PY_VERSION }}

- name: Install dependencies
run: |
uv sync --group deploy

- name: Set tag version
id: tag
run: |
echo "version=${GITHUB_REF#refs/*/}"
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Set module version
id: module
run: |
echo "version=$(uv run hatch --quiet version)" >> $GITHUB_OUTPUT

- name: Check version match
run: |
if [ "${{ steps.tag.outputs.version }}" != "${{ steps.module.outputs.version }}" ]; then
echo "Tag version (${{ steps.tag.outputs.version }}) does not match module version (${{ steps.module.outputs.version }})"
exit 1
fi

- name: Build
run: |
uv run hatch build

- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
path: ./dist/

upload_pypi:
name: Upload release to PyPI
needs: [build]
runs-on: ubuntu-latest
environment:
# Note: this environment must be configured in the repo settings
name: pypi-release
url: https://pypi.org/p/supermorcado
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: artifact
path: dist
merge-multiple: true

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
17 changes: 6 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
rev: v0.25
hooks:
- id: validate-pyproject

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
language_version: python

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 8.0.1
hooks:
- id: isort
language_version: python

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.238
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.9
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.20.0
hooks:
- id: mypy
language_version: python
Expand Down
31 changes: 16 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,46 @@

Issues and pull requests are more than welcome.

**dev install**
We recommand using [`uv`](https://docs.astral.sh/uv) as project manager for development.

See https://docs.astral.sh/uv/getting-started/installation/ for installation

### dev install

```bash
$ git clone https://github.com/developmentseed/supermorecado.git
$ cd supermorecado
$ python -m pip install -e .["dev"]
git clone https://github.com/developmentseed/supermorecado.git
cd supermorecado

uv sync
```

You can then run the tests with the following command:

```sh
python -m pytest --cov supermorecado --cov-report term-missing -s -vv
uv run pytest --cov supermorecado --cov-report term-missing

```

### pre-commit

This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.

```bash
$ pre-commit install
uv run pre-commit install
```

### Docs

```bash
$ git clone https://github.com/developmentseed/supermorecado.git
$ cd supermorecado
$ python -m pip install -e .["docs"]
```

Hot-reloading docs:
git clone https://github.com/developmentseed/supermorecado.git
cd supermorecado

```bash
$ mkdocs serve -f docs/mkdocs.yml
uv run --group docs mkdocs serve -f docs/mkdocs.yml
```

To manually deploy docs (note you should never need to do this because Github
Actions deploys automatically for new commits.):

```bash
$ mkdocs gh-deploy -f docs/mkdocs.yml
uv run --group docs mkdocs gh-deploy -f docs/mkdocs.yml
```
Loading