Skip to content

Commit 9f7839d

Browse files
robertiseleseebimsaipraneeth
authored
Use project template (#17)
* integrate copier project template * apply safe ruff fixes * apply unsafe ruff fixes * fix some easy issues * fix more issues * Fix mypy issues * Fixed lots of Ruff issues (but not all yet) * Fixed more mypy issues * Ignore some ruff issues: - Plugin methods usually don't use all arguments, which is completely fine and expected. - Magic values are fine to be used in tests IMHO - Specific assert statements should also be fine. * fix ruff and mypy issues * not fetch token if grant type is prefetched_token * fix mypy warning --------- Co-authored-by: Sebastian Tramp <[email protected]> Co-authored-by: saipraneeth <[email protected]>
1 parent f9235dc commit 9f7839d

Some content is hidden

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

47 files changed

+1023
-1394
lines changed

.copier-answers.env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changes here will be overwritten by Copier
2+
package_dir=cmem_plugin_base
3+

.copier-answers.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changes here will be overwritten by Copier
2+
_commit: v7.0.0
3+
_src_path: gh:eccenca/cmem-plugin-template
4+
author_mail: [email protected]
5+
author_name: eccenca GmbH
6+
github_page: https://github.com/eccenca/cmem-plugin-base
7+
project_description: Base classes for developing eccenca Corporate Memory plugins.
8+
project_slug: cmem-plugin-base
9+
project_type: generic
10+
pypi: true
11+

.github/workflows/check.yml

+12-23
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ on:
1414

1515
jobs:
1616
check:
17+
1718
runs-on: ubuntu-latest
19+
concurrency: testing_environment
20+
1821
steps:
1922
- name: Check out repository
20-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2124

2225
- name: Install Task
23-
uses: arduino/setup-task@v1
26+
uses: arduino/setup-task@v2
2427

2528
- name: Set up python
2629
id: setup-python
27-
uses: actions/setup-python@v4
30+
uses: actions/setup-python@v5
2831
with:
29-
python-version: 3.11
32+
python-version: '3.11'
3033

3134
- name: Install and configure poetry
3235
uses: snok/install-poetry@v1
@@ -35,32 +38,17 @@ jobs:
3538
virtualenvs-in-project: true
3639
installer-parallel: true
3740

38-
- name: Install poetry-dynamic-versioning plugin
41+
- name: Install dynamic versioning plugin
3942
run: |
4043
poetry self add "poetry-dynamic-versioning[plugin]"
4144
42-
- name: Load cached venv if cache exists
43-
id: cached-poetry-dependencies
44-
uses: actions/cache@v3
45-
with:
46-
path: .venv
47-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
48-
49-
- name: bandit
50-
run: |
51-
task check:bandit
52-
53-
- name: flake8
54-
run: |
55-
task check:flake8
56-
5745
- name: mypy
5846
run: |
5947
task check:mypy
6048
61-
- name: pylint
49+
- name: ruff
6250
run: |
63-
task check:pylint
51+
task check:ruff
6452
6553
- name: pytest
6654
env:
@@ -74,7 +62,7 @@ jobs:
7462
task check:safety
7563
7664
- name: Publish Test Report in Action
77-
uses: mikepenz/action-junit-report@v3
65+
uses: mikepenz/action-junit-report@v4
7866
if: always() # always run even if the previous step fails
7967
with:
8068
report_paths: dist/junit-*.xml
@@ -85,3 +73,4 @@ jobs:
8573
with:
8674
junit-path: dist/junit-pytest.xml
8775
coverage-path: dist/coverage.xml
76+

.github/workflows/publish.yml

+8-12
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ permissions:
1212

1313
jobs:
1414
publish:
15+
1516
runs-on: ubuntu-latest
17+
1618
steps:
1719
- name: Check out repository
18-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
1921

2022
- name: Install Task
21-
uses: arduino/setup-task@v1
23+
uses: arduino/setup-task@v2
2224

2325
- name: Set up python
2426
id: setup-python
25-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2628
with:
27-
python-version: 3.11
29+
python-version: '3.11'
2830

2931
- name: Install and configure poetry
3032
uses: snok/install-poetry@v1
@@ -33,20 +35,14 @@ jobs:
3335
virtualenvs-in-project: true
3436
installer-parallel: true
3537

36-
- name: Install poetry-dynamic-versioning plugin
38+
- name: Install dynamic versioning plugin
3739
run: |
3840
poetry self add "poetry-dynamic-versioning[plugin]"
3941
40-
- name: Load cached venv if cache exists
41-
id: cached-poetry-dependencies
42-
uses: actions/cache@v3
43-
with:
44-
path: .venv
45-
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
46-
4742
- name: Publish Package
4843
env:
4944
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
5045
run: |
5146
poetry config pypi-token.pypi "$PYPI_TOKEN"
5247
poetry publish --build
48+

.gitignore

+2-88
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
1+
# https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
22
# Byte-compiled / optimized / DLL files
33
__pycache__/
44
*.py[cod]
@@ -138,89 +138,7 @@ dmypy.json
138138
# Cython debug symbols
139139
cython_debug/
140140

141-
142-
### JetBrain ignores
143-
# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
144-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
145-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
146-
147-
# User-specific stuff
148-
.idea/**/workspace.xml
149-
.idea/**/tasks.xml
150-
.idea/**/usage.statistics.xml
151-
.idea/**/dictionaries
152-
.idea/**/shelf
153-
154-
# AWS User-specific
155-
.idea/**/aws.xml
156-
157-
# Generated files
158-
.idea/**/contentModel.xml
159-
160-
# Sensitive or high-churn files
161-
.idea/**/dataSources/
162-
.idea/**/dataSources.ids
163-
.idea/**/dataSources.local.xml
164-
.idea/**/sqlDataSources.xml
165-
.idea/**/dynamic.xml
166-
.idea/**/uiDesigner.xml
167-
.idea/**/dbnavigator.xml
168-
169-
# Gradle
170-
.idea/**/gradle.xml
171-
.idea/**/libraries
172-
173-
# Gradle and Maven with auto-import
174-
# When using Gradle or Maven with auto-import, you should exclude module files,
175-
# since they will be recreated, and may cause churn. Uncomment if using
176-
# auto-import.
177-
# .idea/artifacts
178-
# .idea/compiler.xml
179-
# .idea/jarRepositories.xml
180-
# .idea/modules.xml
181-
# .idea/*.iml
182-
# .idea/modules
183-
# *.iml
184-
# *.ipr
185-
186-
# CMake
187-
cmake-build-*/
188-
189-
# Mongo Explorer plugin
190-
.idea/**/mongoSettings.xml
191-
192-
# File-based project format
193-
*.iws
194-
195-
# IntelliJ
196-
out/
197-
198-
# mpeltonen/sbt-idea plugin
199-
.idea_modules/
200-
201-
# JIRA plugin
202-
atlassian-ide-plugin.xml
203-
204-
# Cursive Clojure plugin
205-
.idea/replstate.xml
206-
207-
# SonarLint plugin
208-
.idea/sonarlint/
209-
210-
# Crashlytics plugin (for Android Studio and IntelliJ)
211-
com_crashlytics_export_strings.xml
212-
crashlytics.properties
213-
crashlytics-build.properties
214-
fabric.properties
215-
216-
# Editor-based Rest Client
217-
.idea/httpRequests
218-
219-
# Android studio 3.1+ serialized cache file
220-
.idea/caches/build_file_checksums.ser
221-
222-
223-
### project build plan specific ignores
141+
# project build plan specific ignores
224142
version.py
225143
co
226144
*.xml
@@ -229,7 +147,3 @@ co
229147
artifacts
230148
.DS_Store
231149
.task
232-
233-
.scannerwork
234-
235-

.gitlab-ci.yml

+67-22
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,91 @@
11
---
22
default:
3-
image: docker-registry.eccenca.com/eccenca-python:v3.7.0
3+
image: docker-registry.eccenca.com/eccenca-python:v3.11.4
4+
# all jobs can be interrupted in case a new commit is pushed
5+
interruptible: true
6+
before_script:
7+
# make sure poetry creates virtual environment as .venv
8+
- poetry config virtualenvs.in-project true
9+
cache:
10+
# cache the virtual environment based on the poetry lock file
11+
key:
12+
files:
13+
- poetry.lock
14+
paths:
15+
- .venv
416

517
stages:
618
- test
7-
- sonarqube
819
- build
9-
- deploy
20+
- publish
21+
22+
ruff:
23+
stage: test
24+
script:
25+
- task check:ruff
26+
artifacts:
27+
when: always
28+
reports:
29+
junit:
30+
- dist/junit-ruff.xml
1031

11-
check:
32+
mypy:
1233
stage: test
1334
script:
14-
- task check
35+
- task check:mypy
1536
artifacts:
1637
when: always
1738
reports:
18-
cobertura:
19-
- ./dist/coverage.xml
2039
junit:
21-
- ./dist/junit-bandit.xml
22-
- ./dist/junit-flake8.xml
23-
- ./dist/junit-mypy.xml
24-
- ./dist/junit-pylint.xml
25-
- ./dist/junit-pytest.xml
40+
- dist/junit-mypy.xml
41+
42+
pytest:
43+
stage: test
44+
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
45+
script:
46+
- task check:pytest
47+
artifacts:
48+
when: always
49+
reports:
50+
coverage_report:
51+
coverage_format: cobertura
52+
path: dist/coverage.xml
53+
junit:
54+
- dist/junit-pytest.xml
2655
paths:
27-
- ./dist/badge-coverage.svg
28-
- ./dist/badge-tests.svg
29-
- ./dist/coverage
30-
- ./dist/coverage.xml
31-
- ./dist/junit-*.xml
56+
- dist/badge-coverage.svg
57+
- dist/badge-tests.svg
58+
- dist/coverage
59+
- dist/coverage.xml
60+
61+
safety:
62+
stage: test
63+
script:
64+
- task check:safety
3265

3366
build:
3467
stage: build
68+
needs:
69+
- mypy
70+
- pytest
71+
- safety
3572
script:
3673
- task build
3774
artifacts:
3875
when: always
3976
paths:
40-
- ./dist/*.tar.gz
41-
- ./dist/*.whl
77+
- dist/*.tar.gz
78+
- dist/*.whl
4279

43-
deploy:
44-
stage: deploy
80+
pypi:
81+
# publishing only available on a tag
82+
stage: publish
83+
needs:
84+
- ruff
85+
- build
86+
allow_failure: true
87+
when: manual
4588
script:
46-
- ls
89+
- poetry config pypi-token.pypi $PYPI_TOKEN
90+
- poetry publish
91+

0 commit comments

Comments
 (0)