Skip to content
Open
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 .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source =
probtest.py
util/
omit =
tests/*
test/*
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
env:
TZ: Europe/Zurich
run: |
conda run --name dev_env pytest -v -s --cov --cov-report=term tests/
conda run --name dev_env pytest -v -s --cov --cov-report=term test/
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg




.idea*
.vscode/*
!.vscode/settings.json
Expand All @@ -7,9 +37,83 @@
*.png
*.log
*.nc

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetest.xml
coverage.xml

*.cover
.hypothesis/
.pytest_cache/
junit*

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# IDE project settings
.editorconfig
.spyproject
.idea/

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# output from unittest
test_stats.csv
test_stats_csv.csv
Expand Down
122 changes: 122 additions & 0 deletions .mch-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Default configuration used by CI/CD.
# You can run locally 'mchbuild build' to create the images,
# 'mchbuild test' to run the tests using the images. The 'deploy' steps
# can be run separately.
default:
- build:
- getVersion:
gitCalculateVersion:
- imageTester:
containerBuildImage:
fullImageName: ${var.image}-tester
target: tester
extraArgs:
- --build-arg
- VERSION=${var.version}
- imageRunner:
containerBuildImage:
fullImageName: ${var.image}
target: runner
extraArgs:
- --build-arg
- VERSION=${var.version}
pullAlways: false
- docs:
- script: mkdir -p doc/_build
- pythonDocs:
fullImageName: ${var.image}-tester
packageManager: ''
pullAlways: false
- test:
- getVersion:
gitCalculateVersion:
- unit:
- script: mkdir -p test_reports
- pythonTest:
fullImageName: ${var.image}-tester
packageManager: ''
pullAlways: false
- pythonCoverage:
fullImageName: ${var.image}-tester
packageManager: ''
pullAlways: false
- lint:
- script: mkdir -p test_reports
- pythonLint:
# fullImageName: ${var.image}-tester
# packageManager: ''
# pullAlways: false
- pythonTypeChecker:
# fullImageName: ${var.image}-tester
# packageManager: ''
# pullAlways: false
- verify:
- scan:
openshiftTrivy:
- deploy:
- addNextTag:
gitAddNextTag:
- addTag:
gitAddTag:
- docs:
openshiftPublishDocs:
docSrc: doc/_build/
docType: python
- image:
containerPublishImage:
removeLocalImage: false
- cp:
openshiftDeploy:
restartDeployment: false
- cpDelete:
openshiftDelete:
- pypi:
pythonPublishPackage:
setPackageVersion: true
pythonImageName: '3.11'
pullAlways: false
- clean:
- getVersion:
gitCalculateVersion:
- images:
script: |
if test -n "${var.version}"; then
podman image rm -f $(podman image ls -q \
-f "label=ch.meteoswiss.project=${var.project}-${var.version}") || :
fi

# Alternative configuration to install and test the service locally using
# the local Python installation. Besides 'mchbuild local.build' and
# 'mchbuild local.test' it is possible to run the job using
# 'mchbuild local.run'.
local:
- build:
- install:
pythonInstall:
- docs:
pythonDocs:
- format:
pythonFormat:
inPlace: true
commands: poetry run black probtest
- test:
- unit:
- script: mkdir -p test_reports
- pythonTest:
- pythonCoverage:
- lint:
- script: mkdir -p test_reports
- pythonLint:
# - pythonTypeChecker:
- run:
- main:
- pythonRun:
commands: probtest --help

variables:
project: probtest
solution: probtest
ocpHostNameForEnv:
devt: api.cpnonprod.meteoswiss.ch:6443
depl: api.cpnonprod.meteoswiss.ch:6443
prod: api.cp.meteoswiss.ch:6443
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ repos:
entry: end-of-file-fixer
language: system
types: [text]
exclude: tests/data/
exclude: test/data/
- id: trailing-whitespace
name: trim trailing whitespace
description: trims trailing whitespace.
entry: trailing-whitespace-fixer
language: system
types: [text]
exclude: tests/data/
exclude: test/data/
- repo: local
hooks:
- id: forbidden-files-copier-rej
Expand Down Expand Up @@ -83,7 +83,7 @@ repos:
description: Check for spelling errors
language: system
entry: codespell
exclude: tests/data/
exclude: test/data/
args: ['-L astroid,fof']
- repo: local
hooks:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM dockerhub.apps.cp.meteoswiss.ch/mch/python/builder AS builder
ARG VERSION
LABEL ch.meteoswiss.project=probtest-${VERSION}

COPY poetry.lock pyproject.toml /src/app-root/

WORKDIR /src/app-root

RUN poetry export -o requirements.txt --without-hashes \
&& poetry export --with dev -o requirements_dev.txt --without-hashes


FROM dockerhub.apps.cp.meteoswiss.ch/mch/python-3.11:latest-slim AS base
ARG VERSION
LABEL ch.meteoswiss.project=probtest-${VERSION}

COPY --from=builder /src/app-root/requirements.txt /src/app-root/requirements.txt

WORKDIR /src/app-root

RUN pip install -r requirements.txt --no-cache-dir --no-deps --root-user-action=ignore

COPY probtest /src/app-root/probtest

FROM base AS tester
ARG VERSION
LABEL ch.meteoswiss.project=probtest-${VERSION}

COPY --from=builder /src/app-root/requirements_dev.txt /src/app-root/requirements_dev.txt
RUN pip install -r /src/app-root/requirements_dev.txt --no-cache-dir --no-deps --root-user-action=ignore

COPY pyproject.toml /src/app-root/
COPY test /src/app-root/test

FROM base AS runner
ARG VERSION
LABEL ch.meteoswiss.project=probtest-${VERSION}

ENV VERSION=$VERSION

# For running outside of OpenShift, we want to make sure that the container is run without root privileges
# uid 1001 is defined in the base-container-images for this purpose
USER 1001

ENTRYPOINT ["python", "-m", "probtest"]
CMD []
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=======
History
=======

1.0.0 (2024-06-13)
------------------

* First release
Loading