From 19092591794aed347fbbdc0c88f3c4642abc816d Mon Sep 17 00:00:00 2001 From: Matt Norton Date: Tue, 9 Dec 2025 00:57:43 +0000 Subject: [PATCH 1/4] Swap to using single-purpose linters, rather than JSON schema checkers --- .pre-commit-config.yaml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0fdcc024..5c2c7f5e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,11 @@ default_language_version: default_stages: [pre-commit, pre-merge-commit, manual] repos: + - repo: https://github.com/rhysd/actionlint + rev: v1.7.9 + hooks: + - id: actionlint + - repo: https://github.com/dotenv-linter/dotenv-linter rev: v4.0.0 hooks: @@ -28,17 +33,6 @@ repos: args: [--strict] stages: [manual] - - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.35.0 - hooks: - - id: check-github-workflows - - - id: check-jsonschema - args: [--schemafile, 'https://json.schemastore.org/yamllint.json'] # yamllint disable-line rule:quoted-strings - files: ^\.yamllint\.yaml$ # yamllint disable-line rule:key-ordering - name: Check yamllint configuration file - types: [yaml] - - repo: https://github.com/jorisroovers/gitlint rev: v0.19.1 hooks: From e804b4aa4c64e14a5bfde33ac0b3474a20fdc918 Mon Sep 17 00:00:00 2001 From: Matt Norton Date: Wed, 10 Dec 2025 00:50:45 +0000 Subject: [PATCH 2/4] Add actionlint pre-commit --- .github/workflows/check-build-deploy.yaml | 48 ++++++++++++----------- .pre-commit-config.yaml | 10 +++++ 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/.github/workflows/check-build-deploy.yaml b/.github/workflows/check-build-deploy.yaml index 9c07186e..0289ba70 100644 --- a/.github/workflows/check-build-deploy.yaml +++ b/.github/workflows/check-build-deploy.yaml @@ -44,8 +44,8 @@ jobs: - name: Run Flake8 # TODO: Run from locked dependencies, once project's Python version has been updated to 3.14 - run: uvx --python 3.14 --with flake8-carrot>=0.1.4 --with flake8-pyproject>=1.2 -- - flake8 + run: uvx --python 3.14 --with "flake8-carrot>=0.1.4" --with "flake8-pyproject>=1.2" + -- flake8 mypy: # yamllint disable-line rule:key-ordering env: @@ -76,20 +76,20 @@ jobs: - name: Install mypy From Locked Dependencies run: | if [ "${{matrix.component}}" == "package" ]; then - ARGS="" + ARGS=() elif [ "${{matrix.component}}" == "tests" ]; then - ARGS="--group test" + ARGS=("--group" "test") else - echo "Error: Unknown matrix.component value: '${{matrix.component}}'" >&2 - exit 1 + echo "Error: Unknown matrix.component value: '${{matrix.component}}'" >&2 + exit 1 fi - uv sync --no-group dev --group type-check $ARGS + uv sync --no-group dev --group type-check "${ARGS[@]}" - id: store-hashed-python-version name: Store Hashed Python Version run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)" - >> $GITHUB_OUTPUT + >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: @@ -99,15 +99,15 @@ jobs: - name: Run mypy # TODO: Add GitHub workflows output format run: | if [ "${{matrix.component}}" == "package" ]; then - ARGS=". --exclude tests/" + ARGS=("." "--exclude" "tests/") elif [ "${{matrix.component}}" == "tests" ]; then - ARGS="tests/" + ARGS=("tests/") else - echo "Error: Unknown matrix.component value: '${{matrix.component}}'" >&2 - exit 1 + echo "Error: Unknown matrix.component value: '${{matrix.component}}'" >&2 + exit 1 fi - uv run -- mypy $ARGS + uv run -- mypy "${ARGS[@]}" pre-commit: # yamllint disable-line rule:key-ordering env: @@ -142,7 +142,7 @@ jobs: - id: store-hashed-python-version name: Store Hashed Python Version run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)" - >> $GITHUB_OUTPUT + >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: @@ -155,13 +155,18 @@ jobs: - name: Save pre-commit Checks Which Require Skipping run: | if [[ "${{github.event_name}}" == "push" && "${{github.ref_name}}" == "${{github.event.repository.default_branch}}" ]]; then - echo "SKIP=check-github-workflows,flake8,ruff-check,uv-lock,gitlint-ci" >> $GITHUB_ENV + echo "SKIP=check-github-workflows,flake8,ruff-check,uv-lock,gitlint-ci" >> "$GITHUB_ENV" else - echo "SKIP=check-github-workflows,flake8,ruff-check,uv-lock" >> $GITHUB_ENV + echo "SKIP=check-github-workflows,flake8,ruff-check,uv-lock" >> "$GITHUB_ENV" fi - name: Run pre-commit - run: uv run -- pre-commit run --all-files --hook-stage manual # TODO: Add GitHub workflows output format + run: | + set -o pipefail + uv run -- pre-commit run --all-files --hook-stage manual | tee /tmp/pre-commit.log + + - name: Ensure No Warnings + run: if grep -q "\[WARNING\]" /tmp/pre-commit.log; then exit 1; fi - if: ${{!cancelled()}} uses: pre-commit-ci/lite-action@v1.1.0 @@ -221,7 +226,7 @@ jobs: - id: store-hashed-python-version name: Store Hashed Python Version run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)" - >> $GITHUB_OUTPUT + >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: @@ -269,7 +274,7 @@ jobs: - id: store-hashed-python-version name: Store Hashed Python Version run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)" - >> $GITHUB_OUTPUT + >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: @@ -284,9 +289,8 @@ jobs: IMAGE_NAME: ${{github.repository}} REGISTRY: ghcr.io environment: publish - if: | - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name == 'CSSUoB/TeX-Bot-Py-V2' + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name + == 'CSSUoB/TeX-Bot-Py-V2' needs: [mypy, pre-commit, pymarkdown, pytest, ruff-lint, uv-check] permissions: attestations: write diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c2c7f5e..2edcfbb1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,6 +8,7 @@ repos: rev: v1.7.9 hooks: - id: actionlint + args: [-pyflakes=] - repo: https://github.com/dotenv-linter/dotenv-linter rev: v4.0.0 @@ -33,6 +34,15 @@ repos: args: [--strict] stages: [manual] + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.35.0 + hooks: + - id: check-jsonschema + args: [--schemafile, 'https://json.schemastore.org/yamllint.json'] # yamllint disable-line rule:quoted-strings + files: ^\.yamllint\.yaml$ # yamllint disable-line rule:key-ordering + name: Check yamllint configuration file + types: [yaml] + - repo: https://github.com/jorisroovers/gitlint rev: v0.19.1 hooks: From 69b81036523a92644040681b24f91d74d9b23f39 Mon Sep 17 00:00:00 2001 From: Matt Norton Date: Wed, 10 Dec 2025 00:59:01 +0000 Subject: [PATCH 3/4] Add shellcheck as pre-commit dependency --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2edcfbb1..28f44add 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,6 +8,7 @@ repos: rev: v1.7.9 hooks: - id: actionlint + additional_dependencies: [github.com/wasilibs/go-shellcheck/cmd/shellcheck@latest] # yamllint disable-line rule:key-ordering args: [-pyflakes=] - repo: https://github.com/dotenv-linter/dotenv-linter From 2eb29ccbd1808f47d021c0cbecef6d3ab6be70c6 Mon Sep 17 00:00:00 2001 From: Matt Norton Date: Sun, 14 Dec 2025 16:22:04 +0000 Subject: [PATCH 4/4] Remove unnecessary pre-commit CI skips --- .github/workflows/check-build-deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-build-deploy.yaml b/.github/workflows/check-build-deploy.yaml index a712e63a..c7408f4f 100644 --- a/.github/workflows/check-build-deploy.yaml +++ b/.github/workflows/check-build-deploy.yaml @@ -155,9 +155,9 @@ jobs: - name: Save pre-commit Checks Which Require Skipping run: | if [[ "${{github.event_name}}" == "push" && "${{github.ref_name}}" == "${{github.event.repository.default_branch}}" ]]; then - echo "SKIP=check-github-workflows,flake8,ruff-check,uv-lock,gitlint-ci" >> "$GITHUB_ENV" + echo "SKIP=flake8,ruff-check,uv-lock,gitlint-ci" >> "$GITHUB_ENV" else - echo "SKIP=check-github-workflows,flake8,ruff-check,uv-lock" >> "$GITHUB_ENV" + echo "SKIP=flake8,ruff-check,uv-lock" >> "$GITHUB_ENV" fi - name: Run pre-commit