Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
template update
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Nov 17, 2023
1 parent b65931c commit 0e81ecf
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 42 deletions.
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": "e1fc4734213fe5ff14f1d95c755a9f25448447bc",
"commit": "59c6471bda34e48214cdcf5905590fb5a96507ad",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
104 changes: 72 additions & 32 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 @@ -142,17 +153,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 @@ -174,21 +188,47 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install packages
- uses: actions/setup-python@v4
with:
python-version: 3.x
- 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 cads_api_client*.whl || exit
$CONDA/bin/python -m twine check * || exit
$CONDA/bin/python -c "import cads_api_client"
- 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 cads_api_client*.whl || exit
python -m twine check --strict * || exit
python -c "import cads_api_client" || 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/cads-api-client
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/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
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
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,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 @@ -56,6 +57,9 @@ select = [
"D"
]

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

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

Expand Down

0 comments on commit 0e81ecf

Please sign in to comment.