Skip to content

feat(cicd/github-actions): implement the "examples" section generation#113

Merged
neilime merged 6 commits intomainfrom
copilot/fix-112
Sep 20, 2025
Merged

feat(cicd/github-actions): implement the "examples" section generation#113
neilime merged 6 commits intomainfrom
copilot/fix-112

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 19, 2025

Implementation of examples section generation for GitHub Actions

Completed Work

  • Explore repository structure and understand existing patterns
  • Understand the SectionIdentifier enum already includes Examples
  • Analyze existing section generators (Usage, Overview) to understand implementation pattern
  • Create ExamplesSectionGenerator following existing patterns
  • Implement examples detection strategy (examples/ folder, destination file)
  • Add version replacement logic for code snippets containing action calls (@sha-xxx # x.x.x format)
  • Register the new generator in container
  • Export the new generator in index.ts
  • Create comprehensive tests for the new functionality
  • Fix failing unit tests (test setup issues)
  • Update integration test snapshots
  • Address PR feedback: use mock-fs instead of manual mocking
  • Address PR feedback: look in destination file instead of README.md
  • Use enum type for Example interface instead of string literal union
  • Remove workflow discovery strategy based on feedback
  • Fix failing CLI snapshot test
  • Update documentation for examples section
  • All tests passing (273 total tests across all packages)

Recent Changes (Documentation Update)

Updated Documentation for Examples Section

  • GitHub Actions Template: Added examples section to the complete template and Available Sections table
  • GitHub Actions Package Documentation: Enhanced description of ExamplesSectionGenerator and added dedicated section explaining:
    • Multiple detection strategies (examples/, .github/examples/, destination file)
    • Supported file formats (YAML, Markdown, destination file content)
    • Automatic version replacement functionality
  • Concise Updates: Focused on essential information without duplicating implementation details

Implementation Summary

Successfully implemented the ExamplesSectionGenerator with the following features:

Multi-Strategy Examples Detection

  1. Examples Directory: Scans examples/ folder for YAML and Markdown files
  2. GitHub Examples: Checks .github/examples/ directory for examples
  3. Destination File: Extracts examples from existing destination file (if it exists)

Examples can be stored in multiple formats:

  • YAML files (.yml/.yaml): Pure code snippets containing workflow examples
  • Markdown files (.md): Rich content with descriptions and/or code snippets
  • Destination file: Existing examples in the documentation being generated (examples section)

Version Replacement Logic

  • Automatically replaces action versions in code snippets
  • Format: @sha-xxx # x.x.x (SHA + tag in comment)
  • Handles both explicit action references and local references (./)
  • Only processes when version information with SHA is available

Testing & Documentation

  • Comprehensive unit tests using mock-fs for reliable file system mocking
  • Integration tests confirm examples section appears in generated documentation
  • All existing tests continue to pass, including updated snapshots
  • Updated documentation templates and package documentation

The examples section is now automatically generated and included in GitHub Actions documentation when examples are found using any of the detection strategies.

Fixes #112.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] feat(cicd/github-actions): implement the "examples" section generation feat(cicd/github-actions): implement the "examples" section generation Sep 19, 2025
Copilot AI requested a review from neilime September 19, 2025 09:37
Copy link
Copy Markdown
Member

@neilime neilime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot handle feedbacks

Comment thread packages/cicd/github-actions/src/section/examples-section-generator.adapter.ts Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 19, 2025

@copilot handle feedbacks

Addressed both feedback items:

  1. Replaced manual fs mocking with mock-fs library
  2. Changed to look in destination file instead of README.md for examples
    All tests are passing (276 tests across all packages). (commit f14c229)

Copy link
Copy Markdown
Member

@neilime neilime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Handle feedbacks

Comment thread packages/cicd/github-actions/src/section/examples-section-generator.adapter.ts Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 19, 2025

@copilot Handle feedbacks

Addressed the feedback to use enum type for the Example interface. Created ExampleType enum and updated all code to use enum values instead of string literals. All tests are passing (158 tests in GitHub Actions package). (commit 49ed84e)

Copilot AI and others added 4 commits September 19, 2025 21:01
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
…mples

Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
Copy link
Copy Markdown
Member

@neilime neilime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot handle feedback

Comment thread packages/cicd/github-actions/src/section/examples-section-generator.adapter.ts Outdated
@neilime neilime marked this pull request as ready for review September 19, 2025 19:13
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 19, 2025

@copilot handle feedback

Addressed both feedback items:

  1. Removed the workflow discovery strategy as requested
  2. Updated examples documentation to clearly explain the three supported sources (YAML files, Markdown files, destination file)
    All tests continue to pass (158 tests in GitHub Actions package). (commit eaa6e67)

Copy link
Copy Markdown
Member

@neilime neilime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Fix failing tests

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot Fix failing tests

Fixed the failing CLI snapshot test. The issue was that after removing the workflow discovery strategy, the CLI was generating different example content, causing the snapshot to be outdated. Updated the snapshot and all 273 tests across all packages now pass. (commit bb2c1ab)

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 20, 2025

Codecov Report

❌ Patch coverage is 78.48101% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.14%. Comparing base (225e95a) to head (85fdfa2).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
.../src/section/examples-section-generator.adapter.ts 78.44% 50 Missing ⚠️
packages/cicd/github-actions/src/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #113      +/-   ##
==========================================
- Coverage   86.56%   86.14%   -0.43%     
==========================================
  Files          70       71       +1     
  Lines        4303     4540     +237     
  Branches      963     1010      +47     
==========================================
+ Hits         3725     3911     +186     
- Misses        569      620      +51     
  Partials        9        9              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@neilime neilime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update documentation for related changes in packages/docs/content. Be concise.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot update documentation for related changes in packages/docs/content. Be concise.

Updated documentation for the examples section implementation:

GitHub Actions Template: Added examples section to template and Available Sections table

GitHub Actions Package Docs: Enhanced ExamplesSectionGenerator description with details on detection strategies (examples/, .github/examples/, destination file), supported formats (YAML, Markdown), and version replacement functionality

(commit b0e870a)

Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
@neilime neilime merged commit 44b3c2c into main Sep 20, 2025
25 checks passed
@neilime neilime deleted the copilot/fix-112 branch September 20, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cicd/github-actions): implement the "examples" section generation

3 participants