From 403909cc8eed460663dac2c2a95f60ddbe4abdc6 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 10 Nov 2024 12:02:20 +0000 Subject: [PATCH 1/3] chore: add check-jsonchema for lint --- .gitlab/workflows/ci.yml | 2 +- .renovaterc.json | 2 +- Makefile | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) 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/.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..0202e8e9 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 .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: From e28cdc4a21eabdb7f181ed8c0760778545ef65f7 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 10 Nov 2024 12:48:27 +0000 Subject: [PATCH 2/3] update template --- template/.renovaterc.json.jinja | 2 +- template/Makefile.jinja | 14 +++++++++++++- .../workflows/ci.yml.jinja | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) 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..bde2de11 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 .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: From 05d29ba33659a24ef529a1ab8f1eb8fc478a4231 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 10 Nov 2024 13:29:03 +0000 Subject: [PATCH 3/3] update pre-commit` --- .pre-commit-config.yaml | 12 ++++++++++++ Makefile | 2 +- template/.pre-commit-config.yaml.jinja | 12 ++++++++++++ template/Makefile.jinja | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) 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/Makefile b/Makefile index 0202e8e9..96da9af6 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ 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 .gitlab-ci.yml .gitlab/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 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/Makefile.jinja b/template/Makefile.jinja index bde2de11..521a6351 100644 --- a/template/Makefile.jinja +++ b/template/Makefile.jinja @@ -96,7 +96,7 @@ check-jsonschema: 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 .gitlab-ci.yml .gitlab/workflows/*.yml + 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