Skip to content

Commit 2887857

Browse files
theletterfv1vycombinator
authored
Add validation script for docs generation (#11411)
* Add validation script for docs generation * Apply suggestions from code review Co-authored-by: Victor Martinez <[email protected]> * Move check to makefile * Update .github/workflows/validate-docs-structure.yml Co-authored-by: Victor Martinez <[email protected]> * Use magefile * Add make mage * Remove makefile target * Remove trailing space * Add target dependency --------- Co-authored-by: Victor Martinez <[email protected]> Co-authored-by: Shaunak Kashyap <[email protected]>
1 parent b1d4e25 commit 2887857

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Validate docs generation structure
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'internal/edot/**'
7+
- 'internal/pkg/otel/**'
8+
- '.github/workflows/validate-docs-structure.yml'
9+
10+
jobs:
11+
validate-structure:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v6
18+
with:
19+
go-version-file: 'go.mod'
20+
21+
- name: Install mage
22+
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3.1.0
23+
with:
24+
install-only: true
25+
26+
- name: Validate expected files for docs generation
27+
run: mage check:docsFiles
28+

magefile.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ func (Build) TestBinaries() error {
450450
return nil
451451
}
452452

453-
// All run all the code checks.
453+
// All run all the code and docs checks.
454454
func (Check) All() {
455-
mg.SerialDeps(Check.License, Integration.Check)
455+
mg.SerialDeps(Check.License, Integration.Check, Check.DocsFiles)
456456
}
457457

458458
// License makes sure that all the Golang files have the appropriate license header.
@@ -462,6 +462,40 @@ func (Check) License() error {
462462
return sh.RunV("go-licenser", "-d", "-license", "Elasticv2")
463463
}
464464

465+
// DocsFiles validates that files required by the docs generation script exist.
466+
func (Check) DocsFiles() error {
467+
fmt.Println("Validating files required by docs/scripts/update-docs/update-components-docs.py")
468+
469+
requiredFiles := []string{
470+
"go.mod",
471+
"internal/pkg/otel/components.yml",
472+
"internal/pkg/otel/samples/linux/gateway.yml",
473+
}
474+
475+
missing := false
476+
for _, file := range requiredFiles {
477+
if _, err := os.Stat(file); os.IsNotExist(err) {
478+
fmt.Printf("❌ Missing: %s\n", file)
479+
missing = true
480+
} else {
481+
fmt.Printf("✅ Found: %s\n", file)
482+
}
483+
}
484+
485+
if missing {
486+
fmt.Println()
487+
return fmt.Errorf("one or more files required by the docs generation script are missing.\n" +
488+
"If these files were intentionally moved, please update:\n" +
489+
" - docs/scripts/update-docs/update-components-docs.py\n" +
490+
" - magefile.go (Check.DocsFiles function)\n" +
491+
" - .github/workflows/validate-docs-structure.yml")
492+
}
493+
494+
fmt.Println()
495+
fmt.Println("✅ All required files are present.")
496+
return nil
497+
}
498+
465499
// Changes run git status --porcelain and return an error if we have changes or uncommitted files.
466500
func (Check) Changes() error {
467501
out, err := sh.Output("git", "status", "--porcelain")

0 commit comments

Comments
 (0)