From b819410272ea9e13f2f3164a1364974e64031813 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Tue, 10 Oct 2023 10:00:20 +0200 Subject: [PATCH] [ci] Run vale directly and use official pre-commit hook. --- .pre-commit-config.yaml | 10 ++++++--- scripts/ci/helper/run-vale | 40 ---------------------------------- scripts/ci/jobs/build-docs.yml | 4 +--- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100755 scripts/ci/helper/run-vale diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b7569a2e79..c500d5ec5c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -73,11 +73,15 @@ repos: language: system pass_filenames: false files: \.(h|cpp)$ + - repo: https://github.com/errata-ai/vale + rev: v2.24.4 + hooks: - id: vale - name: Check spelling with vale - entry: bash -c 'if command -v vale &> /dev/null; then vale sync; VALE_MIN_ALERT_LEVEL=error scripts/ci/helper/run-vale; else exit 0; fi' + name: vale sync pass_filenames: false - language: system + args: [sync] + - id: vale + args: [--output=line, --minAlertLevel=error] - repo: https://github.com/charliermarsh/ruff-pre-commit rev: "v0.0.262" hooks: diff --git a/scripts/ci/helper/run-vale b/scripts/ci/helper/run-vale deleted file mode 100755 index 061ad491d5e..00000000000 --- a/scripts/ci/helper/run-vale +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -# From https://gitlab.com/gitlab-org/gitlab-runner/-/blob/main/scripts/lint-docs - -set -o pipefail -GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) -cd ${GIT_ROOT} -VALE_MIN_ALERT_LEVEL=${VALE_MIN_ALERT_LEVEL:-} -VALE_OUTPUT=${VALE_OUTPUT:-} -ERROR_RESULTS=0 -if command -v vale >/dev/null 2>&1; then - args=() - if [ -n "${VALE_MIN_ALERT_LEVEL}" ]; then - args+=("--minAlertLevel" "${VALE_MIN_ALERT_LEVEL}") - fi - if [ "${VALE_OUTPUT}" == "line" ]; then - args+=("--output" "line" "--sort" "--normalize") - fi - if [ "${VALE_OUTPUT}" == "json" ]; then - args+=("--output" "./Documentation/.vale/vale-json.tmpl") - else - echo "Lint prose" - fi - - # TODO: "Documentation" - vale "${args[@]}" web/content || ((ERROR_RESULTS++)) -else - echo "vale is missing, please install it from https://errata-ai.gitbook.io/vale/#installation" -fi -if [ "${VALE_OUTPUT}" == "json" ]; then - exit 0 -fi - -if [ "${ERROR_RESULTS}" -ne 0 ]; then - echo "✖ ${ERROR_RESULTS} Vale spell check failed. Review the log carefully to see full listing." - exit 1 -else - echo "✔ Vale spell check passed" - exit 0 -fi diff --git a/scripts/ci/jobs/build-docs.yml b/scripts/ci/jobs/build-docs.yml index 9ce2be9f4d6..05b56e3a887 100644 --- a/scripts/ci/jobs/build-docs.yml +++ b/scripts/ci/jobs/build-docs.yml @@ -102,10 +102,8 @@ spell check docs: image: registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.18-vale-2.27.0-markdownlint-0.35.0-markdownlint2-0.8.1 stage: check needs: [] - variables: - VALE_OUTPUT: json script: - - scripts/ci/helper/run-vale > vale-report.json + - vale web/content --output ./Documentation/.vale/vale-json.tmpl > vale-report.json artifacts: paths: - vale-report.json -- GitLab