-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ecmwf-projects/COPDS-1893
COPDS-1893: Cookiecutter
- Loading branch information
Showing
27 changed files
with
654 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"template": "https://github.com/ecmwf-projects/cookiecutter-conda-package", | ||
"commit": "3b34cec552be24da244f3ec6133685c83a4e9f6c", | ||
"checkout": null, | ||
"context": { | ||
"cookiecutter": { | ||
"project_name": "cads-mars-server", | ||
"project_slug": "cads_mars_server", | ||
"project_short_description": "A proxy MARS server and client designed for CADS", | ||
"copyright_holder": "European Union", | ||
"copyright_year": "2024", | ||
"mypy_strict": false, | ||
"integration_tests": "true", | ||
"pypi": true, | ||
"_template": "https://github.com/ecmwf-projects/cookiecutter-conda-package" | ||
} | ||
}, | ||
"directory": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
name: on-push | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
- uses: pre-commit/action@v3.0.1 | ||
|
||
combine-environments: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
- name: Install conda-merge | ||
run: | | ||
python -m pip install conda-merge | ||
- name: Combine environments | ||
run: | | ||
for SUFFIX in ci integration; do | ||
conda-merge ci/environment-$SUFFIX.yml environment.yml > ci/combined-environment-$SUFFIX.yml || exit | ||
done | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: combined-environments | ||
path: ci/combined-environment-*.yml | ||
|
||
unit-tests: | ||
name: unit-tests | ||
needs: combine-environments | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.11'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: combined-environments | ||
path: ci | ||
- 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 | ||
run: | | ||
python -m pip install --no-deps -e . | ||
- name: Run tests | ||
run: | | ||
make unit-tests COV_REPORT=xml | ||
type-check: | ||
needs: [combine-environments, unit-tests] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: combined-environments | ||
path: ci | ||
- 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.11 | ||
- name: Install package | ||
run: | | ||
python -m pip install --no-deps -e . | ||
- name: Run code quality checks | ||
run: | | ||
make type-check | ||
docs-build: | ||
needs: [combine-environments, unit-tests] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: combined-environments | ||
path: ci | ||
- 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.11 | ||
- name: Install package | ||
run: | | ||
python -m pip install --no-deps -e . | ||
- name: Build documentation | ||
run: | | ||
make docs-build | ||
integration-tests: | ||
needs: [combine-environments, unit-tests] | ||
if: | | ||
success() && true | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- python-version: '3.6' | ||
extra: -integration | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: combined-environments | ||
path: ci | ||
- 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 | ||
run: | | ||
python -m pip install --no-deps -e . | ||
- name: Run tests | ||
run: | | ||
make unit-tests COV_REPORT=xml | ||
distribution: | ||
runs-on: ubuntu-latest | ||
needs: [unit-tests, type-check, docs-build, integration-tests] | ||
if: | | ||
always() && | ||
needs.unit-tests.result == 'success' && | ||
needs.type-check.result == 'success' && | ||
needs.docs-build.result == 'success' && | ||
(needs.integration-tests.result == 'success' || needs.integration-tests.result == 'skipped') | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Install package | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install build twine | ||
- name: Build distribution | ||
run: | | ||
python -m build | ||
- name: Check wheels | ||
run: | | ||
cd dist || exit | ||
python -m pip install cads_mars_server*.whl || exit | ||
python -m twine check --strict * || exit | ||
python -c "import cads_mars_server" || exit | ||
cd .. | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: distribution | ||
path: dist | ||
|
||
upload-to-pypi: | ||
runs-on: ubuntu-latest | ||
needs: distribution | ||
if: | | ||
always() && false && | ||
needs.distribution.result == 'success' && | ||
github.event_name == 'push' && | ||
startsWith(github.ref, 'refs/tags') | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/cads-mars-server | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publish | ||
|
||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: distribution | ||
path: dist | ||
- uses: pypa/gh-action-pypi-publish@v1.9.0 | ||
with: | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
repos: | ||
- repo: https://github.com/cruft/cruft | ||
rev: 2.15.0 | ||
hooks: | ||
- id: cruft | ||
entry: cruft update -y | ||
additional_dependencies: [toml] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-json | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: check-added-large-files | ||
- id: check-merge-conflict | ||
- id: debug-statements | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
hooks: | ||
- id: black | ||
- id: mixed-line-ending | ||
- 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.5.2 | ||
hooks: | ||
- id: ruff | ||
args: [--fix, --show-fixes] | ||
- id: ruff-format | ||
- repo: https://github.com/executablebooks/mdformat | ||
rev: 0.7.16 | ||
rev: 0.7.17 | ||
hooks: | ||
- id: mdformat | ||
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks | ||
rev: v2.14.0 | ||
hooks: | ||
- id: pretty-format-yaml | ||
args: [--autofix, --preserve-quotes] | ||
- id: pretty-format-toml | ||
args: [--autofix] | ||
- repo: https://github.com/gitleaks/gitleaks | ||
rev: v8.18.4 | ||
hooks: | ||
- id: gitleaks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM continuumio/miniconda3 | ||
|
||
WORKDIR /src/cads-mars-server | ||
|
||
COPY environment.yml /src/cads-mars-server/ | ||
|
||
RUN conda install -c conda-forge gcc python=3.11 \ | ||
&& conda env update -n base -f environment.yml | ||
|
||
COPY . /src/cads-mars-server | ||
|
||
RUN pip install --no-deps -e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.