Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use project template #17

Merged
merged 12 commits into from
Sep 27, 2024
Merged
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
3 changes: 3 additions & 0 deletions .copier-answers.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changes here will be overwritten by Copier
package_dir=cmem_plugin_base

11 changes: 11 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changes here will be overwritten by Copier
_commit: v7.0.0
_src_path: gh:eccenca/cmem-plugin-template
author_mail: [email protected]
author_name: eccenca GmbH
github_page: https://github.com/eccenca/cmem-plugin-base
project_description: Base classes for developing eccenca Corporate Memory plugins.
project_slug: cmem-plugin-base
project_type: generic
pypi: true

35 changes: 12 additions & 23 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ on:

jobs:
check:

runs-on: ubuntu-latest
concurrency: testing_environment

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Task
uses: arduino/setup-task@v1
uses: arduino/setup-task@v2

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: '3.11'

- name: Install and configure poetry
uses: snok/install-poetry@v1
Expand All @@ -35,32 +38,17 @@ jobs:
virtualenvs-in-project: true
installer-parallel: true

- name: Install poetry-dynamic-versioning plugin
- name: Install dynamic versioning plugin
run: |
poetry self add "poetry-dynamic-versioning[plugin]"

- name: Load cached venv if cache exists
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: bandit
run: |
task check:bandit

- name: flake8
run: |
task check:flake8

- name: mypy
run: |
task check:mypy

- name: pylint
- name: ruff
run: |
task check:pylint
task check:ruff

- name: pytest
env:
Expand All @@ -74,7 +62,7 @@ jobs:
task check:safety

- name: Publish Test Report in Action
uses: mikepenz/action-junit-report@v3
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
report_paths: dist/junit-*.xml
Expand All @@ -85,3 +73,4 @@ jobs:
with:
junit-path: dist/junit-pytest.xml
coverage-path: dist/coverage.xml

20 changes: 8 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ permissions:

jobs:
publish:

runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Task
uses: arduino/setup-task@v1
uses: arduino/setup-task@v2

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: '3.11'

- name: Install and configure poetry
uses: snok/install-poetry@v1
Expand All @@ -33,20 +35,14 @@ jobs:
virtualenvs-in-project: true
installer-parallel: true

- name: Install poetry-dynamic-versioning plugin
- name: Install dynamic versioning plugin
run: |
poetry self add "poetry-dynamic-versioning[plugin]"

- name: Load cached venv if cache exists
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Publish Package
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi "$PYPI_TOKEN"
poetry publish --build

90 changes: 2 additions & 88 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
# https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -138,89 +138,7 @@ dmypy.json
# Cython debug symbols
cython_debug/


### JetBrain ignores
# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser


### project build plan specific ignores
# project build plan specific ignores
version.py
co
*.xml
Expand All @@ -229,7 +147,3 @@ co
artifacts
.DS_Store
.task

.scannerwork


89 changes: 67 additions & 22 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,91 @@
---
default:
image: docker-registry.eccenca.com/eccenca-python:v3.7.0
image: docker-registry.eccenca.com/eccenca-python:v3.11.4
# all jobs can be interrupted in case a new commit is pushed
interruptible: true
before_script:
# make sure poetry creates virtual environment as .venv
- poetry config virtualenvs.in-project true
cache:
# cache the virtual environment based on the poetry lock file
key:
files:
- poetry.lock
paths:
- .venv

stages:
- test
- sonarqube
- build
- deploy
- publish

ruff:
stage: test
script:
- task check:ruff
artifacts:
when: always
reports:
junit:
- dist/junit-ruff.xml

check:
mypy:
stage: test
script:
- task check
- task check:mypy
artifacts:
when: always
reports:
cobertura:
- ./dist/coverage.xml
junit:
- ./dist/junit-bandit.xml
- ./dist/junit-flake8.xml
- ./dist/junit-mypy.xml
- ./dist/junit-pylint.xml
- ./dist/junit-pytest.xml
- dist/junit-mypy.xml

pytest:
stage: test
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
script:
- task check:pytest
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: dist/coverage.xml
junit:
- dist/junit-pytest.xml
paths:
- ./dist/badge-coverage.svg
- ./dist/badge-tests.svg
- ./dist/coverage
- ./dist/coverage.xml
- ./dist/junit-*.xml
- dist/badge-coverage.svg
- dist/badge-tests.svg
- dist/coverage
- dist/coverage.xml

safety:
stage: test
script:
- task check:safety

build:
stage: build
needs:
- mypy
- pytest
- safety
script:
- task build
artifacts:
when: always
paths:
- ./dist/*.tar.gz
- ./dist/*.whl
- dist/*.tar.gz
- dist/*.whl

deploy:
stage: deploy
pypi:
# publishing only available on a tag
stage: publish
needs:
- ruff
- build
allow_failure: true
when: manual
script:
- ls
- poetry config pypi-token.pypi $PYPI_TOKEN
- poetry publish

Loading