run vale in docker

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2025-07-16 15:06:36 +02:00
parent c69c0b53dd
commit 04b56a67f9
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
4 changed files with 79 additions and 14 deletions

View File

@ -68,17 +68,6 @@ jobs:
AWS_CLOUDFRONT_ID: 0123456789ABCD
AWS_LAMBDA_FUNCTION: DockerDocsRedirectFunction-dummy
vale:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: errata-ai/vale-action@reviewdog
env:
PIP_BREAK_SYSTEM_PACKAGES: 1
with:
files: content
validate:
runs-on: ubuntu-24.04
strategy:
@ -86,6 +75,7 @@ jobs:
matrix:
target:
- lint
- vale
- test
- unused-media
- test-go-redirects
@ -93,6 +83,9 @@ jobs:
- path-warnings
- validate-vendor
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -100,8 +93,18 @@ jobs:
name: Validate
uses: docker/bake-action@v6
with:
source: .
files: |
docker-bake.hcl
targets: ${{ matrix.target }}
set: |
*.args.BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
-
name: Install reviewdog
if: ${{ matrix.target == 'vale' && github.event_name == 'pull_request' }}
uses: reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893 # v1.3.2
-
name: Run reviewdog for vale
if: ${{ matrix.target == 'vale' && github.event_name == 'pull_request' }}
run: |
cat ./tmp/vale.out | reviewdog -f=rdjsonl -name=vale -reporter=github-pr-annotations -fail-on-error=false -filter-mode=added -level=info
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

31
.vale-rdjsonl.tmpl Normal file
View File

@ -0,0 +1,31 @@
{{- /* Range over the linted files */ -}}
{{- range .Files}}
{{- $path := .Path -}}
{{- /* Range over the file's alerts */ -}}
{{- range .Alerts -}}
{{- $error := "" -}}
{{- if eq .Severity "error" -}}
{{- $error = "ERROR" -}}
{{- else if eq .Severity "warning" -}}
{{- $error = "WARNING" -}}
{{- else -}}
{{- $error = "INFO" -}}
{{- end}}
{{- /* Variables setup */ -}}
{{- $line := printf "%d" .Line -}}
{{- $col := printf "%d" (index .Span 0) -}}
{{- $check := printf "%s" .Check -}}
{{- $message := printf "%s" .Message -}}
{{- /* Output */ -}}
{"message": "[{{ $check }}] {{ $message | jsonEscape }}", "location": {"path": "{{ $path }}", "range": {"start": {"line": {{ $line }}, "column": {{ $col }}}}}, "severity": "{{ $error }}"}
{{end -}}
{{end -}}

View File

@ -4,6 +4,7 @@
ARG ALPINE_VERSION=3.21
ARG GO_VERSION=1.24
ARG HTMLTEST_VERSION=0.17.0
ARG VALE_VERSION=3.11.2
ARG HUGO_VERSION=0.141.0
ARG NODE_VERSION=22
ARG PAGEFIND_VERSION=1.3.0
@ -67,6 +68,23 @@ COPY --from=build /project/public ./public
ADD .htmltest.yml .htmltest.yml
RUN htmltest
# vale
FROM jdkato/vale:v${VALE_VERSION} AS vale-run
WORKDIR /src
ARG GITHUB_ACTIONS
RUN --mount=type=bind,target=.,rw <<EOT
set -e
mkdir /out
args=""
[ "$GITHUB_ACTIONS" = "true" ] && args="--output=.vale-rdjsonl.tmpl"
set -x
vale sync
vale $args content/ | tee /out/vale.out
EOT
FROM scratch AS vale
COPY --from=vale-run /out/vale.out /
# update-modules downloads and vendors Hugo modules
FROM build-base AS update-modules
# MODULE is the Go module path and version of the module to update

View File

@ -14,6 +14,10 @@ variable "DRY_RUN" {
default = null
}
variable "GITHUB_ACTIONS" {
default = null
}
group "default" {
targets = ["release"]
}
@ -36,7 +40,7 @@ target "release" {
}
group "validate" {
targets = ["lint", "test", "unused-media", "test-go-redirects", "dockerfile-lint", "path-warnings", "validate-vendor"]
targets = ["lint", "vale", "test", "unused-media", "test-go-redirects", "dockerfile-lint", "path-warnings", "validate-vendor"]
}
target "test" {
@ -51,6 +55,15 @@ target "lint" {
provenance = false
}
target "vale" {
target = "vale"
args = {
GITHUB_ACTIONS = GITHUB_ACTIONS
}
output = ["./tmp"]
provenance = false
}
target "unused-media" {
target = "unused-media"
output = ["type=cacheonly"]