8000 docs: unify documentation workflows with improved validation by EdwardAngert · Pull Request #17522 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

docs: unify documentation workflows with improved validation #17522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d0fe1f8
Add simplified docs preview GitHub action
EdwardAngert Apr 9, 2025
3010c77
Merge branch 'main' into simplified-docs-preview
EdwardAngert Apr 9, 2025
afbdde9
\Fix tj-actions/changed-files SHA to match existing usage\n\nUpdate t…
EdwardAngert Apr 9, 2025
1f716c9
\Fix docs preview workflow to ensure PR comments are posted\n\nUpdate…
EdwardAngert Apr 9, 2025
38cfd56
\Update preview URL format and add direct doc links\
EdwardAngert Apr 9, 2025
e072e92
Add shared docs GitHub action
EdwardAngert Apr 9, 2025
07e93b0
test: Add heading to docs README
EdwardAngert Apr 9, 2025
6a7a2bc
Add test workflow
EdwardAngert Apr 9, 2025
4fcb322
Unified documentation workflow
EdwardAngert Apr 23, 2025
777bddc
Enhance documentation workflows with cross-reference checking
EdwardAngert Apr 23, 2025
992c592
Enhance PR comment with informative status overview and collapsible s…
8000 EdwardAngert Apr 23, 2025
6420b3f
Optimize workflow logic and improve Vale style checking
EdwardAngert Apr 23, 2025
0a464f3
enhance: optimize workflow with unified reporting and concurrency
EdwardAngert Apr 23, 2025
3840432
refactor: replace linkspector with lychee for link checking
EdwardAngert Apr 23, 2025
b555621
refactor: combine documentation workflow optimizations
EdwardAngert Apr 23, 2025
00a4fb0
fix: address workflow issues for GitHub Actions compatibility
EdwardAngert Apr 23, 2025
ba403f2
docs: update GitHub Actions documentation
EdwardAngert Apr 23, 2025
168b54b
Merge branch 'main' into feature/unified-docs-workflow-combined
EdwardAngert Apr 23, 2025
6a0c1c1
fix: remove duplicate docs example workflows and fix caching issues
EdwardAngert Apr 23, 2025
8a29450
fix: update lychee-action configuration for v1 compatibility
EdwardAngert Apr 23, 2025
e37cda8
fix readme
EdwardAngert Apr 23, 2025
749d142
fix: correct YAML syntax in docs-link-check.yaml
EdwardAngert Apr 23, 2025
90a9ca8
chore: use caret versioning for tj-actions/changed-files
EdwardAngert Apr 23, 2025
bb9e393
fix: update actions and preview URL handling
EdwardAngert Apr 23, 2025
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
Prev Previous commit
Next Next commit
docs: update GitHub Actions documentation
- Add more detailed descriptions of workflow components
- Document status badge generation and thresholds
- Clarify validation options and phases
- Update preview generation details
- Add examples of direct document links
- Improve workflow composite action description

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
  • Loading branch information
EdwardAngert and claude committed Apr 23, 2025
commit ba403f287c92b3fbb0c656c9a9386e7d2a3a3ed2
39 changes: 28 additions & 11 deletions .github/actions/docs-shared/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ runs:
echo "status=success" >> $GITHUB_OUTPUT
echo "result=" >> $GITHUB_OUTPUT

# Setup regex patterns for cross-references (escape special regex characters)
MD_LINK_PATTERN='\[[^\]]+\]\([^)]+\)'
ANCHOR_LINK_PATTERN='\(#[^)]+\)'
# Patterns for matching markdown links and anchors
MD_LINK_PATTERN='\[.*\](.*)'
ANCHOR_LINK_PATTERN='(#[^)]*)'

# Get the base commit to compare against
BASE_SHA=$(git merge-base HEAD origin/main || git rev-parse HEAD~1)
Expand All @@ -474,11 +474,22 @@ runs:

# Check if file exists in commit
if git cat-file -e $commit:$file 2>/dev/null; then
# Extract and process headings with error handling
git show $commit:$file 2>/dev/null | grep -E '^#{1,6} ' |
# Extract and process headings
git show $commit:$file 2>/dev/null | grep '^#' |
while IFS= read -r line; do
echo "$line" | sed 's/^#* //' | tr -d '`' |
tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9 -]//g' | sed 's/ /-/g' || echo ""
# Step-by-step processing for maximum reliability
# 1. Remove initial #s and leading space
cleaned=$(echo "$line" | sed 's/^#* //')
# 2. Remove backticks
cleaned=$(echo "$cleaned" | tr -d '`')
# 3. Convert to lowercase
cleaned=$(echo "$cleaned" | tr '[:upper:]' '[:lower:]')
# 4. Remove special characters
cleaned=$(echo "$cleaned" | sed 's/[^a-z0-9 -]//g')
# 5. Replace spaces with dashes
cleaned=$(echo "$cleaned" | sed 's/ /-/g')
# Output the result
echo "$cleaned"
done
else
echo "File not found in commit: $file@$commit" >&2
Expand Down Expand Up @@ -594,11 +605,17 @@ runs:
echo $CHANGED_FILES | jq -c '.[]' | while read -r file_path; do
file_path=$(echo $file_path | tr -d '"')
if [[ $file_path == ${{ inputs.docs-dir }}/* ]] && [[ $file_path == *.md ]]; then
# Extract path for URL (remove .md and docs/ prefix)
url_path=$(echo "$file_path" | sed 's/^${{ inputs.docs-dir }}\///' | sed 's/\.md$//')
# Extract path for URL using parameter expansion
DOCS_DIR="${{ inputs.docs-dir }}"
# Remove docs dir prefix and .md extension
temp_path="${file_path#$DOCS_DIR/}"
url_path="${temp_path%.md}"

# Generate the full preview URL
doc_url="https://coder.com/docs/@$BRANCH/$url_path"
# Get file title from first heading or filename
title=$(head -20 "$file_path" | grep -m 1 "^# " | sed 's/^# //' || basename "$file_path" .md)

# Get file title from first heading or fallback to filename
title=$(head -20 "$file_path" | grep "^# " | head -1 | cut -c 3- || basename "$file_path" .md)
DOC_LINKS="${DOC_LINKS}- [$title]($doc_url)\n"
fi
done
Expand Down
50 changes: 32 additions & 18 deletions .github/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,28 @@ jobs:
contents: read
pull-requests: write
with:
lint-markdown: true
check-format: true
check-links: true
check-cross-references: true
lint-vale: true
generate-preview: true
post-comment: true
fail-on-error: false
# Validation options
lint-markdown: true # Run markdownlint-cli2
check-format: true # Check markdown table formatting
check-links: true # Check for broken links with lychee
check-cross-references: true # Detect broken internal references
lint-vale: true # Run Vale style checking

# Output options
generate-preview: true # Generate preview URLs
post-comment: true # Post results as PR comment
fail-on-error: false # Continue workflow on validation errors
```

### Post-Merge Link Checking

The `docs-link-check.yaml` workflow runs after merges to main and on a weekly schedule to check for broken links and create GitHub issues automatically:
The `docs-link-check.yaml` workflow runs after merges to main and on a weekly schedule to check for broken links and cross-references:

- Runs after merges to main that affect documentation
- Runs weekly on Monday mornings
- Creates GitHub issues with broken link details
- Sends Slack notifications when issues are found
- Uses lychee for robust link checking
- Detects broken internal cross-references
- Creates GitHub issues with detailed error information and fix guidance

## Features

Expand Down Expand Up @@ -81,40 +85,50 @@ The documentation workflow is designed for maximum efficiency using a phase-base

### Phase 4: Preview Generation
- Generate preview URLs for documentation changes
- Build links to new documentation
- Create direct links to specific changed documents
- Extract document titles from markdown headings

### Phase 5: Results Aggregation
- Collect results from all validation steps
- Normalize into a unified JSON structure
- Calculate success metrics and statistics
- Generate summary badge
- Generate status badge based on success percentage

### Phase 6: PR Comment Management
- Find existing comments or create new ones
- Format results in a user-friendly way
- Provide actionable guidance for fixing issues
- Include direct links to affected documents

## Unified Results Reporting

The workflow now aggregates all validation results into a single JSON structure:
The workflow aggregates all validation results into a single JSON structure:

```json
[
{
"name": "markdown-lint",
"status": "success|failure",
"output": "Raw output from the validation tool",
"name": "Markdown Linting",
"status": "success|failure|warning",
"details": "Details about the validation result",
"guidance": "Human-readable guidance on how to fix",
"fix_command": "Command to run to fix the issue"
},
// Additional validation results...
]
```

### Status Badge Generation

Results are automatically converted to a GitHub-compatible badge:

- ✅ **Passing**: 100% of validations pass
- ⚠️ **Mostly Passing**: ≥80% of validations pass
- ❌ **Failing**: <80% of validations pass

### Benefits of Unified Reporting:

1. **Consistency**: All validation tools report through the same structure
2. **Integration**: JSON output can be easily consumed by other tools or dashboards
2. **Visibility**: Status badge clearly shows overall health at a glance
3. **Statistics**: Automatic calculation of pass/fail rates and success percentages
4. **Diagnostics**: All validation results in one place for easier debugging
5. **Extensibility**: New validators can be added with the same reporting format
Expand Down
2 changes: 1 addition & 1 deletion .github/docs/actions/docs-shared/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Docs Shared Action'
description: 'A composite action providing shared functionality for docs-related workflows'
description: 'A unified, phase-based composite action for documentation validation and reporting'
author: 'Coder'

inputs:
Expand Down
2900
0