Skip to content

Commit

Permalink
upgrade template to v6.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
msaipraneeth committed Jan 12, 2024
1 parent e15af26 commit 91493f5
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 106 deletions.
8 changes: 4 additions & 4 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Changes here will be overwritten by Copier
_commit: v5.3.0
_commit: v6.0.1
_src_path: gh:eccenca/cmem-plugin-template
author_mail: info@eccenca.com
author_mail: cmempy-developer@eccenca.com
author_name: eccenca GmbH
github_page: ''
github_page: https://github.com/eccenca/cmem-plugin-uuid
project_description: Generate UUIDv1, 3, 4, 5, 6, 7 and 8 literals.
project_slug: uuid
pypi: false
pypi: true

4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
name: check

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" and "develop" branch
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
check:

runs-on: ubuntu-latest
concurrency: testing_environment

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

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

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

- name: Install and configure poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install dynamic versioning plugin
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
- name: mypy
run: |
task check:mypy
- name: ruff
run: |
task check:ruff
- name: pytest
env:
CMEM_BASE_URI: ${{ secrets.CMEM_BASE_URI }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
run: |
task check:pytest
- name: safety
run: |
task check:safety
- name: Publish Test Report in Action
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
report_paths: dist/junit-*.xml

- name: Publish Test and Coverage Report as PR comment
uses: xportation/junit-coverage-report@main
if: github.event_name == 'pull_request'
with:
junit-path: dist/junit-pytest.xml
coverage-path: dist/coverage.xml

91 changes: 91 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
default:
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
- build
- publish

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

mypy:
stage: test
script:
- task check:mypy
artifacts:
when: always
reports:
junit:
- 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

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

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

46 changes: 33 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@
repos:
- repo: local
hooks:
- id: pylint
name: pylint
entry: poetry run pylint
exclude: '^tests/.*$'
language: system
types: [python]
- repo: local
hooks:
- id: forbidden-files
name: forbidden files
entry: found copier update rejection files; review them and remove them
language: fail
files: "\\.rej$"

- id: ruff
name: check:ruff
entry: task check:ruff
language: python
types_or: [python, pyi]
pass_filenames: false

- id: poetry-check
name: poetry-check
description: run poetry check to validate config
entry: poetry check
language: python
pass_filenames: false
files: ^(.*/)?pyproject\.toml$

- id: poetry-lock
name: poetry-lock
description: run poetry lock to update lock file
entry: poetry lock
language: python
pass_filenames: false
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$

- id: poetry-install
name: poetry-install
description: >
run poetry install to install dependencies from the lock file
entry: poetry install
language: python
pass_filenames: false
stages: [post-checkout, post-merge]
always_run: true

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Create universally unique identifiers (UUIDs) versions 1, 3, 4, 5, 6, 7 and 8 in transformations.

[![eccenca Corporate Memory](https://img.shields.io/badge/eccenca-Corporate%20Memory-orange)](https://documentation.eccenca.com)
[![eccenca Corporate Memory](https://img.shields.io/badge/eccenca-Corporate%20Memory-orange)](https://documentation.eccenca.com) [![workflow](https://github.com/eccenca/cmem-plugin-uuid/actions/workflows/check.yml/badge.svg)](https://github.com/eccenca/cmem-plugin-uuid/actions) [![pypi version](https://img.shields.io/pypi/v/cmem-plugin-uuid)](https://pypi.org/project/uuid) [![license](https://img.shields.io/pypi/l/cmem-plugin-uuid)](https://pypi.org/project/cmem-plugin-uuid)

## UUID1

Expand Down
75 changes: 32 additions & 43 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ tasks:
cmds:
- poetry install

python:format:
desc: Format Python files
format:fix:
desc: Format Python files and fix obvious issues
<<: *preparation
cmds:
- poetry run black .
- poetry run ruff format tests {{.PACKAGE}}
- poetry run ruff check tests {{.PACKAGE}} --fix-only

format:fix-unsafe:
desc: Format Python files and fix 'unsafe' issues
<<: *preparation
cmds:
- poetry run ruff format tests {{.PACKAGE}}
- poetry run ruff check tests {{.PACKAGE}} --fix-only --unsafe-fixes

clean:
desc: Removes dist, *.pyc and some caches
Expand All @@ -83,18 +91,16 @@ tasks:

check:
desc: Run whole test suite incl. unit and integration tests
deps:
- check:linters
- check:pytest
cmds:
- task: check:linters
- task: check:pytest

check:linters:
desc: Run all linter and static code analysis tests
deps:
- check:bandit
- check:flake8
- check:mypy
- check:pylint
- check:safety
cmds:
- task: check:ruff
- task: check:mypy
- task: check:safety

check:pytest:
desc: Run unit and integration tests
Expand Down Expand Up @@ -125,59 +131,39 @@ tasks:
BADGE_COVERAGE: ./{{.DIST_DIR}}/badge-coverage.svg
BADGE_TESTS: ./{{.DIST_DIR}}/badge-tests.svg

check:pylint:
desc: Find code smells, errors and style issues
<<: *preparation
cmds:
- poetry run pylint --exit-zero {{.PACKAGE}}
- poetry run pylint {{.PACKAGE}} {{.XML_PARAMS}}
vars:
FORMAT: --output-format=pylint_junit.JUnitReporter
JUNIT_FILE: ./{{.DIST_DIR}}/junit-pylint.xml
XML_PARAMS: --output={{.JUNIT_FILE}} {{.FORMAT}}

check:mypy:
desc: Find type errors
desc: Complain about typing errors
<<: *preparation
cmds:
- poetry run mypy -p tests -p {{.PACKAGE}} --junit-xml {{.JUNIT_FILE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-mypy.xml

check:safety:
desc: Scan dependencies for vulnerabilities
desc: Complain about vulnerabilities in dependencies
<<: *preparation
cmds:
# ignore 51358 safety - dev dependency only
# ignore 59956 certifi - temporary solution for cmempy 23.1
- poetry run safety check -i 51358 -i 59956

check:bandit:
desc: Find common security issues
<<: *preparation
cmds:
- poetry run bandit --exit-zero -r {{.PACKAGE}}
- poetry run bandit --format xml -r {{.PACKAGE}} -o {{.JUNIT_FILE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-bandit.xml
# ignore 61489 pillow - dev dependency only
- poetry run safety check -i 51358 -i 61489

check:flake8:
desc: Enforce standard source code style guide
check:ruff:
desc: Complain about everything else
<<: *preparation
cmds:
- poetry run flake8 --exit-zero tests {{.PACKAGE}} {{.XML_PARAMS}}
- poetry run flake8 --show-source tests {{.PACKAGE}}
- poetry run ruff check --show-source tests {{.PACKAGE}}
- poetry run ruff check --exit-zero tests {{.PACKAGE}} {{.XML_PARAMS}}
- poetry run ruff format --check tests {{.PACKAGE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-flake8.xml
XML_PARAMS: --format junit-xml --output-file {{.JUNIT_FILE}}
JUNIT_FILE: ./{{.DIST_DIR}}/junit-ruff.xml
XML_PARAMS: --output-format junit --output-file {{.JUNIT_FILE}}

# }}}
# {{{ build and deploy tasks

deploy:
desc: Install plugin package in Corporate Memory
deps:
- clean
- build
cmds:
- cmemc admin workspace python install dist/*.tar.gz
Expand All @@ -186,6 +172,9 @@ tasks:
build:
desc: Build a tarball and a wheel package
<<: *preparation
deps:
- clean
- poetry:check
cmds:
- poetry build

Expand Down
1 change: 1 addition & 0 deletions cmem_plugin_uuid/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""uuid - main package"""
Loading

0 comments on commit 91493f5

Please sign in to comment.