diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000..1c1d2e8 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,7 @@ +Copyright DB Netz AG and contributors +SPDX-License-Identifier: CC0-1.0 + +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true)$ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..de62da1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# Copyright DB Netz AG and contributors +# SPDX-License-Identifier: CC0-1.0 + +* text=auto + +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf + +*.{sh,py} text eol=lf + +.git_archival.txt export-subst diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml new file mode 100644 index 0000000..86237f4 --- /dev/null +++ b/.github/workflows/build-test-publish.yml @@ -0,0 +1,77 @@ +# Copyright DB Netz AG and contributors +# SPDX-License-Identifier: CC0-1.0 + +name: Build + +on: + push: + branches: ["*"] + pull_request: [master] + tags: ["v*.*.*"] + +jobs: + test: + name: Test with Python ${{matrix.python_version}} on ${{matrix.os}} + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python_version: + - "3.0" + - "3.10" + - "3.11" + include: + - os: windows-latest + python_version: "3.0" + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{matrix.python_version}} + uses: actions/setup-python@v2 + with: + python-version: ${{matrix.python_version}} + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{runner.os}}-pip-${{hashFiles('pyproject.toml')}} + restore-keys: | + ${{runner.os}}-pip- + ${{runner.os}}- + - name: Upgrade Pip + run: |- + python -m pip install -U pip + - name: Install test dependencies + run: |- + python -m pip install '.[test]' + - name: Run unit tests + run: |- + python -m pytest --cov-report=term --cov=capella_git_hooks --rootdir=. + + publish: + name: Publish artifacts + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.0" + - name: Install dependencies + run: |- + python -m pip install -U pip + python -m pip install build twine + - name: Build packages + run: |- + python -m build + - name: Verify packages + run: |- + python -m twine check dist/* + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: 'dist/*' + - name: Publish to PyPI (release only) + if: startsWith(github.ref, 'refs/tags/v') + run: python -m twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} --non-interactive dist/* diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..b222d8b --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,39 @@ +# Copyright DB Netz AG and contributors +# SPDX-License-Identifier: CC0-1.0 + +name: Docs + +on: + push: + branches: ["master"] + +jobs: + sphinx: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: "3.0" + - name: Upgrade pip + run: | + python -m pip install -U pip + - name: Install dependencies + run: | + python -m pip install '.[docs]' + - name: Auto-generate APIDOC sources + run: |- + sphinx-apidoc --output-dir docs/source/code --force . + - name: Create docs + run: | + make -C docs html + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + force_orphan: true + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/build/html diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..bdd8e61 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +# Copyright DB Netz AG and contributors +# SPDX-License-Identifier: CC0-1.0 + +name: Lint + +on: + push: + branches: ["*"] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.0" + - name: Upgrade pip + run: |- + python -m pip install -U pip + - name: Install pre-commit + run: |- + python -m pip install pre-commit types-docutils + - name: Run Pre-Commit + run: |- + pre-commit run --all-files + pylint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.0" + - name: Upgrade pip + run: |- + python -m pip install -U pip + - name: Install pylint + run: |- + python -m pip install pylint + - name: Run pylint + run: |- + pylint -dfixme capella_git_hooks || exit $(($? & ~24)) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..975287e --- /dev/null +++ b/.gitignore @@ -0,0 +1,158 @@ +# Copyright DB Netz AG and contributors +# SPDX-License-Identifier: CC0-1.0 + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +docs/source/code/ +docs/source/_build + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..caf8bff --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,103 @@ +# Copyright DB Netz AG and contributors +# SPDX-License-Identifier: CC0-1.0 + +default_install_hook_types: [commit-msg, pre-commit] +default_stages: [commit, merge-commit] +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-builtin-literals + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-toml + - id: check-vcs-permalinks + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: destroyed-symlinks + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: trailing-whitespace + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.9.1 + hooks: + - id: black + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.5 + hooks: + - id: docformatter + additional_dependencies: + - docformatter[tomli] + - repo: https://github.com/PyCQA/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle + exclude: '^tests/' + additional_dependencies: + - pydocstyle[toml] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.5.1 + hooks: + - id: mypy + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.4.2 + hooks: + - id: insert-license + name: Insert license headers (shell-style comments) + files: '(?:^|/)(?:.*\.(?:py|sh|toml|ya?ml)|Dockerfile|Makefile)$' + exclude: '(?:^|/)\..+|^docs/Makefile$' + args: + - --detect-license-in-X-top-lines=15 + - --license-filepath + - LICENSES/.license_header.txt + - --comment-style + - '#' + - id: insert-license + name: Insert license headers (XML-style comments) + files: '\.(?:html|md|xml)$' + exclude: '(?:^|/)\..+' + args: + - --detect-license-in-X-top-lines=15 + - --license-filepath + - LICENSES/.license_header.txt + - --comment-style + - '' + - id: insert-license + name: Insert license headers (C-style comments) + files: '\.(?:css|js|ts)$' + exclude: '(?:^|/)\..+' + args: + - --detect-license-in-X-top-lines=15 + - --license-filepath + - LICENSES/.license_header.txt + - --comment-style + - '/*| *| */' + - id: insert-license + name: Insert license headers (reST comments) + files: '\.rst$' + exclude: '(?:^|/)\..+' + args: + - --detect-license-in-X-top-lines=15 + - --license-filepath + - LICENSES/.license_header.txt + - --comment-style + - '..| |' + - repo: https://github.com/fsfe/reuse-tool + rev: v2.1.0 + hooks: + - id: reuse + - repo: https://github.com/qoomon/git-conventional-commits + rev: v2.6.5 + hooks: + - id: conventional-commits