diff --git a/.gitlab/workflows/ci.yml b/.gitlab/workflows/ci.yml index 10a3fa7c..0763cdff 100644 --- a/.gitlab/workflows/ci.yml +++ b/.gitlab/workflows/ci.yml @@ -11,7 +11,7 @@ ci: files: - pdm.lock prefix: venv-${PYTHON_VERSION} - coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/ + coverage: /TOTAL.*? (100(?:\.0+)?\%\|[1-9]?\d(?:\.\d+)?\%)$/ image: ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} interruptible: true parallel: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03c05232..a87d40d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -88,6 +88,18 @@ repos: language: python types: - text + - id: check-jsonschema + name: check-jsonschema + entry: make check-jsonschema + language: python + files: (?x)^( + \.github/workflows/[^/]+| + \.gitlab-ci\.yml| + \.gitlab/workflows/[^/]+| + \.readthedocs\.yaml| + \.renovaterc\.json + )$ + pass_filenames: false - id: forbidden-files name: forbidden files entry: found Copier update rejection files; review them and remove them diff --git a/.renovaterc.json b/.renovaterc.json index 0bdf670b..6571049d 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -147,7 +147,7 @@ ], "postUpgradeTasks": { "commands": [ - "find template -type f -regex 'template/.*\.github.*/workflows/.*' -exec sed -i 's|{{{depName}}}-{{{currentValue}}}|{{{depName}}}-{{{newValue}}}|g' {} +" + "find template -type f -regex 'template/.*\\.github.*/workflows/.*' -exec sed -i 's|{{{depName}}}-{{{currentValue}}}|{{{depName}}}-{{{newValue}}}|g' {} +" ] } }, diff --git a/Makefile b/Makefile index 1cad7932..96da9af6 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,7 @@ dev: # Install standalone tools prerequisites: + pipx install --force check-jsonschema==0.29.4 pipx install --force codespell[toml]==2.3.0 pipx install --force pdm==2.20.1 pipx install --force pre-commit==4.0.1 @@ -87,8 +88,15 @@ pyproject-fmt: codespell: codespell +# Check jsonschema with check-jsonschema. +check-jsonschema: + check-jsonschema --builtin-schema vendor.github-workflows .github/workflows/*.yml + check-jsonschema --builtin-schema vendor.gitlab-ci --data-transform gitlab-ci .gitlab-ci.yml .gitlab/workflows/*.yml + check-jsonschema --builtin-schema vendor.readthedocs .readthedocs.yaml + check-jsonschema --builtin-schema vendor.renovate .renovaterc.json + # Check lint with all linters. -lint: mypy ruff ruff-format pyproject-fmt codespell +lint: mypy ruff ruff-format pyproject-fmt codespell check-jsonschema # Run pre-commit with autofix against all files. pre-commit: diff --git a/template/.pre-commit-config.yaml.jinja b/template/.pre-commit-config.yaml.jinja index e43a7506..19cb18f5 100644 --- a/template/.pre-commit-config.yaml.jinja +++ b/template/.pre-commit-config.yaml.jinja @@ -91,6 +91,18 @@ repos: language: python types: - text + - id: check-jsonschema + name: check-jsonschema + entry: make check-jsonschema + language: python + files: (?x)^( + \.github/workflows/[^/]+| + \.gitlab-ci\.yml| + \.gitlab/workflows/[^/]+| + \.readthedocs\.yaml| + \.renovaterc\.json + )$ + pass_filenames: false - id: forbidden-files name: forbidden files entry: found Copier update rejection files; review them and remove them diff --git a/template/.renovaterc.json.jinja b/template/.renovaterc.json.jinja index 4d13ca99..3ba8481e 100644 --- a/template/.renovaterc.json.jinja +++ b/template/.renovaterc.json.jinja @@ -161,7 +161,7 @@ ], "postUpgradeTasks": { "commands": [ - "find template -type f -regex 'template/.*\.github.*/workflows/.*' -exec sed -i {{ '\'s|{{{depName}}}-{{{currentValue}}}|{{{depName}}}-{{{newValue}}}|g\' {} +' }}" + "find template -type f -regex 'template/.*\\.github.*/workflows/.*' -exec sed -i {{ '\'s|{{{depName}}}-{{{currentValue}}}|{{{depName}}}-{{{newValue}}}|g\' {} +' }}" ] } }, diff --git a/template/Makefile.jinja b/template/Makefile.jinja index e3390042..521a6351 100644 --- a/template/Makefile.jinja +++ b/template/Makefile.jinja @@ -58,6 +58,7 @@ dev: # Install standalone tools prerequisites: + pipx install --force check-jsonschema==0.29.4 pipx install --force codespell[toml]==2.3.0 pipx install --force pdm==2.20.1 pipx install --force pre-commit==4.0.1 @@ -89,8 +90,19 @@ pyproject-fmt: codespell: codespell +# Check jsonschema with check-jsonschema. +check-jsonschema: +[%- if repo_platform == "github" %] + check-jsonschema --builtin-schema vendor.github-workflows .github/workflows/*.yml +[%- endif %] +[%- if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' or project_name == "Serious Scaffold Python" %] + check-jsonschema --builtin-schema vendor.gitlab-ci --data-transform gitlab-ci .gitlab-ci.yml .gitlab/workflows/*.yml +[%- endif %] + check-jsonschema --builtin-schema vendor.readthedocs .readthedocs.yaml + check-jsonschema --builtin-schema vendor.renovate .renovaterc.json + # Check lint with all linters. -lint: mypy ruff ruff-format pyproject-fmt codespell +lint: mypy ruff ruff-format pyproject-fmt codespell check-jsonschema # Run pre-commit with autofix against all files. pre-commit: diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja index e10707e4..33c85a2b 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja @@ -12,7 +12,7 @@ ci: files: - pdm.lock prefix: venv-${PYTHON_VERSION} - coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/ + coverage: /TOTAL.*? (100(?:\.0+)?\%\|[1-9]?\d(?:\.\d+)?\%)$/ image: ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} interruptible: true parallel: