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

template update #64

Merged
merged 1 commit into from
Nov 17, 2023
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
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/ecmwf-projects/cookiecutter-conda-package",
"commit": "22b85d3aca63d05f4a19f1a531bcea311617f4cd",
"commit": "ce9afbb8510935c0206746d26f05f6b80e9d0087",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
108 changes: 73 additions & 35 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install conda-merge
run: |
$CONDA/bin/python -m pip install conda-merge
python -m pip install conda-merge
- name: Combine environments
run: |
for SUFFIX in ci integration; do
$CONDA/bin/conda-merge ci/environment-$SUFFIX.yml environment.yml > ci/combined-environment-$SUFFIX.yml || exit
conda-merge ci/environment-$SUFFIX.yml environment.yml > ci/combined-environment-$SUFFIX.yml || exit
done
- name: Archive combined environments
uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v3
with:
name: combined-environments
path: ci/combined-environment-*.yml
Expand All @@ -57,17 +59,20 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Download combined environments
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v3
with:
name: combined-environments
path: ci
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/combined-environment-ci.yml
environment-name: DEVELOP
cache-environment: true
cache-environment-key: environment-${{ steps.date.outputs.date }}
cache-downloads-key: downloads-${{ steps.date.outputs.date }}
create-args: >-
python=${{ matrix.python-version }}
- name: Install package
Expand All @@ -83,17 +88,20 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Download combined environments
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v3
with:
name: combined-environments
path: ci
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/combined-environment-ci.yml
environment-name: DEVELOP
cache-environment: true
cache-environment-key: environment-${{ steps.date.outputs.date }}
cache-downloads-key: downloads-${{ steps.date.outputs.date }}
create-args: >-
python=3.10
- name: Install package
Expand All @@ -109,17 +117,20 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Download combined environments
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v3
with:
name: combined-environments
path: ci
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/combined-environment-ci.yml
environment-name: DEVELOP
cache-environment: true
cache-environment-key: environment-${{ steps.date.outputs.date }}
cache-downloads-key: downloads-${{ steps.date.outputs.date }}
create-args: >-
python=3.10
- name: Install package
Expand All @@ -145,17 +156,20 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Download combined environments
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v3
with:
name: combined-environments
path: ci
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/combined-environment${{ matrix.extra }}.yml
environment-name: DEVELOP${{ matrix.extra }}
cache-environment: true
cache-environment-key: environment-${{ steps.date.outputs.date }}
cache-downloads-key: downloads-${{ steps.date.outputs.date }}
create-args: >-
python=${{ matrix.python-version }}
- name: Install package
Expand All @@ -168,11 +182,6 @@ jobs:
distribution:
runs-on: ubuntu-latest
needs: [unit-tests, type-check, docs-build, integration-tests]
environment:
name: pypi
url: https://pypi.org/p/ogc-api-processes-fastapi
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publish
if: |
always() &&
needs.unit-tests.result == 'success' &&
Expand All @@ -182,18 +191,47 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install packages
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install package
run: |
$CONDA/bin/python -m pip install build twine
- name: Build distributions
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distribution
run: |
$CONDA/bin/python -m build
python -m build
- name: Check wheels
run: |
cd dist || exit
$CONDA/bin/python -m pip install ogc_api_processes_fastapi*.whl || exit
$CONDA/bin/python -m twine check * || exit
$CONDA/bin/python -c "import ogc_api_processes_fastapi"
- name: Publish a Python distribution to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
python -m pip install ogc_api_processes_fastapi*.whl || exit
python -m twine check --strict * || exit
python -c "import ogc_api_processes_fastapi" || exit
cd ..
- uses: actions/upload-artifact@v3
with:
name: distribution
path: dist

upload-to-pypi:
runs-on: ubuntu-latest
needs: distribution
if: |
always() &&
needs.distribution.result == 'success' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags')
environment:
name: pypi
url: https://pypi.org/p/ogc-api-processes-fastapi
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publish

steps:
- uses: actions/download-artifact@v3
with:
name: distribution
path: dist
- uses: pypa/[email protected]
with:
verbose: true
12 changes: 5 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ repos:
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- id: check-merge-conflict
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [black==22.3.0]
additional_dependencies: [black==23.11.0]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.5
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand Down
2 changes: 1 addition & 1 deletion ogc_api_processes_fastapi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def register_route(
response_model_exclude_unset=True,
response_model_exclude_none=True,
endpoint=route_endpoint,
**config.ROUTES[route_name].model_dump(exclude={"client_method"})
**config.ROUTES[route_name].model_dump(exclude={"client_method"}),
)


Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ ignore = [
# pydocstyle: Missing Docstrings
"D1"
]
# Black line length is 88, but black does not format comments.
line-length = 110
# Same as Black.
indent-width = 4
line-length = 88
select = [
# pyflakes
"F",
Expand All @@ -50,6 +51,9 @@ select = [
"D"
]

[tool.ruff.lint.pycodestyle]
max-line-length = 110

[tool.ruff.pydocstyle]
convention = "numpy"

Expand Down
Loading