Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,40 +68,43 @@ 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:
fail-fast: false
matrix:
target:
- lint
- vale
- test
- unused-media
- test-go-redirects
- dockerfile-lint
- path-warnings
- validate-vendor
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
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 changes: 31 additions & 0 deletions .vale-rdjsonl.tmpl
Original file line number Diff line number Diff line change
@@ -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 -}}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ variable "DRY_RUN" {
default = null
}

variable "GITHUB_ACTIONS" {
default = null
}

group "default" {
targets = ["release"]
}
Expand All @@ -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" {
Expand All @@ -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"]
Expand Down
Loading