diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..2c8aaaf --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,5 @@ +ARG IMAGE="python:3.12" +FROM --platform=amd64 mcr.microsoft.com/vscode/devcontainers/${IMAGE} +RUN apt-get update \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends build-essential libssl-dev gdb cmake diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..63570b4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "Render Engine", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + "IMAGE": "python:3.12" + } + }, + "postCreateCommand": ". .devcontainer/setup.sh", + "customizations": { + "vscode": { + "settings": { + "python.formatting.provider": "charliermarsh.ruff", + "python.testing.pytestEnabled": true, + "python.testing.pytestPath": "pytest", + "python.testing.unittestEnabled": false, + "python.editor.formatOnSave": true, + "python.editor.codeActionsOnSave": {"source.fixAll": true}, + "python.testing.pytestArgs": [ + "tests" + ], + ".markdownlint-cli2.ignores": [".gitignore"] + + }, + "extensions": [ + "ms-python.python", + "charliermarsh.ruff", + "github.github-actions", + "github.github", + "yzhang.markdown-all-in-one", + "DavidAnson.vscode-markdownlint" + ] + } + } +} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 0000000..c01c0eb --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,6 @@ +python -m pip install --user --upgrade pip +python -m pip install --user pip-tools +python -m piptools compile --upgrade -o requirements.txt pyproject.toml +python -m pip install --user -r requirements.txt +python -m pip install -e . +pre-commit install diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4874ed3..ad08fdc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,5 @@ name: Format and Lint with Ruff and MarkdownLint -on: +on: pull_request: branches: [main] workflow_dispatch: @@ -14,7 +14,7 @@ jobs: with: fetch-depth: 0 - name: Install Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install dependencies @@ -24,25 +24,17 @@ jobs: # Update output format to enable automatic inline annotations. - name: Run Ruff run: | - ruff check --fix --output-format=github render_engine_parser - - ruff format render_engine_parser + ruff check . --fix --output-format=github + ruff format . - name: Markdown Lint base-files - uses: DavidAnson/markdownlint-cli2-action@v14 + uses: DavidAnson/markdownlint-cli2-action@v16 with: fix: true globs: | *.md .github/**/*.md continue-on-error: true - - name: Markdown Lint Docs - uses: DavidAnson/markdownlint-cli2-action@v14 - with: - fix: true - globs: docs/**/*.md - config: docs/.markdownlint.json - continue-on-error: true - name: Commit changes run: | if [ -n "$(git status --porcelain)" ]; then @@ -52,6 +44,3 @@ jobs: git commit -m "Format and lint with Ruff" git push origin HEAD:${{ github.event.pull_request.head.ref }} fi - - - diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6ff1539..7ba4714 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,6 @@ name: Build distribution -on: +on: release: types: [created] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7133c91 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +default_language_version: + python: python3.12 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + - id: check-toml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.7 + hooks: + - id: ruff + args: ["--fix"] + # Run the formatter. + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 49a7238..2f303d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dev = [ "pytest", "pytest-cov", "ruff", - ] +] [tool.setuptools_scm] @@ -37,8 +37,7 @@ version_toml = "pyproject.toml:project.version" branch = "main" [tool.ruff] -select = ["E", "F", "I", "UP"] +lint.select = ["E", "F", "I", "UP"] target-version = "py311" line-length = 120 src = ["src"] -ignore-init-module-imports = true diff --git a/requirements.txt b/requirements.txt index 9131120..4b60907 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,26 +1,10 @@ # -# This file is autogenerated by pip-compile with Python 3.13 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --extra=dev +# pip-compile --output-file=requirements.txt pyproject.toml # -coverage[toml]==7.6.1 - # via pytest-cov -iniconfig==2.0.0 - # via pytest -packaging==24.1 - # via pytest -pluggy==1.5.0 - # via pytest -pytest==8.3.2 - # via - # pytest-cov - # render_engine_parser (pyproject.toml) -pytest-cov==5.0.0 - # via render_engine_parser (pyproject.toml) python-frontmatter==1.1.0 # via render_engine_parser (pyproject.toml) pyyaml==6.0.2 # via python-frontmatter -ruff==0.6.4 - # via render_engine_parser (pyproject.toml) diff --git a/tests/test_base_parser.py b/tests/test_base_parser.py index 1b13c33..82fa883 100644 --- a/tests/test_base_parser.py +++ b/tests/test_base_parser.py @@ -1,6 +1,5 @@ import frontmatter import pytest - from render_engine_parser.base_parsers import BasePageParser, parse_content