diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93ac1a6..e758035 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,80 +7,37 @@ jobs: linting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - restore-keys: ${{ runner.os }}-pip - - name: Install Poetry - uses: snok/install-poetry@v1.1.1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - # virtualenvs-path: ~/.venv - - - name: Ensure cache is healthy - if: steps.cache.outputs.cache-hit == 'true' - shell: bash - run: timeout 10s poetry run pip --version || rm -rf .venv - - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v2 - with: - path: .venv - key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - # install dependencies if cache does not exist - - name: Check cache and install dependencies - run: poetry install - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + - uses: actions/checkout@v4 + - name: Install virtualenv from poetry + uses: 20c/workflows/poetry@v1 - name: Run linters run: | - source .venv/bin/activate - # flake8 . - black . --check - isort . + poetry run isort . + poetry run black --check src/ + poetry run pre-commit run --all-files test: needs: linting strategy: - fail-fast: true + fail-fast: false matrix: os: [ "ubuntu-latest", "macos-latest" ] - python-version: [ "3.6", "3.7", "3.8", "3.9" ] + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] runs-on: ${{ matrix.os }} steps: - name: Check out repository - uses: actions/checkout@v2 - - name: Set up python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/checkout@v4 + - name: Install virtualenv from poetry + uses: 20c/workflows/poetry@v1 with: python-version: ${{ matrix.python-version }} - - name: Install Poetry - uses: snok/install-poetry@v1.1.1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v2 - with: - path: .venv - key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - # install dependencies if cache does not exist - - name: Check cache and install dependencies - run: poetry install - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - - name: Run tests + - name: Install dependencies run: | - source .venv/bin/activate - pytest -vv --cov-report=term-missing --cov=${{ github.event.repository.name }} --cov-report=xml tests/ - coverage report - # upload coverage stats + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Run tests + run: tox -e py - name: Upload coverage - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: - file: ./coverage.xml fail_ci_if_error: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5eb2ce5..07f1af5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,30 +1,28 @@ +fail_fast: false +exclude: | + (?x)^( + tests/data/.* + )$ repos: - - repo: local + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + - id: trailing-whitespace + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.14 hooks: - - id: system - name: isort - entry: poetry run isort src/ - language: system - pass_filenames: false + # Run the linter. + - id: ruff + args: [--fix] + # Run the formatter. + - id: ruff-format - repo: local hooks: - - id: pyupgrade + - id: pyupgrade name: pyupgrade entry: poetry run pyupgrade --py38-plus language: python types: [python] pass_filenames: true - - repo: local - hooks: - - id: system - name: Black - entry: poetry run black src/ - language: system - pass_filenames: false - - repo: local - hooks: - - id: system - name: flake8 - entry: poetry run flake8 src/ - language: system - pass_filenames: false \ No newline at end of file diff --git a/Ctl/config.yml b/Ctl/config.yml index 9b317f0..4af70a1 100644 --- a/Ctl/config.yml +++ b/Ctl/config.yml @@ -43,7 +43,7 @@ ctl: - Ctl/tmplvars.yaml ignore: - \.git/ - + # command to remove temporary files - name: clean diff --git a/Ctl/tmplvars.yaml b/Ctl/tmplvars.yaml index 75f02ac..635296a 100644 --- a/Ctl/tmplvars.yaml +++ b/Ctl/tmplvars.yaml @@ -4,4 +4,4 @@ version: "0.4.0.1" project_description: "Template abstraction for using multiple template engine backends in same code." project_license: "Apache-2.0" # FIXME -coverage_repos: "tmpl" +coverage_repos: "tmpl" diff --git a/poetry.lock b/poetry.lock index a8cf78b..0de1f6d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,51 +1,5 @@ # This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. -[[package]] -name = "black" -version = "23.12.1" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-23.12.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0aaf6041986767a5e0ce663c7a2f0e9eaf21e6ff87a5f95cbf3675bfd4c41d2"}, - {file = "black-23.12.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c88b3711d12905b74206227109272673edce0cb29f27e1385f33b0163c414bba"}, - {file = "black-23.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920b569dc6b3472513ba6ddea21f440d4b4c699494d2e972a1753cdc25df7b0"}, - {file = "black-23.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:3fa4be75ef2a6b96ea8d92b1587dd8cb3a35c7e3d51f0738ced0781c3aa3a5a3"}, - {file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"}, - {file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"}, - {file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"}, - {file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"}, - {file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"}, - {file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"}, - {file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"}, - {file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"}, - {file = "black-23.12.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1fa88a0f74e50e4487477bc0bb900c6781dbddfdfa32691e780bf854c3b4a47f"}, - {file = "black-23.12.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a4d6a9668e45ad99d2f8ec70d5c8c04ef4f32f648ef39048d010b0689832ec6d"}, - {file = "black-23.12.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b18fb2ae6c4bb63eebe5be6bd869ba2f14fd0259bda7d18a46b764d8fb86298a"}, - {file = "black-23.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:c04b6d9d20e9c13f43eee8ea87d44156b8505ca8a3c878773f68b4e4812a421e"}, - {file = "black-23.12.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3e1b38b3135fd4c025c28c55ddfc236b05af657828a8a6abe5deec419a0b7055"}, - {file = "black-23.12.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4f0031eaa7b921db76decd73636ef3a12c942ed367d8c3841a0739412b260a54"}, - {file = "black-23.12.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:97e56155c6b737854e60a9ab1c598ff2533d57e7506d97af5481141671abf3ea"}, - {file = "black-23.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:dd15245c8b68fe2b6bd0f32c1556509d11bb33aec9b5d0866dd8e2ed3dba09c2"}, - {file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"}, - {file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "certifi" version = "2023.11.17" @@ -451,22 +405,6 @@ docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1 testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] typing = ["typing-extensions (>=4.8)"] -[[package]] -name = "flake8" -version = "5.0.4" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, - {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.9.0,<2.10.0" -pyflakes = ">=2.5.0,<2.6.0" - [[package]] name = "ghp-import" version = "2.1.0" @@ -582,20 +520,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "jaraco-classes" version = "3.3.0" @@ -798,17 +722,6 @@ files = [ {file = "MarkupSafe-2.1.4.tar.gz", hash = "sha256:3aae9af4cac263007fd6309c64c6ab4506dd2b79382d9d19a1994f9240b8db4f"}, ] -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - [[package]] name = "mdurl" version = "0.1.2" @@ -1114,17 +1027,6 @@ nodeenv = ">=0.11.1" pyyaml = ">=5.1" virtualenv = ">=20.10.0" -[[package]] -name = "pycodestyle" -version = "2.9.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, - {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, -] - [[package]] name = "pycparser" version = "2.21" @@ -1136,17 +1038,6 @@ files = [ {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, ] -[[package]] -name = "pyflakes" -version = "2.5.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, - {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, -] - [[package]] name = "pygments" version = "2.17.2" @@ -1636,4 +1527,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "ecf09652a9a143b217cab73c1e52641d3b78c7c3e1a83b9c56059b67a9997f9f" +content-hash = "b11e2413ebe0c2d049f5ae1f50696172bd564f50b1fe2580d8fd1991f4b17f5f" diff --git a/pyproject.toml b/pyproject.toml index b6d9b23..59ad0bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,29 +4,29 @@ version = "1.0.0" description = "Template abstraction for using multiple template engine backends in same code." repository = "https://github.com/20c/tmpl" readme = "README.md" -authors = [ "20C ",] +authors = ["20C "] license = "Apache-2.0" classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", - "Topic :: Software Development", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules", ] -packages = [ - { include = "tmpl", from = "src" }, -] +packages = [{ include = "tmpl", from = "src" }] [tool.poetry.dependencies] python = "^3.8" [tool.poetry.dev-dependencies] +jinja2 = ">=2" + # testing coverage = ">=5" pytest = ">=6" @@ -35,9 +35,6 @@ pytest-cov = "*" # linting ruff = ">=0.1" -black = ">=20" -isort = ">=5.7" -flake8 = ">=3.8" mypy = ">=0.950" pre-commit = ">=2.13" pyupgrade = ">=2.19" @@ -45,20 +42,19 @@ pyupgrade = ">=2.19" # docs markdown = "*" markdown-include = ">=0.5,<1" -mkdocs = "^1.2.3" +mkdocs = ">=1.2.3" # ctl ctl = ">=1" -jinja2 = ">=2" twine = ">=3" [tool.poetry.plugins."markdown.extensions"] pymdgen = "pymdgen.md:Extension" +[tool.ruff.lint] +# Enable the isort rules. +extend-select = ["I"] + [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" - -[tool.isort] -profile = "black" -multi_line_output = 3 diff --git a/tests/test_base.py b/tests/test_base.py index 2e47093..f4f7529 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,5 +1,4 @@ import util - from tmpl.context import Context diff --git a/tests/test_engines.py b/tests/test_engines.py index 55683b7..268679b 100644 --- a/tests/test_engines.py +++ b/tests/test_engines.py @@ -2,9 +2,8 @@ import sys import pytest -import util - import tmpl +import util engines = ["DjangoEngine", "Jinja2Engine"] engines = ["DjangoEngine", "Jinja2Engine"]