Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:tanbro/jinjyaml into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tanbro committed Jan 21, 2025
2 parents 09f9605 + b9a1f34 commit 3a8171b
Show file tree
Hide file tree
Showing 30 changed files with 894 additions and 619 deletions.
5 changes: 2 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[run]
branch = True
source = src
relative_files = True
omit = tests/*
src/**/_version.py
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Tab indentation (no size specified)
[*.bat]
end_of_line = crlf
indent_style = tab
211 changes: 106 additions & 105 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,105 +1,106 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [master]
tags: ["*"]
pull_request:
branches: [master]

jobs:
check-pep440:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Check PEP-440 style version
id: get-version
run: |
PEP440_VERSION=""
VERSION_PREFIX="v"
BRANCH_OR_TAG="$(echo ${{ github.event.ref }} | cut -d / -f 3)"
if [[ "${BRANCH_OR_TAG}" =~ ^v?(([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*(\.?(a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?)$ ]]
then
PEP440_VERSION="${BRANCH_OR_TAG#$VERSION_PREFIX}"
fi
echo "version=${PEP440_VERSION}" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install project and tools dependencies
run: |
pip install -e . coverage
- name: Test with coverage
run: |
coverage run -m unittest -fcv
coverage report -m
coverage xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
runs-on: ubuntu-latest
needs: [test, check-pep440]
if: needs.check-pep440.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
cache: "pip"
- name: Install builder
run: pip install build
- name: Build Python distribution
run: pyproject-build
- name: Upload dist to artifact
uses: actions/upload-artifact@v3
with:
name: jinjyaml-dist-${{ needs.check-pep440.outputs.version }}
path: dist
if-no-files-found: error
retention-days: 1

publish:
runs-on: ubuntu-latest
needs: [check-pep440, build]
if: needs.check-pep440.outputs.version != ''
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download dist from artifact
uses: actions/download-artifact@v3
with:
name: jinjyaml-dist-${{needs.check-pep440.outputs.version}}
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [master]
tags: ["*"]
pull_request:
branches: [master]

jobs:
check-pep440:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Check PEP-440 style version
id: get-version
run: |
PEP440_VERSION=""
VERSION_PREFIX="v"
BRANCH_OR_TAG="$(echo ${{ github.event.ref }} | cut -d / -f 3)"
if [[ "${BRANCH_OR_TAG}" =~ ^v?(([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*(\.?(a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?)$ ]]
then
PEP440_VERSION="${BRANCH_OR_TAG#$VERSION_PREFIX}"
fi
echo "version=${PEP440_VERSION}" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install project and dependent tools
run: |
pip install -e . coverage ruff
- name: Check with ruff
run: |
ruff check .
- name: Test with coverage
run: |
coverage run -m unittest -fcv
coverage report -m
coverage xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
runs-on: ubuntu-latest
needs: [test, check-pep440]
if: needs.check-pep440.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: "pip"
- name: Install builder
run: pip install build
- name: Build Python distribution
run: pyproject-build
- name: Upload dist to artifact
uses: actions/upload-artifact@v4
with:
name: jinjyaml-dist-${{ needs.check-pep440.outputs.version }}
path: dist
if-no-files-found: error
retention-days: 1

publish:
runs-on: ubuntu-latest
needs: [check-pep440, build]
if: needs.check-pep440.outputs.version != ''
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download dist from artifact
uses: actions/download-artifact@v4
with:
name: jinjyaml-dist-${{needs.check-pep440.outputs.version}}
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# setuptools_scm version file
src/**/version.py

# test-results aircraft
test-results

*~

# temporary files which can be created if a process still has a handle open of a deleted file
Expand Down Expand Up @@ -927,3 +921,12 @@ Backup of *.doc*

# LibreOffice locks
.~lock.*#



# setuptools_scm version file
src/**/_version.py
*.lock

# test-results aircraft
test-results
2 changes: 2 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
files = src/**/*.py
13 changes: 10 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-added-large-files
Expand All @@ -17,12 +17,19 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.275
rev: v0.9.2
hooks:
- id: ruff

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.14.1"
hooks:
- id: mypy
args: [--ignore-missing-imports, --config-file, .mypy.ini]
additional_dependencies: [types-PyYAML]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.23.2"
rev: "0.31.0"
hooks:
- id: check-github-workflows
- id: check-readthedocs
16 changes: 9 additions & 7 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
src = ["src"]
extend-exclude = ["tests", "docs"]
# Always generate Python 3.7-compatible code.
target-version = "py37"
extend-exclude = ["docs"]
line-length = 128
ignore-init-module-imports = true
[mccabe]

[lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

# Ignore `F401`(imported but unused), `F403`(import *` used), `E402`(import violations) in all `__init__.py` files
[per-file-ignores]
"__init__.py" = ["E402", "F401", "F403"]
[lint.per-file-ignores]
"__init__.py" = ["E402", "F401"]

[format]
docstring-code-format = true
15 changes: 13 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,28 @@
"problemMatcher": []
},
{
"label": "python docs",
"label": "docs: build",
"type": "shell",
"command": "${command:python.interpreterPath} -m sphinx -b html -j auto -d _build/doctrees . _build/html",
"runOptions": {
"instanceLimit": 1
},
"group": "build",
"options": {
"cwd": "${workspaceFolder}/docs"
},
"problemMatcher": []
},
{
"label": "docs: serve",
"type": "shell",
"command": "${command:python.interpreterPath} -m http.server",
"runOptions": {
"instanceLimit": 1
},
"options": {
"cwd": "${workspaceFolder}/docs/_build/html"
},
"problemMatcher": []
}
]
}
Loading

0 comments on commit 3a8171b

Please sign in to comment.