Skip to content

Commit c6ae574

Browse files
MCH Python template (#22)
1 parent 5b3acae commit c6ae574

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3403
-1807
lines changed

.copier-answers.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.gitignore

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,108 @@
1-
# Byte-compiled
1+
# Byte-compiled / optimized / DLL files
22
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
38

49
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
524
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
junit*
50+
51+
# mchbuild reports
52+
test_reports/
53+
security_reports/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
doc/_build/
72+
73+
# PyBuilder
74+
target/
75+
76+
# Jupyter Notebook
77+
.ipynb_checkpoints
78+
79+
# celery beat schedule file
80+
celerybeat-schedule
81+
82+
# SageMath parsed files
83+
*.sage.py
84+
85+
# dotenv
86+
.env
87+
88+
# virtualenv
89+
.venv
90+
venv/
91+
ENV/
92+
93+
# IDE project settings
94+
.editorconfig
95+
.spyproject
96+
.idea/
97+
.vscode/*
98+
!.vscode/settings.json
99+
!.vscode/launch.json
100+
101+
# Rope project settings
102+
.ropeproject
103+
104+
# mkdocs documentation
105+
/site
106+
107+
# mypy
108+
.mypy_cache/

.mambarc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
channels:
2+
- conda-forge
3+
channel_alias: https://service.meteoswiss.ch/nexus/repository/conda

.mch-ci.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Default configuration used by CI/CD.
2+
# You can run locally 'mchbuild build' to create the images,
3+
# 'mchbuild test' to run the tests using the images. The 'deploy' steps
4+
# can be run separately.
5+
default:
6+
- build:
7+
- getVersion:
8+
gitCalculateVersion:
9+
- imageTester:
10+
containerBuildImage:
11+
fullImageName: ${var.image}-tester
12+
target: tester
13+
extraArgs:
14+
- --build-arg
15+
- VERSION=${var.version}
16+
- imageRunner:
17+
containerBuildImage:
18+
fullImageName: ${var.image}
19+
target: runner
20+
extraArgs:
21+
- --build-arg
22+
- VERSION=${var.version}
23+
pullAlways: false
24+
- docs:
25+
- script: mkdir -p doc/_build
26+
- pythonDocs:
27+
fullImageName: ${var.image}-tester
28+
packageManager: ''
29+
pullAlways: false
30+
- test:
31+
- getVersion:
32+
gitCalculateVersion:
33+
- unit:
34+
- script: mkdir -p test_reports
35+
- pythonTest:
36+
fullImageName: ${var.image}-tester
37+
packageManager: ''
38+
pullAlways: false
39+
- pythonCoverage:
40+
fullImageName: ${var.image}-tester
41+
packageManager: ''
42+
pullAlways: false
43+
- lint:
44+
- script: mkdir -p test_reports
45+
- pythonLint:
46+
fullImageName: ${var.image}-tester
47+
packageManager: ''
48+
pullAlways: false
49+
- pythonTypeChecker:
50+
fullImageName: ${var.image}-tester
51+
packageManager: ''
52+
pullAlways: false
53+
- verify:
54+
- imageSecurityScan:
55+
- securityReport:
56+
format: [ 'html', 'sbom', 'table', 'print']
57+
severity: [ 'CRITICAL', 'HIGH' ]
58+
removeLocalImage: false
59+
pullAlways: false
60+
qualityGate:
61+
threshold: 20
62+
criticalFactor: 5
63+
highFactor: 1
64+
- publishSbom:
65+
- securityPublishSbom:
66+
- deploy:
67+
- addNextTag:
68+
gitAddNextTag:
69+
- addTag:
70+
gitAddTag:
71+
- docs:
72+
openshiftPublishDocs:
73+
docSrc: doc/_build/
74+
docType: python
75+
- image:
76+
containerPublishImage:
77+
removeLocalImage: false
78+
- cpDelete:
79+
openshiftDelete:
80+
- cp:
81+
openshiftDeploy:
82+
restartDeployment: false
83+
- clean:
84+
- getVersion:
85+
gitCalculateVersion:
86+
- images:
87+
script: |
88+
if test -n "${var.version}"; then
89+
podman image rm -f $(podman image ls -q \
90+
-f "label=ch.meteoswiss.project=${var.project}-${var.version}") || :
91+
fi
92+
93+
# Alternative configuration to install and test the service locally using
94+
# the local Python installation. Besides 'mchbuild local.build' and
95+
# 'mchbuild local.test' it is possible to run the job using
96+
# 'mchbuild local.run'.
97+
local:
98+
- build:
99+
- install:
100+
pythonInstall:
101+
- docs:
102+
pythonDocs:
103+
- format:
104+
pythonFormat:
105+
inPlace: true
106+
- test:
107+
- unit:
108+
- script: mkdir -p test_reports
109+
- pythonTest:
110+
- pythonCoverage:
111+
- lint:
112+
- script: mkdir -p test_reports
113+
- pythonLint:
114+
- pythonTypeChecker:
115+
- run:
116+
- main:
117+
- pythonRun:
118+
commands: realtime-pollen-calibration update_phenology --help
119+
120+
# Configuration to install and test the python project
121+
# on top of a conda environment using micromamba to set it up
122+
conda:
123+
- build:
124+
- getVersion:
125+
gitCalculateVersion:
126+
- install:
127+
pythonRun:
128+
packageManager: micromamba
129+
commands: |
130+
micromamba create -y -n ${var.project}-${var.version} --file conda_deps.yml --rc-file .mambarc &&
131+
micromamba run -n ${var.project}-${var.version} poetry install &&
132+
echo "Activate your environment with 'micromamba activate ${var.project}-${var.version}'"
133+
- test:
134+
- getVersion:
135+
gitCalculateVersion:
136+
- unit:
137+
pythonRun:
138+
packageManager: micromamba
139+
commands: |
140+
micromamba run -n ${var.project}-${var.version} bash -c "mchbuild local.test.unit"
141+
- lint:
142+
pythonRun:
143+
packageManager: micromamba
144+
commands: |
145+
micromamba run -n ${var.project}-${var.version} bash -c "mchbuild local.test.lint"
146+
- run:
147+
- getVersion:
148+
gitCalculateVersion:
149+
- main:
150+
- pythonRun:
151+
packageManager: micromamba
152+
commands: |
153+
micromamba run -n ${var.project}-${var.version} bash -c "mchbuild local.run.main"
154+
- clean:
155+
- getVersion:
156+
gitCalculateVersion:
157+
- deleteCondaEnv:
158+
pythonRun:
159+
packageManager: micromamba
160+
commands: |
161+
micromamba env remove -y -n ${var.project}-${var.version}
162+
163+
variables:
164+
project: realtime-pollen-calibration
165+
solution: icon

0 commit comments

Comments
 (0)