Skip to content

Commit 716a581

Browse files
feature/template maint 20250301 (#165)
### Added - add pre-commit hooks and linting CI workflow ### Changes - update gitignores with `locked-requirements.txt` and invenio-specifics - update versions in requirements.txt, pyproject.toml and pre-commit ### Fixed - fix project page link on documentation pages - use proper git tag for building containers in CI --------- Signed-off-by: Nicolas Drebenstedt <897972+cutoffthetop@users.noreply.github.com> Co-authored-by: RKI | Metadata Exchange <121876825+RKIMetadataExchange@users.noreply.github.com>
1 parent 8bdad06 commit 716a581

19 files changed

+163
-23
lines changed

.github/workflows/linting.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Linting
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags: ["**"]
7+
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
workflow_dispatch:
13+
14+
env:
15+
PDM_CHECK_UPDATE: False
16+
PIP_DISABLE_PIP_VERSION_CHECK: on
17+
PIP_NO_CLEAN: on
18+
PIP_NO_INPUT: on
19+
PIP_PREFER_BINARY: on
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
lint:
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 10
29+
steps:
30+
- name: Checkout repo
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 1
34+
35+
- name: Cache requirements
36+
uses: actions/cache@v4
37+
env:
38+
cache-name: cache-requirements
39+
with:
40+
path: ~/.cache/pip
41+
key: ${{ env.cache-name }}-${{ hashFiles('requirements.txt') }}
42+
restore-keys: |
43+
${{ env.cache-name }}-
44+
45+
- name: Setup python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: 3.11
49+
50+
- name: Install requirements
51+
run: make install
52+
53+
- name: Run linters
54+
run: make linter

.github/workflows/renovatebot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fetch-depth: 1
2323

2424
- name: Run renovatebot
25-
uses: renovatebot/github-action@v41.0.13
25+
uses: renovatebot/github-action@v41.0.14
2626
env:
2727
RENOVATE_GIT_PRIVATE_KEY: ${{ secrets.GPG_SIGNING_KEY }}
2828
RENOVATE_REPOSITORIES: "robert-koch-institut/mex-template"

.gitignore

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ downloads/
2222
eggs/
2323
lib/
2424
lib64/
25+
locked-requirements.txt
2526
MANIFEST
2627
parts/
2728
sdist/
@@ -49,7 +50,7 @@ coverage.xml
4950
test*.jpeg
5051
test*.png
5152
*.cover
52-
*.py,cover
53+
*,cover
5354
.hypothesis/
5455
.pytest_cache/
5556
cover/
@@ -84,7 +85,7 @@ ipython_config.py
8485
__pypackages__/
8586

8687
# Celery stuff
87-
celerybeat-schedule
88+
celerybeat-schedule.*
8889
celerybeat.pid
8990

9091
# Environments
@@ -126,10 +127,14 @@ dmypy.json
126127
assets/external/
127128
.web
128129

129-
# Default exports
130+
# MEx specific
131+
.aws/
132+
.invenio.private
130133
*.ndjson
131134
data/
132135
identity.csv
136+
logs/
137+
payload
133138
schema.json
134139
tmp*/
135140
work/

.pre-commit-config.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fail_fast: false
2+
default_language_version:
3+
python: python3.11
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: pretty-format-json
9+
name: json
10+
args: [--autofix, --indent=4, --no-ensure-ascii]
11+
exclude: cookiecutter.json
12+
- id: end-of-file-fixer
13+
name: eof
14+
- id: trailing-whitespace
15+
name: whitespaces
16+
- id: fix-byte-order-marker
17+
name: byte-order

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- add pre-commit hooks and linting CI workflow
13+
1214
### Changes
1315

16+
- update gitignores with `locked-requirements.txt` and invenio-specifics
17+
- update versions in requirements.txt, pyproject.toml and pre-commit
18+
1419
### Deprecated
1520

1621
### Removed
1722

1823
### Fixed
1924

25+
- fix project page link on documentation pages
26+
- use proper git tag for building containers in CI
27+
2028
### Security
2129

2230
## [0.4.0] - 2025-02-18

Makefile

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
.PHONY: all setup
2-
all: setup
3-
4-
LATEST = $(shell git describe --tags $(shell git rev-list --tags --max-count=1))
5-
PWD = $(shell pwd)
1+
.PHONY: all setup hooks install linter
2+
all: install linter
63

74
setup:
85
# install meta requirements system-wide
96
@ echo installing requirements; \
107
pip --disable-pip-version-check install --force-reinstall -r requirements.txt; \
8+
9+
hooks:
10+
# install pre-commit hooks when not in CI
11+
@ if [ -z "$$CI" ]; then \
12+
pre-commit install; \
13+
fi; \
14+
15+
install: setup hooks
16+
# install packages from lock file in local virtual environment
17+
@ echo installing package; \
18+
pdm install; \
19+
20+
linter:
21+
# run the linter hooks from pre-commit on all files
22+
@ echo linting all files; \
23+
pre-commit run --all-files; \

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Cookiecutter template for MEx python projects.
44

5+
[![cookiecutter](https://github.com/robert-koch-institut/mex-template/actions/workflows/cookiecutter.yml/badge.svg)](https://github.com/robert-koch-institut/mex-template)
6+
[![cve-scan](https://github.com/robert-koch-institut/mex-template/actions/workflows/cve-scan.yml/badge.svg)](https://github.com/robert-koch-institut/mex-template/actions/workflows/cve-scan.yml)
7+
[![linting](https://github.com/robert-koch-institut/mex-template/actions/workflows/linting.yml/badge.svg)](https://github.com/robert-koch-institut/mex-template/actions/workflows/linting.yml)
58
[![open-code](https://github.com/robert-koch-institut/mex-template/actions/workflows/open-code.yml/badge.svg)](https://gitlab.opencode.de/robert-koch-institut/mex/mex-template)
69

710
## Project

mex-{{ cookiecutter.project_name }}/.dockerignore

+8-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ coverage.xml
5050
test*.jpeg
5151
test*.png
5252
*.cover
53-
*.py,cover
53+
*,cover
5454
.hypothesis/
5555
.pytest_cache/
5656
cover/
@@ -84,7 +84,7 @@ ipython_config.py
8484
__pypackages__/
8585

8686
# Celery stuff
87-
celerybeat-schedule
87+
celerybeat-schedule.*
8888
celerybeat.pid
8989

9090
# Environments
@@ -122,10 +122,14 @@ dmypy.json
122122
assets/external/
123123
.web
124124

125-
# Default exports
125+
# MEx specific
126+
.aws/
127+
.invenio.private
126128
*.ndjson
127129
data/
128130
identity.csv
131+
logs/
132+
payload
129133
schema.json
130134
tmp*/
131135
work/
@@ -149,6 +153,7 @@ work/
149153
Makefile
150154
mex.bat
151155
*.lock
156+
Pipfile
152157
poetry.toml
153158
pytest.ini
154159
requirements.txt

mex-{{ cookiecutter.project_name }}/.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
uses: actions/checkout@v4
8989
with:
9090
fetch-depth: 1
91+
{% raw %}ref: ${{ needs.release.outputs.tag }}{% endraw %}
9192

9293
- name: Cache requirements
9394
uses: actions/cache@v4

mex-{{ cookiecutter.project_name }}/.github/workflows/renovatebot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fetch-depth: 1
2323

2424
- name: Run renovatebot
25-
uses: renovatebot/github-action@v41.0.13
25+
uses: renovatebot/github-action@v41.0.14
2626
env:
2727
RENOVATE_GIT_PRIVATE_KEY: {% raw %}${{ secrets.GPG_SIGNING_KEY }}{% endraw %}
2828
RENOVATE_REPOSITORIES: "robert-koch-institut/mex-{{ cookiecutter.project_name }}"

mex-{{ cookiecutter.project_name }}/.gitignore

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ downloads/
2222
eggs/
2323
lib/
2424
lib64/
25+
locked-requirements.txt
2526
MANIFEST
2627
parts/
2728
sdist/
@@ -49,7 +50,7 @@ coverage.xml
4950
test*.jpeg
5051
test*.png
5152
*.cover
52-
*.py,cover
53+
*,cover
5354
.hypothesis/
5455
.pytest_cache/
5556
cover/
@@ -84,7 +85,7 @@ ipython_config.py
8485
__pypackages__/
8586

8687
# Celery stuff
87-
celerybeat-schedule
88+
celerybeat-schedule.*
8889
celerybeat.pid
8990

9091
# Environments
@@ -126,10 +127,14 @@ dmypy.json
126127
assets/external/
127128
.web
128129

129-
# Default exports
130+
# MEx specific
131+
.aws/
132+
.invenio.private
130133
*.ndjson
131134
data/
132135
identity.csv
136+
logs/
137+
payload
133138
schema.json
134139
tmp*/
135140
work/

mex-{{ cookiecutter.project_name }}/.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ default_language_version:
33
python: python3.11
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.9.6
6+
rev: v0.9.10
77
hooks:
88
- id: ruff
99
args: [--fix, --exit-non-zero-on-fix]
@@ -25,7 +25,7 @@ repos:
2525
- id: fix-byte-order-marker
2626
name: byte-order
2727
- repo: https://github.com/pdm-project/pdm
28-
rev: 2.22.3
28+
rev: 2.22.4
2929
hooks:
3030
- id: pdm-lock-check
3131
name: pdm

mex-{{ cookiecutter.project_name }}/docs/layout.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{% block footer %}
55
<div class="footer">
6-
<a href="https://www.rki.de/DE/Content/Forsch/MEx/MEx_inhalt.html" rel="nofollow">
6+
<a href="https://www.rki.de/DE/Aktuelles/Publikationen/Forschungsdaten/MEx/metadata-exchange-plattform-mex-node.html" rel="nofollow">
77
MEx Project
88
</a> |
99
<a href="https://www.rki.de/DE/Service/Impressum/impressum_node.html" rel="nofollow">

mex-{{ cookiecutter.project_name }}/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies = []
1111
optional-dependencies.dev = [
1212
"ipdb>=0.13,<1",
1313
"mypy>=1,<2",
14-
"pytest-cov>=5,<6",
14+
"pytest-cov>=6,<7",
1515
"pytest-random-order>=1,<2",
1616
"pytest-xdist>=3,<4",
1717
"pytest>=8,<9",
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cruft==2.16.0
22
mex-release==0.3.0
3-
pdm==2.22.3
3+
pdm==2.22.4
44
pre-commit==4.1.0

mex.bat

+19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set target=%1
44

55
if "%target%"=="install" goto install
6+
if "%target%"=="test" goto test
67
echo invalid argument %target%
78
exit /b 1
89

@@ -12,3 +13,21 @@ exit /b 1
1213
echo installing requirements
1314
pip --disable-pip-version-check install --force-reinstall -r requirements.txt
1415
if %errorlevel% neq 0 exit /b %errorlevel%
16+
17+
@REM install pre-commit hooks when not in CI
18+
if "%CI%"=="" (
19+
pre-commit install
20+
if %errorlevel% neq 0 exit /b %errorlevel%
21+
)
22+
23+
@REM install packages from lock file in local virtual environment
24+
echo installing package
25+
pdm install
26+
exit /b %errorlevel%
27+
28+
29+
:test
30+
@REM run the linter hooks from pre-commit on all files
31+
echo linting all files
32+
pre-commit run --all-files
33+
exit /b %errorlevel%

pdm.lock

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ urls = { Repository = "https://github.com/robert-koch-institut/mex-template" }
99
requires-python = ">=3.11,<3.13"
1010
dependencies = []
1111
optional-dependencies.dev = []
12-

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cruft==2.16.0
22
mex-release==0.3.0
3-
pdm==2.22.3
3+
pdm==2.22.4
44
pre-commit==4.1.0

0 commit comments

Comments
 (0)