Skip to content

Commit

Permalink
Merge branch 'release/0.4rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tanbro committed Mar 15, 2024
2 parents 82f8c4c + d8aad27 commit 3e11653
Show file tree
Hide file tree
Showing 27 changed files with 877 additions and 577 deletions.
14 changes: 6 additions & 8 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[run]
branch = True
source = src
relative_files = True
omit =
test/*
tests/*
.venv/*
env/*
venv/*
ENV/*
env.bak/*
venv.bak/*
_version.py
_yaml_types.py
_yaml_types_backward.py
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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
210 changes: 106 additions & 104 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,104 +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 test dependencies
run: |
pip install -e .
pip install pytest pytest-cov
- name: Test
run: |
pytest --cov=jinjyaml --cov-report=xml --cov-branch
- 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.7", "3.8", "3.9", "3.10", "3.11"]

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 . -r tests/requirements.txt 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 }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# setuptools_scm version file
src/**/version.py
src/**/_version.py

# test-results aircraft
test-results
Expand Down
2 changes: 1 addition & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"front_matter_title": ""
},
"line-length": false
}
}
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-added-large-files
- id: check-symlinks
- id: detect-private-key
- id: mixed-line-ending
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: check-toml
# - id: check-ast
- id: check-docstring-first

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

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.28.0"
hooks:
- id: check-github-workflows
- id: check-readthedocs
17 changes: 17 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
src = ["src"]
extend-exclude = ["docs"]
line-length = 128

[lint]
ignore-init-module-imports = true

[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
[lint.per-file-ignores]
"__init__.py" = ["E402", "F401"]

[format]
docstring-code-format = true
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"problemMatcher": []
}
]
}
}
Loading

0 comments on commit 3e11653

Please sign in to comment.