Skip to content
Draft
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
100 changes: 100 additions & 0 deletions .github/workflows/docs-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: "Docs: Validate Documentation"

on:
pull_request:
paths:
- '**.md'
- 'test/docs/**'
- '.github/workflows/docs-validation.yml'
- '.markdownlint.json'
push:
branches:
- main
paths:
- '**.md'
- 'test/docs/**'
Comment on lines +5 to +15

permissions:
contents: read

jobs:
markdown-lint:
name: Markdown Linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0

# Linting every .md in the repo is not viable: ~198 files carry pre-existing
# violations. Lint only in-scope files that this change actually touches, and
# widen SCOPE as more docs are brought up to standard.
- name: Collect changed Markdown files in scope
id: changed
env:
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
run: |
set -euo pipefail

base="${BASE_SHA:-}"
if [[ -z "${base}" ]] || ! git cat-file -e "${base}^{commit}" 2>/dev/null; then
# First push to a branch, or a force push: fall back to the previous commit.
base="$(git rev-parse HEAD^ 2>/dev/null || git rev-parse HEAD)"
fi

files="$(git diff --name-only --diff-filter=ACMR "${base}" HEAD -- \
docs/personal-dev.md test/docs/ \
| { grep -E '\.md$' || true; } \
| tr '\n' ' ' | sed 's/ *$//')"

# When only config/workflow files changed, lint the baseline scope
# so invalid config can still be caught.
if [[ -z "${files}" ]]; then
changed_configs="$(git diff --name-only --diff-filter=ACMR "${base}" HEAD -- \
.markdownlint.json .github/workflows/docs-validation.yml \
|| true)"
if [[ -n "${changed_configs}" ]]; then
files="docs/personal-dev.md test/docs/README.md"
existing=""
for f in ${files}; do
if [[ -f "${f}" ]]; then
existing="${existing} ${f}"
fi
done
files="$(echo "${existing}" | sed 's/^ *//')"
echo "Config changed; linting baseline: ${files}"
else
echo "No in-scope Markdown changed; nothing to lint."
fi
else
echo "Linting: ${files}"
fi

echo "files=${files}" >> "$GITHUB_OUTPUT"

- name: Lint changed Markdown files
if: steps.changed.outputs.files != ''
uses: nosborn/github-action-markdown-cli@f5d8cad27b5690b173425c45f762f8662ecf47e8 # v3.3.0
with:
files: ${{ steps.changed.outputs.files }}
config_file: .markdownlint.json

readme-tests:
name: README Command Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.work

# dry-run asserts only on the docs, so no az/kubectl install is needed.
- name: Run personal-dev README tests
run: |
bash test/docs/personal-dev-readme-test.sh
env:
TEST_MODE: dry-run
18 changes: 18 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"default": true,
"MD013": {
"line_length": 120,
"code_blocks": false,
"tables": false
},
"MD033": false,
"MD041": false,
"MD028": false,
"MD060": false,
"MD024": {
"siblings_only": true
},
"MD046": {
"style": "fenced"
}
}
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@ image-updater:

# Component updater (shared version bumper; Istio wired today — tooling/component-updater/README.md)
COMPONENT ?=
# Documentation tests
test-docs:
@echo "Running documentation tests..."
@bash ./test/docs/personal-dev-readme-test.sh
.PHONY: test-docs

SUBSCRIPTION_ID ?=
component-updater-check:
@$(MAKE) -C tooling/component-updater check COMPONENT="$(COMPONENT)" SUBSCRIPTION_ID="$(SUBSCRIPTION_ID)"
Expand Down
Loading