| 1 | package App::GHGen; | ||
| 2 | |||
| 3 | # Try this to update GitHub Marketplace release, but bear in mind it tends to not work, marketplace does not detect the update | ||
| 4 | # Update the @v1 to @v2 in action.yml | ||
| 5 | # git tag -a v2 -m 'Release v0.02' | ||
| 6 | # git push origin v2 | ||
| 7 | # Go to https://github.com/nigelhorne/App-GHGen/releases | ||
| 8 | # Click 'Draft a new release' | ||
| 9 | # Choose the new tag: v2 | ||
| 10 | # Commit release v2 | ||
| 11 | # Publish the release | ||
| 12 | |||
| 13 | 58 | ▶ | use v5.36; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 58 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 58 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | =encoding utf-8 | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | App::GHGen - GitHub Actions workflow generator, analyzer, and optimizer | ||
| 22 | |||
| 23 | =head1 VERSION | ||
| 24 | |||
| 25 | Version 0.13 | ||
| 26 | |||
| 27 | =cut | ||
| 28 | |||
| 29 | 58 | our $VERSION = '0.13'; | |
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | # Generate workflows | ||
| 34 | ghgen generate --auto # Auto-detect project type | ||
| 35 | ghgen generate --type=perl # Generate Perl workflow | ||
| 36 | ghgen generate --type=perl --customize # Interactive customization | ||
| 37 | ghgen generate --interactive # Choose type interactively | ||
| 38 | ghgen generate --type=perl --os=linux,macos # Skip Windows jobs | ||
| 39 | ghgen generate --type=node --versions=20,22 # Choose versions tested | ||
| 40 | ghgen generate --type=perl --timeout=45 # Job timeout in minutes | ||
| 41 | |||
| 42 | # Analyze workflows | ||
| 43 | ghgen analyze # Analyze for issues | ||
| 44 | ghgen analyze --fix # Auto-fix issues | ||
| 45 | ghgen analyze --estimate # Show cost estimates | ||
| 46 | |||
| 47 | # List available types | ||
| 48 | ghgen generate --list | ||
| 49 | |||
| 50 | =head1 DESCRIPTION | ||
| 51 | |||
| 52 | GHGen Workflow Analyzer is the all-in-one solution for keeping your GitHub Actions fast, | ||
| 53 | secure, and effortlessly up-to-date. | ||
| 54 | It automatically scans your workflows for performance bottlenecks, | ||
| 55 | outdated actions, | ||
| 56 | missing security permissions, and wasted CI minutes-then applies safe, intelligent fixes or opens a clean pull request with improvements. | ||
| 57 | Whether you maintain a single project or dozens, | ||
| 58 | GHGen saves time, reduces CI costs, and enforces modern best practices without manual effort. | ||
| 59 | Developers choose it because it turns workflow maintenance from a chore into a fully automated, | ||
| 60 | reliable part of their development pipeline. | ||
| 61 | |||
| 62 | =head2 Key Features | ||
| 63 | |||
| 64 | =over 4 | ||
| 65 | |||
| 66 | =item * B<Auto-detect project type> - Intelligently scans your repository to detect language and dependencies | ||
| 67 | |||
| 68 | =item * B<Generate optimized workflows> - Creates workflows with caching, security, concurrency, and best practices built-in | ||
| 69 | |||
| 70 | =item * B<Analyze existing workflows> - Comprehensive analysis for performance, security, cost, and maintenance issues | ||
| 71 | |||
| 72 | =item * B<Auto-fix issues> - Automatically applies fixes for detected problems (adds caching, updates versions, adds permissions, etc.) | ||
| 73 | |||
| 74 | =item * B<Interactive customization> - Guided workflow creation with smart defaults and multi-select options | ||
| 75 | |||
| 76 | =item * B<Cost estimation> - Estimates current CI minutes usage and calculates potential savings from optimizations | ||
| 77 | |||
| 78 | =item * B<GitHub Action integration> - Run as a GitHub Action to analyze PRs, comment with suggestions, and create fix PRs | ||
| 79 | |||
| 80 | =item * B<Per-workflow breakdown> - Detailed analysis of each workflow's cost and optimization potential | ||
| 81 | |||
| 82 | =back | ||
| 83 | |||
| 84 | =head1 INSTALLATION | ||
| 85 | |||
| 86 | =head2 From CPAN | ||
| 87 | |||
| 88 | cpanm App::GHGen | ||
| 89 | |||
| 90 | =head2 From Source | ||
| 91 | |||
| 92 | git clone https://github.com/nigelhorne/App-GHGen.git | ||
| 93 | cd ghgen | ||
| 94 | cpanm --installdeps . | ||
| 95 | perl Makefile.PL | ||
| 96 | make | ||
| 97 | make test | ||
| 98 | make install | ||
| 99 | |||
| 100 | =head2 Quick Install Script | ||
| 101 | |||
| 102 | curl -L https://cpanmin.us | perl - App::GHGen | ||
| 103 | |||
| 104 | =head1 QUICK START | ||
| 105 | |||
| 106 | The fastest way to get started: | ||
| 107 | |||
| 108 | # Navigate to your project | ||
| 109 | cd my-project/ | ||
| 110 | |||
| 111 | # Auto-detect and generate workflow | ||
| 112 | ghgen generate --auto | ||
| 113 | |||
| 114 | # Review the generated workflow | ||
| 115 | cat .github/workflows/*-ci.yml | ||
| 116 | |||
| 117 | # Commit and push | ||
| 118 | git add .github/workflows/ | ||
| 119 | git commit -m "Add CI workflow" | ||
| 120 | git push | ||
| 121 | |||
| 122 | That's it! GHGen will detect your project type and create an optimized workflow. | ||
| 123 | |||
| 124 | =head1 WORKFLOW GENERATION | ||
| 125 | |||
| 126 | =head2 Auto-Detection | ||
| 127 | |||
| 128 | GHGen can automatically detect your project type by scanning for indicator files: | ||
| 129 | |||
| 130 | ghgen generate --auto | ||
| 131 | |||
| 132 | Detection looks for: | ||
| 133 | |||
| 134 | =over 4 | ||
| 135 | |||
| 136 | =item * B<Perl>: cpanfile, dist.ini, Makefile.PL, Build.PL, lib/*.pm | ||
| 137 | |||
| 138 | =item * B<Node.js>: package.json, package-lock.json, yarn.lock | ||
| 139 | |||
| 140 | =item * B<Python>: requirements.txt, setup.py, pyproject.toml | ||
| 141 | |||
| 142 | =item * B<Rust>: Cargo.toml, Cargo.lock | ||
| 143 | |||
| 144 | =item * B<Go>: go.mod, go.sum | ||
| 145 | |||
| 146 | =item * B<Ruby>: Gemfile, Rakefile | ||
| 147 | |||
| 148 | =item * B<Docker>: Dockerfile, docker-compose.yml | ||
| 149 | |||
| 150 | =back | ||
| 151 | |||
| 152 | If multiple types are detected, it shows alternatives: | ||
| 153 | |||
| 154 | [ok] Detected project type: PERL | ||
| 155 | Evidence: cpanfile, lib, t | ||
| 156 | |||
| 157 | Other possibilities: | ||
| 158 | - docker (confidence: 65%) | ||
| 159 | |||
| 160 | Generate PERL workflow? [Y/n]: | ||
| 161 | |||
| 162 | =head2 Specify Project Type | ||
| 163 | |||
| 164 | Generate for a specific language: | ||
| 165 | |||
| 166 | ghgen generate --type=perl | ||
| 167 | ghgen generate --type=node | ||
| 168 | ghgen generate --type=python | ||
| 169 | ghgen generate --type=rust | ||
| 170 | ghgen generate --type=go | ||
| 171 | ghgen generate --type=ruby | ||
| 172 | ghgen generate --type=docker | ||
| 173 | ghgen generate --type=static | ||
| 174 | |||
| 175 | =head2 Choosing Operating Systems and Versions | ||
| 176 | |||
| 177 | C<--os> restricts the operating systems of a Perl workflow and C<--versions> | ||
| 178 | chooses the language versions tested. Both take comma-separated lists. | ||
| 179 | |||
| 180 | ghgen generate --type=perl --os=linux,macos | ||
| 181 | ghgen generate --type=perl --versions=5.40,5.42 | ||
| 182 | ghgen generate --type=python --versions=3.12,3.13 | ||
| 183 | |||
| 184 | C<--os> accepts C<linux>, C<macos> and C<windows> (case-insensitive, with | ||
| 185 | C<ubuntu> as an alias for C<linux>) or a literal runner label such as | ||
| 186 | C<ubuntu-22.04>. The default is C<linux,macos,windows>. | ||
| 187 | |||
| 188 | C<--versions> replaces the version matrix. The defaults are: | ||
| 189 | |||
| 190 | =over 4 | ||
| 191 | |||
| 192 | =item * perl 5.36, 5.38, 5.40, 5.42 | ||
| 193 | |||
| 194 | =item * node 18.x, 20.x, 22.x | ||
| 195 | |||
| 196 | =item * python 3.9, 3.10, 3.11, 3.12 | ||
| 197 | |||
| 198 | =item * ruby 3.1, 3.2, 3.3 | ||
| 199 | |||
| 200 | =item * java 11, 17, 21 | ||
| 201 | |||
| 202 | =item * php 8.1, 8.2, 8.3 | ||
| 203 | |||
| 204 | =item * go 1.22 (a single version; C<--versions> turns it into a matrix) | ||
| 205 | |||
| 206 | =item * rust stable (a single toolchain; C<--versions> turns it into a matrix) | ||
| 207 | |||
| 208 | =back | ||
| 209 | |||
| 210 | C<--versions> has no effect for C<cpp>, C<docker> and C<static>; a warning is | ||
| 211 | printed. A value may contain only letters, digits and C<. + * - _>. | ||
| 212 | |||
| 213 | =head2 Interactive Mode | ||
| 214 | |||
| 215 | Choose from a menu of available types: | ||
| 216 | |||
| 217 | ghgen generate --interactive | ||
| 218 | |||
| 219 | GitHub Actions Workflow Generator | ||
| 220 | ================================================== | ||
| 221 | |||
| 222 | Select a project type: | ||
| 223 | |||
| 224 | 1. Node.js/npm | ||
| 225 | 2. Python | ||
| 226 | 3. Rust | ||
| 227 | 4. Go | ||
| 228 | 5. Ruby | ||
| 229 | 6. Perl | ||
| 230 | 7. Docker | ||
| 231 | 8. Static site (GitHub Pages) | ||
| 232 | |||
| 233 | Enter number (1-8): | ||
| 234 | |||
| 235 | =head2 Interactive Customization | ||
| 236 | |||
| 237 | Customize workflows with guided prompts: | ||
| 238 | |||
| 239 | ghgen generate --type=perl --customize | ||
| 240 | |||
| 241 | For Perl, you'll be asked: | ||
| 242 | |||
| 243 | =over 4 | ||
| 244 | |||
| 245 | =item * B<Perl versions to test> - Select from 5.22 through 5.42 (multi-select with defaults) | ||
| 246 | |||
| 247 | =item * B<Operating systems> - Ubuntu, macOS, Windows (multi-select) | ||
| 248 | |||
| 249 | =item * B<Enable syntax linting> - C<perl -c> check on all C<.pm> files, run across every matrix cell; requires no extra CPAN modules (yes/no, default: yes) | ||
| 250 | |||
| 251 | =item * B<Enable unused-variable check> - C<warnings::unused> check, latest Perl + Ubuntu only (yes/no, default: no) | ||
| 252 | |||
| 253 | =item * B<Enable Perl::Critic> - Code quality analysis, latest Perl + Ubuntu only (yes/no, default: yes) | ||
| 254 | |||
| 255 | =item * B<Enable Devel::Cover> - Test coverage, latest Perl + Ubuntu only (yes/no, default: yes) | ||
| 256 | |||
| 257 | =item * B<Branch configuration> - Which branches to run on | ||
| 258 | |||
| 259 | =back | ||
| 260 | |||
| 261 | Example session: | ||
| 262 | |||
| 263 | === Workflow Customization: PERL === | ||
| 264 | |||
| 265 | Perl Versions to Test: | ||
| 266 | Which Perl versions? | ||
| 267 | (Enter numbers separated by commas, or 'all') | ||
| 268 | [ok] 1. 5.40 | ||
| 269 | [ok] 2. 5.38 | ||
| 270 | [ok] 3. 5.36 | ||
| 271 | 4. 5.34 | ||
| 272 | 5. 5.32 | ||
| 273 | |||
| 274 | Enter choices [1,2,3]: 1,2,3 | ||
| 275 | |||
| 276 | Operating Systems: | ||
| 277 | Which operating systems? | ||
| 278 | [ok] 1. ubuntu-latest | ||
| 279 | [ok] 2. macos-latest | ||
| 280 | [ok] 3. windows-latest | ||
| 281 | |||
| 282 | Enter choices [1,2,3]: 1,2 | ||
| 283 | |||
| 284 | Code Quality Tools: | ||
| 285 | Enable syntax linting (perl -c on all matrix cells)? [Y/n]: y | ||
| 286 | |||
| 287 | Enable unused-variable check (warnings::unused, latest+ubuntu only)? [y/N]: n | ||
| 288 | |||
| 289 | Enable Perl::Critic? [Y/n]: y | ||
| 290 | Enable test coverage? [Y/n]: y | ||
| 291 | |||
| 292 | Each language has its own customization options appropriate to its ecosystem. | ||
| 293 | |||
| 294 | =head2 List Available Types | ||
| 295 | |||
| 296 | See all supported project types: | ||
| 297 | |||
| 298 | ghgen generate --list | ||
| 299 | |||
| 300 | Available workflow templates: | ||
| 301 | |||
| 302 | node - Node.js/npm projects with testing and linting | ||
| 303 | python - Python projects with pytest and coverage | ||
| 304 | rust - Rust projects with cargo, clippy, and formatting | ||
| 305 | go - Go projects with testing and race detection | ||
| 306 | ruby - Ruby projects with bundler and rake | ||
| 307 | perl - Perl projects with cpanm, prove, and coverage | ||
| 308 | docker - Docker image build and push workflow | ||
| 309 | static - Static site deployment to GitHub Pages | ||
| 310 | |||
| 311 | =head1 WORKFLOW ANALYSIS | ||
| 312 | |||
| 313 | =head2 Basic Analysis | ||
| 314 | |||
| 315 | Scan all workflows in your repository for issues: | ||
| 316 | |||
| 317 | ghgen analyze | ||
| 318 | |||
| 319 | GitHub Actions Workflow Analyzer | ||
| 320 | ================================================== | ||
| 321 | |||
| 322 | [file] Analyzing: perl-ci.yml | ||
| 323 | [warn] No dependency caching found - increases build times | ||
| 324 | [tip] Fix: | ||
| 325 | - uses: actions/cache@v5 | ||
| 326 | with: | ||
| 327 | path: ~/perl5 | ||
| 328 | key: ${{ runner.os }}-${{ matrix.perl }}-${{ hashFiles('cpanfile') }} | ||
| 329 | |||
| 330 | [warn] Found 2 outdated action(s) | ||
| 331 | [tip] Fix: | ||
| 332 | Update to latest versions: | ||
| 333 | actions/cache@v4 -> actions/cache@v5 | ||
| 334 | |||
| 335 | ================================================== | ||
| 336 | Summary: | ||
| 337 | Workflows analyzed: 1 | ||
| 338 | Total issues found: 2 | ||
| 339 | |||
| 340 | The analyzer checks for: | ||
| 341 | |||
| 342 | =over 4 | ||
| 343 | |||
| 344 | =item * B<Performance Issues> | ||
| 345 | |||
| 346 | =over 8 | ||
| 347 | |||
| 348 | =item - Missing dependency caching (npm, pip, cargo, go, bundler, cpanm) | ||
| 349 | |||
| 350 | =item - Jobs that could run in parallel | ||
| 351 | |||
| 352 | =back | ||
| 353 | |||
| 354 | =item * B<Security Issues> | ||
| 355 | |||
| 356 | =over 8 | ||
| 357 | |||
| 358 | =item - Unpinned action versions (@master, @main) | ||
| 359 | |||
| 360 | =item - Missing permissions declarations | ||
| 361 | |||
| 362 | =item - Overly broad permissions (contents: write when read is sufficient) | ||
| 363 | |||
| 364 | =back | ||
| 365 | |||
| 366 | =item * B<Cost Issues> | ||
| 367 | |||
| 368 | =over 8 | ||
| 369 | |||
| 370 | =item - Missing concurrency controls (wasted CI on superseded runs) | ||
| 371 | |||
| 372 | =item - Overly broad triggers (runs on every push without filters) | ||
| 373 | |||
| 374 | =item - Inefficient matrix strategies | ||
| 375 | |||
| 376 | =back | ||
| 377 | |||
| 378 | =item * B<Maintenance Issues> | ||
| 379 | |||
| 380 | =over 8 | ||
| 381 | |||
| 382 | =item - Outdated action versions (v4 -> v5, v5 -> v6) | ||
| 383 | |||
| 384 | =item - Outdated runner versions (ubuntu-18.04 -> ubuntu-latest) | ||
| 385 | |||
| 386 | =back | ||
| 387 | |||
| 388 | =back | ||
| 389 | |||
| 390 | =head2 Auto-Fix | ||
| 391 | |||
| 392 | Automatically apply fixes to your workflows: | ||
| 393 | |||
| 394 | ghgen analyze --fix | ||
| 395 | |||
| 396 | GitHub Actions Workflow Analyzer | ||
| 397 | (Auto-fix mode enabled) | ||
| 398 | ================================================== | ||
| 399 | |||
| 400 | [file] Analyzing: perl-ci.yml | ||
| 401 | [fix] Applying 3 fix(es)... | ||
| 402 | [ok] Applied 3 fix(es) | ||
| 403 | |||
| 404 | ================================================== | ||
| 405 | Summary: | ||
| 406 | Workflows analyzed: 1 | ||
| 407 | Total issues found: 3 | ||
| 408 | Fixes applied: 3 | ||
| 409 | |||
| 410 | Auto-fix can: | ||
| 411 | |||
| 412 | =over 4 | ||
| 413 | |||
| 414 | =item * B<Add caching> - Detects project type and adds appropriate dependency caching | ||
| 415 | |||
| 416 | =item * B<Update actions> - Updates to latest versions (cache@v4->v5, checkout@v5->v6, etc.) | ||
| 417 | |||
| 418 | =item * B<Pin versions> - Converts @master/@main to specific version tags | ||
| 419 | |||
| 420 | =item * B<Add permissions> - Adds C<permissions: contents: read> for security | ||
| 421 | |||
| 422 | =item * B<Add concurrency> - Adds concurrency groups to cancel superseded runs | ||
| 423 | |||
| 424 | =item * B<Optimize triggers> - Adds branch and path filters | ||
| 425 | |||
| 426 | =item * B<Update runners> - Changes ubuntu-18.04 to ubuntu-latest | ||
| 427 | |||
| 428 | =back | ||
| 429 | |||
| 430 | The auto-fix feature is safe: | ||
| 431 | |||
| 432 | =over 4 | ||
| 433 | |||
| 434 | =item * Only fixes well-understood issues | ||
| 435 | |||
| 436 | =item * Preserves YAML structure and comments | ||
| 437 | |||
| 438 | =item * Changes are easily reviewable with C<git diff> | ||
| 439 | |||
| 440 | =item * Can be reverted if needed | ||
| 441 | |||
| 442 | =back | ||
| 443 | |||
| 444 | =head2 Cost Estimation | ||
| 445 | |||
| 446 | See your current CI usage and potential savings: | ||
| 447 | |||
| 448 | ghgen analyze --estimate | ||
| 449 | |||
| 450 | GitHub Actions Workflow Analyzer | ||
| 451 | (Cost estimation mode) | ||
| 452 | ================================================== | ||
| 453 | |||
| 454 | [stats] Estimating current CI usage... | ||
| 455 | |||
| 456 | Current Monthly Usage: | ||
| 457 | Total CI minutes: 1,247 | ||
| 458 | Billable minutes: 0 (after 2,000 free tier) | ||
| 459 | Estimated cost: $0.00 | ||
| 460 | |||
| 461 | Per-Workflow Breakdown: | ||
| 462 | Perl CI 840 min/month (100 runs x 8.4 min/run) | ||
| 463 | Node.js CI 300 min/month ( 60 runs x 5.0 min/run) | ||
| 464 | Docker 107 min/month ( 20 runs x 5.4 min/run) | ||
| 465 | |||
| 466 | [file] Analyzing: node-ci.yml | ||
| 467 | [warn] No dependency caching found | ||
| 468 | [warn] No concurrency group defined | ||
| 469 | |||
| 470 | ================================================== | ||
| 471 | Summary: | ||
| 472 | Workflows analyzed: 3 | ||
| 473 | Total issues found: 2 | ||
| 474 | |||
| 475 | [savings] Potential Savings: | ||
| 476 | With recommended changes: 647 CI minutes/month | ||
| 477 | Reduction: -600 minutes (48%) | ||
| 478 | Cost savings: $4.80/month (for private repos) | ||
| 479 | |||
| 480 | Breakdown: | ||
| 481 | - Adding dependency caching: ~75 min/month | ||
| 482 | - Adding concurrency controls: ~525 min/month | ||
| 483 | |||
| 484 | The cost estimator considers: | ||
| 485 | |||
| 486 | =over 4 | ||
| 487 | |||
| 488 | =item * Workflow trigger frequency (push, PR, schedule) | ||
| 489 | |||
| 490 | =item * Estimated duration per run (based on steps and commands) | ||
| 491 | |||
| 492 | =item * Matrix build multipliers (e.g., 3 OS x 8 Perl versions = 24 jobs) | ||
| 493 | |||
| 494 | =item * Parallel vs sequential job execution | ||
| 495 | |||
| 496 | =item * GitHub Actions pricing ($0.008/minute for private repos, 2000 free minutes/month) | ||
| 497 | |||
| 498 | =back | ||
| 499 | |||
| 500 | =head1 GITHUB ACTION INTEGRATION | ||
| 501 | |||
| 502 | Use GHGen as a GitHub Action to analyze workflows automatically. | ||
| 503 | |||
| 504 | =head2 Mode 1: Comment on Pull Requests | ||
| 505 | |||
| 506 | Automatically comment on PRs that modify workflows: | ||
| 507 | |||
| 508 | # .github/workflows/ghgen-comment.yml | ||
| 509 | name: Analyze Workflows | ||
| 510 | |||
| 511 | on: | ||
| 512 | pull_request: | ||
| 513 | paths: | ||
| 514 | - '.github/workflows/**' | ||
| 515 | |||
| 516 | permissions: | ||
| 517 | contents: read | ||
| 518 | pull-requests: write | ||
| 519 | |||
| 520 | jobs: | ||
| 521 | analyze: | ||
| 522 | runs-on: ubuntu-latest | ||
| 523 | steps: | ||
| 524 | - uses: actions/checkout@v6 | ||
| 525 | - uses: nigelhorne/App-GHGen@v1 | ||
| 526 | with: | ||
| 527 | github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| 528 | mode: comment | ||
| 529 | |||
| 530 | This posts a comment like: | ||
| 531 | |||
| 532 | ## [search] GHGen Workflow Analysis | ||
| 533 | |||
| 534 | | Category | Count | Auto-fixable | | ||
| 535 | |----------|-------|--------------| | ||
| 536 | | [fast] Performance | 2 | 2 | | ||
| 537 | | [lock] Security | 1 | 1 | | ||
| 538 | |||
| 539 | ### [savings] Potential Savings | ||
| 540 | - [time] Save **~650 CI minutes/month** | ||
| 541 | - [cost] Save **~$5/month** (private repos) | ||
| 542 | |||
| 543 | ### [tip] How to Fix | ||
| 544 | Run locally: `ghgen analyze --fix` | ||
| 545 | |||
| 546 | =head2 Mode 2: Auto-Fix with Pull Request | ||
| 547 | |||
| 548 | Automatically create PRs with fixes on a schedule: | ||
| 549 | |||
| 550 | # .github/workflows/ghgen-autofix.yml | ||
| 551 | name: Weekly Workflow Optimization | ||
| 552 | |||
| 553 | on: | ||
| 554 | schedule: | ||
| 555 | - cron: '0 9 * * 1' # Monday 9am UTC | ||
| 556 | workflow_dispatch: # Manual trigger | ||
| 557 | |||
| 558 | permissions: | ||
| 559 | contents: write | ||
| 560 | pull-requests: write | ||
| 561 | |||
| 562 | jobs: | ||
| 563 | optimize: | ||
| 564 | runs-on: ubuntu-latest | ||
| 565 | steps: | ||
| 566 | - uses: actions/checkout@v6 | ||
| 567 | - uses: nigelhorne/App-GHGen@v1 | ||
| 568 | with: | ||
| 569 | github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| 570 | auto-fix: true | ||
| 571 | create-pr: true | ||
| 572 | |||
| 573 | This creates a PR titled "[bot] Optimize GitHub Actions workflows" with all fixes applied. | ||
| 574 | |||
| 575 | =head2 Mode 3: CI Quality Gate | ||
| 576 | |||
| 577 | Fail builds if workflow issues are found: | ||
| 578 | |||
| 579 | # .github/workflows/ghgen-check.yml | ||
| 580 | name: Workflow Quality Check | ||
| 581 | |||
| 582 | on: | ||
| 583 | pull_request: | ||
| 584 | paths: | ||
| 585 | - '.github/workflows/**' | ||
| 586 | |||
| 587 | permissions: | ||
| 588 | contents: read | ||
| 589 | |||
| 590 | jobs: | ||
| 591 | check: | ||
| 592 | runs-on: ubuntu-latest | ||
| 593 | steps: | ||
| 594 | - uses: actions/checkout@v6 | ||
| 595 | - uses: nigelhorne/App-GHGen@v1 | ||
| 596 | id: check | ||
| 597 | - name: Fail if issues found | ||
| 598 | if: steps.check.outputs.issues-found > 0 | ||
| 599 | run: | | ||
| 600 | echo "Found ${{ steps.check.outputs.issues-found }} issues" | ||
| 601 | exit 1 | ||
| 602 | |||
| 603 | =head1 SUPPORTED LANGUAGES | ||
| 604 | |||
| 605 | =head2 Perl | ||
| 606 | |||
| 607 | Comprehensive Perl testing with modern best practices. | ||
| 608 | |||
| 609 | B<Features:> | ||
| 610 | |||
| 611 | =over 4 | ||
| 612 | |||
| 613 | =item * Multi-OS testing (Ubuntu, macOS, Windows) | ||
| 614 | |||
| 615 | =item * Multiple Perl versions (5.22 through 5.42, customizable) | ||
| 616 | |||
| 617 | =item * Smart minimum-version detection from cpanfile, Makefile.PL, or dist.ini | ||
| 618 | |||
| 619 | =item * CPAN module caching with local::lib | ||
| 620 | |||
| 621 | =item * B<Syntax linting> with C<perl -c> across every matrix cell - catches compile-time errors on every tested OS and Perl version with no extra CPAN dependencies | ||
| 622 | |||
| 623 | =item * Optional B<unused-variable check> via L<warnings::unused> (latest Perl + Ubuntu only) | ||
| 624 | |||
| 625 | =item * Perl::Critic integration for code quality (latest Perl + Ubuntu only) | ||
| 626 | |||
| 627 | =item * Devel::Cover for test coverage (latest Perl + Ubuntu only) | ||
| 628 | |||
| 629 | =item * Proper environment variables (AUTOMATED_TESTING, NO_NETWORK_TESTING, NONINTERACTIVE_TESTING) | ||
| 630 | |||
| 631 | =item * Cross-platform compatibility (C<shell: perl {0}> for linting; bash/cmd for tests) | ||
| 632 | |||
| 633 | =back | ||
| 634 | |||
| 635 | B<Example:> | ||
| 636 | |||
| 637 | ghgen generate --type=perl --customize | ||
| 638 | |||
| 639 | B<Generated workflow step order:> | ||
| 640 | |||
| 641 | =over 4 | ||
| 642 | |||
| 643 | =item 1. C<actions/checkout@v6> | ||
| 644 | |||
| 645 | =item 2. Setup Perl - C<shogo82148/actions-setup-perl@v1.44.5> | ||
| 646 | |||
| 647 | =item 3. Cache CPAN modules - C<actions/cache@v5> | ||
| 648 | |||
| 649 | =item 4. Install cpanm and C<local::lib> | ||
| 650 | |||
| 651 | =item 5. Install project dependencies | ||
| 652 | |||
| 653 | =item 6. B<Lint and syntax check> - all matrix cells (enabled by default) | ||
| 654 | |||
| 655 | =item 7. Run tests | ||
| 656 | |||
| 657 | =item 8. B<Check for unused variables> - latest Perl + Ubuntu only (opt-in) | ||
| 658 | |||
| 659 | =item 9. Run Perl::Critic - latest Perl + Ubuntu only (enabled by default) | ||
| 660 | |||
| 661 | =item 10. Test coverage - latest Perl + Ubuntu only (enabled by default) | ||
| 662 | |||
| 663 | =item 11. Show cpanm build log on failure | ||
| 664 | |||
| 665 | =back | ||
| 666 | |||
| 667 | B<Workflow-level features:> | ||
| 668 | |||
| 669 | =over 4 | ||
| 670 | |||
| 671 | =item * Security C<permissions: contents: read> | ||
| 672 | |||
| 673 | =item * Concurrency group cancels superseded runs | ||
| 674 | |||
| 675 | =item * C<fail-fast: false> so every matrix cell completes | ||
| 676 | |||
| 677 | =back | ||
| 678 | |||
| 679 | =head2 Node.js | ||
| 680 | |||
| 681 | Modern Node.js workflows with npm/yarn/pnpm support. | ||
| 682 | |||
| 683 | B<Features:> | ||
| 684 | |||
| 685 | =over 4 | ||
| 686 | |||
| 687 | =item * Multiple Node.js versions (18.x, 20.x, 22.x) | ||
| 688 | |||
| 689 | =item * Package manager selection (npm, yarn, pnpm) | ||
| 690 | |||
| 691 | =item * Dependency caching (~/.npm, ~/.yarn, ~/.pnpm) | ||
| 692 | |||
| 693 | =item * Optional linting (ESLint) | ||
| 694 | |||
| 695 | =item * Optional build step | ||
| 696 | |||
| 697 | =item * Lock file hash-based cache keys | ||
| 698 | |||
| 699 | =back | ||
| 700 | |||
| 701 | B<Customization options:> | ||
| 702 | |||
| 703 | =over 4 | ||
| 704 | |||
| 705 | =item * Node.js versions to test | ||
| 706 | |||
| 707 | =item * Package manager preference | ||
| 708 | |||
| 709 | =item * Enable/disable linting | ||
| 710 | |||
| 711 | =item * Enable/disable build step | ||
| 712 | |||
| 713 | =back | ||
| 714 | |||
| 715 | =head2 Python | ||
| 716 | |||
| 717 | Python testing with virtual environment support. | ||
| 718 | |||
| 719 | B<Features:> | ||
| 720 | |||
| 721 | =over 4 | ||
| 722 | |||
| 723 | =item * Multiple Python versions (3.9, 3.10, 3.11, 3.12, 3.13) | ||
| 724 | |||
| 725 | =item * pip caching (~/.cache/pip) | ||
| 726 | |||
| 727 | =item * flake8 linting | ||
| 728 | |||
| 729 | =item * pytest with coverage | ||
| 730 | |||
| 731 | =item * Optional black formatter checking | ||
| 732 | |||
| 733 | =item * requirements.txt hash-based cache | ||
| 734 | |||
| 735 | =back | ||
| 736 | |||
| 737 | =head2 Rust | ||
| 738 | |||
| 739 | Rust workflows with cargo, clippy, and formatting. | ||
| 740 | |||
| 741 | B<Features:> | ||
| 742 | |||
| 743 | =over 4 | ||
| 744 | |||
| 745 | =item * Cargo registry and target caching | ||
| 746 | |||
| 747 | =item * cargo fmt formatting check | ||
| 748 | |||
| 749 | =item * Clippy linting with -D warnings | ||
| 750 | |||
| 751 | =item * Comprehensive test suite | ||
| 752 | |||
| 753 | =item * Optional release builds | ||
| 754 | |||
| 755 | =item * Cargo.lock hash-based cache | ||
| 756 | |||
| 757 | =back | ||
| 758 | |||
| 759 | =head2 Go | ||
| 760 | |||
| 761 | Go testing with modules and race detection. | ||
| 762 | |||
| 763 | B<Features:> | ||
| 764 | |||
| 765 | =over 4 | ||
| 766 | |||
| 767 | =item * Configurable Go version | ||
| 768 | |||
| 769 | =item * Go modules caching (~/go/pkg/mod) | ||
| 770 | |||
| 771 | =item * go vet for static analysis | ||
| 772 | |||
| 773 | =item * Race detector (-race flag) | ||
| 774 | |||
| 775 | =item * Test coverage with atomic mode | ||
| 776 | |||
| 777 | =item * go.sum hash-based cache | ||
| 778 | |||
| 779 | =back | ||
| 780 | |||
| 781 | =head2 Ruby | ||
| 782 | |||
| 783 | Ruby testing with Bundler integration. | ||
| 784 | |||
| 785 | B<Features:> | ||
| 786 | |||
| 787 | =over 4 | ||
| 788 | |||
| 789 | =item * Multiple Ruby versions (3.1, 3.2, 3.3) | ||
| 790 | |||
| 791 | =item * Automatic Bundler caching (built into setup-ruby) | ||
| 792 | |||
| 793 | =item * Gemfile.lock hash-based cache | ||
| 794 | |||
| 795 | =item * Rake integration | ||
| 796 | |||
| 797 | =back | ||
| 798 | |||
| 799 | =head2 Docker | ||
| 800 | |||
| 801 | Docker image building and publishing. | ||
| 802 | |||
| 803 | B<Features:> | ||
| 804 | |||
| 805 | =over 4 | ||
| 806 | |||
| 807 | =item * Docker Buildx for multi-platform builds | ||
| 808 | |||
| 809 | =item * GitHub Container Registry (GHCR) support | ||
| 810 | |||
| 811 | =item * Docker Hub support | ||
| 812 | |||
| 813 | =item * Automatic tag extraction from git | ||
| 814 | |||
| 815 | =item * Layer caching with GitHub Actions cache | ||
| 816 | |||
| 817 | =item * Only pushes on non-PR events | ||
| 818 | |||
| 819 | =back | ||
| 820 | |||
| 821 | =head2 Static Sites | ||
| 822 | |||
| 823 | Static site deployment to GitHub Pages. | ||
| 824 | |||
| 825 | B<Features:> | ||
| 826 | |||
| 827 | =over 4 | ||
| 828 | |||
| 829 | =item * GitHub Pages deployment | ||
| 830 | |||
| 831 | =item * Configurable build command | ||
| 832 | |||
| 833 | =item * Configurable build directory | ||
| 834 | |||
| 835 | =item * Artifact upload | ||
| 836 | |||
| 837 | =item * Proper Pages permissions | ||
| 838 | |||
| 839 | =item * Separate build and deploy jobs | ||
| 840 | |||
| 841 | =back | ||
| 842 | |||
| 843 | =head1 CONFIGURATION DETECTION | ||
| 844 | |||
| 845 | GHGen automatically detects configuration and adjusts workflows accordingly. | ||
| 846 | |||
| 847 | =head2 Minimum Version Detection | ||
| 848 | |||
| 849 | For Perl, minimum version is detected from: | ||
| 850 | |||
| 851 | =over 4 | ||
| 852 | |||
| 853 | =item * cpanfile: C<requires 'perl', '5.036'> | ||
| 854 | |||
| 855 | =item * Makefile.PL: C<MIN_PERL_VERSION =E<gt> '5.036'> | ||
| 856 | |||
| 857 | =item * dist.ini: C<perl = 5.036> | ||
| 858 | |||
| 859 | =back | ||
| 860 | |||
| 861 | Only compatible Perl versions are tested (e.g., if min is 5.36, won't test 5.32 or 5.34). | ||
| 862 | |||
| 863 | =head2 Dependency Files | ||
| 864 | |||
| 865 | Caching is based on dependency files: | ||
| 866 | |||
| 867 | =over 4 | ||
| 868 | |||
| 869 | =item * Perl: cpanfile, dist.ini, Makefile.PL, Build.PL | ||
| 870 | |||
| 871 | =item * Node: package-lock.json, yarn.lock, pnpm-lock.yaml | ||
| 872 | |||
| 873 | =item * Python: requirements.txt, Pipfile.lock | ||
| 874 | |||
| 875 | =item * Rust: Cargo.lock | ||
| 876 | |||
| 877 | =item * Go: go.sum | ||
| 878 | |||
| 879 | =item * Ruby: Gemfile.lock | ||
| 880 | |||
| 881 | =back | ||
| 882 | |||
| 883 | =head1 BEST PRACTICES | ||
| 884 | |||
| 885 | =head2 Workflow Generation | ||
| 886 | |||
| 887 | =over 4 | ||
| 888 | |||
| 889 | =item * B<Use --auto for quick start> - Let GHGen detect your project | ||
| 890 | |||
| 891 | =item * B<Use --customize for fine control> - Customize versions, OS, and features | ||
| 892 | |||
| 893 | =item * B<Review before committing> - Always review generated workflows | ||
| 894 | |||
| 895 | =item * B<Test locally first> - Use tools like C<act> to test locally | ||
| 896 | |||
| 897 | =item * B<Start with defaults> - Customize only when needed | ||
| 898 | |||
| 899 | =back | ||
| 900 | |||
| 901 | =head2 Workflow Analysis | ||
| 902 | |||
| 903 | =over 4 | ||
| 904 | |||
| 905 | =item * B<Run analyze regularly> - Weekly C<ghgen analyze> catches issues early | ||
| 906 | |||
| 907 | =item * B<Use --estimate> - Monitor CI costs over time | ||
| 908 | |||
| 909 | =item * B<Enable in CI> - Catch issues in PRs automatically | ||
| 910 | |||
| 911 | =item * B<Review auto-fixes> - Always review changes before committing | ||
| 912 | |||
| 913 | =item * B<Fix incrementally> - Don't fix everything at once if unsure | ||
| 914 | |||
| 915 | =back | ||
| 916 | |||
| 917 | =head2 Cost Optimization | ||
| 918 | |||
| 919 | =over 4 | ||
| 920 | |||
| 921 | =item * B<Add caching> - Biggest time/cost savings | ||
| 922 | |||
| 923 | =item * B<Add concurrency> - Cancel superseded runs | ||
| 924 | |||
| 925 | =item * B<Filter triggers> - Only run on relevant changes | ||
| 926 | |||
| 927 | =item * B<Optimize matrix> - Don't test unnecessary combinations | ||
| 928 | |||
| 929 | =item * B<Run coverage once> - Only on one OS/version combination | ||
| 930 | |||
| 931 | =back | ||
| 932 | |||
| 933 | =head1 EXAMPLES | ||
| 934 | |||
| 935 | =head2 Example 1: New Perl Module | ||
| 936 | |||
| 937 | # In your new Perl module directory | ||
| 938 | cd My-Module/ | ||
| 939 | |||
| 940 | # Create cpanfile | ||
| 941 | echo "requires 'perl', '5.036';" > cpanfile | ||
| 942 | |||
| 943 | # Auto-detect and generate | ||
| 944 | ghgen generate --auto | ||
| 945 | |||
| 946 | # Review and commit | ||
| 947 | cat .github/workflows/perl-ci.yml | ||
| 948 | git add .github/workflows/perl-ci.yml cpanfile | ||
| 949 | git commit -m "Add CI workflow" | ||
| 950 | git push | ||
| 951 | |||
| 952 | =head2 Example 2: Optimize Existing Project | ||
| 953 | |||
| 954 | # Clone project | ||
| 955 | git clone https://github.com/user/project.git | ||
| 956 | cd project/ | ||
| 957 | |||
| 958 | # Analyze with cost estimation | ||
| 959 | ghgen analyze --estimate | ||
| 960 | |||
| 961 | # Review suggestions, then fix | ||
| 962 | ghgen analyze --fix | ||
| 963 | |||
| 964 | # Review changes | ||
| 965 | git diff .github/workflows/ | ||
| 966 | |||
| 967 | # Commit improvements | ||
| 968 | git add .github/workflows/ | ||
| 969 | git commit -m "Optimize CI: add caching, update actions, add permissions" | ||
| 970 | git push | ||
| 971 | |||
| 972 | =head2 Example 3: Multi-Language Project | ||
| 973 | |||
| 974 | # Project with both Node.js and Docker | ||
| 975 | cd fullstack-app/ | ||
| 976 | |||
| 977 | # Generate Node.js workflow | ||
| 978 | ghgen generate --type=node --output=.github/workflows/frontend-ci.yml | ||
| 979 | |||
| 980 | # Generate Docker workflow | ||
| 981 | ghgen generate --type=docker --output=.github/workflows/backend-build.yml | ||
| 982 | |||
| 983 | # Analyze both | ||
| 984 | ghgen analyze | ||
| 985 | |||
| 986 | =head2 Example 4: Custom Perl Testing Matrix | ||
| 987 | |||
| 988 | # Interactive customization | ||
| 989 | ghgen generate --type=perl --customize | ||
| 990 | |||
| 991 | # Choose: | ||
| 992 | # Perl versions: 5.36, 5.38, 5.40 (skip older) | ||
| 993 | # OS: Ubuntu, macOS (skip Windows if not needed) | ||
| 994 | # Perl::Critic: Yes | ||
| 995 | # Coverage: Yes | ||
| 996 | # Branches: main | ||
| 997 | |||
| 998 | # Or without prompts: no Windows, newest two Perls | ||
| 999 | ghgen generate --type=perl --os=linux,macos --versions=5.40,5.42 | ||
| 1000 | |||
| 1001 | =head2 Example 5: CI Quality Gate | ||
| 1002 | |||
| 1003 | Add workflow quality checks to your CI: | ||
| 1004 | |||
| 1005 | # .github/workflows/ci-quality.yml | ||
| 1006 | name: CI Quality Check | ||
| 1007 | |||
| 1008 | on: | ||
| 1009 | pull_request: | ||
| 1010 | paths: | ||
| 1011 | - '.github/workflows/**' | ||
| 1012 | |||
| 1013 | jobs: | ||
| 1014 | check: | ||
| 1015 | runs-on: ubuntu-latest | ||
| 1016 | steps: | ||
| 1017 | - uses: actions/checkout@v6 | ||
| 1018 | - name: Install GHGen | ||
| 1019 | run: cpanm --notest App::GHGen | ||
| 1020 | - name: Check workflows | ||
| 1021 | run: | | ||
| 1022 | if ! ghgen analyze; then | ||
| 1023 | echo "::error::Workflow quality issues found" | ||
| 1024 | echo "Run 'ghgen analyze --fix' locally to fix" | ||
| 1025 | exit 1 | ||
| 1026 | fi | ||
| 1027 | |||
| 1028 | =head1 COMMAND REFERENCE | ||
| 1029 | |||
| 1030 | =head2 generate | ||
| 1031 | |||
| 1032 | ghgen generate [OPTIONS] | ||
| 1033 | |||
| 1034 | Generate a new GitHub Actions workflow. | ||
| 1035 | |||
| 1036 | B<Options:> | ||
| 1037 | |||
| 1038 | =over 4 | ||
| 1039 | |||
| 1040 | =item C<--auto, -a> | ||
| 1041 | |||
| 1042 | Auto-detect project type from repository contents. | ||
| 1043 | |||
| 1044 | =item C<--type=TYPE, -t TYPE> | ||
| 1045 | |||
| 1046 | Specify project type: perl, node, python, rust, go, ruby, docker, static. | ||
| 1047 | |||
| 1048 | =item C<--customize, -c> | ||
| 1049 | |||
| 1050 | Enable interactive customization mode. | ||
| 1051 | |||
| 1052 | =item C<--interactive, -i> | ||
| 1053 | |||
| 1054 | Interactively select project type from menu. | ||
| 1055 | |||
| 1056 | =item C<--output=FILE, -o FILE> | ||
| 1057 | |||
| 1058 | Specify output file (default: .github/workflows/TYPE-ci.yml). | ||
| 1059 | |||
| 1060 | =item C<--list, -l> | ||
| 1061 | |||
| 1062 | List all available workflow types with descriptions. | ||
| 1063 | |||
| 1064 | =item C<--os=LIST> | ||
| 1065 | |||
| 1066 | Comma-separated operating systems for Perl workflows: C<linux>, C<macos>, | ||
| 1067 | C<windows> (default: all three). Overrides the OS choice made with | ||
| 1068 | C<--customize>. | ||
| 1069 | |||
| 1070 | =item C<--versions=LIST> | ||
| 1071 | |||
| 1072 | Comma-separated language versions to test against. Overrides the defaults | ||
| 1073 | described in L</Choosing Operating Systems and Versions>. | ||
| 1074 | |||
| 1075 | =item C<--timeout=MINUTES> | ||
| 1076 | |||
| 1077 | Job C<timeout-minutes> for Perl workflows (default: 60). | ||
| 1078 | |||
| 1079 | =back | ||
| 1080 | |||
| 1081 | B<Examples:> | ||
| 1082 | |||
| 1083 | ghgen generate --auto | ||
| 1084 | ghgen generate --type=perl --customize | ||
| 1085 | ghgen generate --interactive | ||
| 1086 | ghgen generate --type=node --output=custom.yml | ||
| 1087 | ghgen generate --type=perl --os=linux,macos --versions=5.40,5.42 | ||
| 1088 | |||
| 1089 | =head2 analyze | ||
| 1090 | |||
| 1091 | ghgen analyze [OPTIONS] | ||
| 1092 | |||
| 1093 | Analyze existing workflows for issues and optimization opportunities. | ||
| 1094 | |||
| 1095 | B<Options:> | ||
| 1096 | |||
| 1097 | =over 4 | ||
| 1098 | |||
| 1099 | =item C<--fix, -f> | ||
| 1100 | |||
| 1101 | Automatically apply fixes to detected issues. | ||
| 1102 | |||
| 1103 | =item C<--estimate, -e> | ||
| 1104 | |||
| 1105 | Show cost estimates and potential savings. | ||
| 1106 | |||
| 1107 | =back | ||
| 1108 | |||
| 1109 | B<Examples:> | ||
| 1110 | |||
| 1111 | ghgen analyze | ||
| 1112 | ghgen analyze --fix | ||
| 1113 | ghgen analyze --estimate | ||
| 1114 | ghgen analyze --fix --estimate | ||
| 1115 | |||
| 1116 | =head1 TROUBLESHOOTING | ||
| 1117 | |||
| 1118 | =head2 Installation Issues | ||
| 1119 | |||
| 1120 | B<Problem:> C<cpanm> fails to install dependencies | ||
| 1121 | |||
| 1122 | B<Solution:> | ||
| 1123 | |||
| 1124 | # Install build tools first | ||
| 1125 | # On Debian/Ubuntu: | ||
| 1126 | sudo apt-get install build-essential | ||
| 1127 | |||
| 1128 | # On macOS: | ||
| 1129 | xcode-select --install | ||
| 1130 | |||
| 1131 | # Then retry | ||
| 1132 | cpanm App::GHGen | ||
| 1133 | |||
| 1134 | =head2 Generation Issues | ||
| 1135 | |||
| 1136 | B<Problem:> "No .github/workflows directory" | ||
| 1137 | |||
| 1138 | B<Solution:> | ||
| 1139 | |||
| 1140 | mkdir -p .github/workflows | ||
| 1141 | ghgen generate --auto | ||
| 1142 | |||
| 1143 | B<Problem:> Auto-detect doesn't find my project type | ||
| 1144 | |||
| 1145 | B<Solution:> | ||
| 1146 | |||
| 1147 | # Specify type explicitly | ||
| 1148 | ghgen generate --type=perl | ||
| 1149 | |||
| 1150 | # Or ensure indicator files exist | ||
| 1151 | touch cpanfile # for Perl | ||
| 1152 | touch package.json # for Node.js | ||
| 1153 | |||
| 1154 | =head2 Analysis Issues | ||
| 1155 | |||
| 1156 | B<Problem:> "Failed to parse YAML" | ||
| 1157 | |||
| 1158 | B<Solution:> | ||
| 1159 | |||
| 1160 | # Validate YAML syntax first | ||
| 1161 | yamllint .github/workflows/*.yml | ||
| 1162 | |||
| 1163 | # Fix YAML errors, then retry | ||
| 1164 | ghgen analyze | ||
| 1165 | |||
| 1166 | B<Problem:> Cost estimates seem wrong | ||
| 1167 | |||
| 1168 | B<Solution:> | ||
| 1169 | |||
| 1170 | Cost estimates are approximations based on: | ||
| 1171 | |||
| 1172 | =over 4 | ||
| 1173 | |||
| 1174 | =item * Typical commit/PR frequency | ||
| 1175 | |||
| 1176 | =item * Average workflow duration | ||
| 1177 | |||
| 1178 | =item * Standard GitHub Actions pricing | ||
| 1179 | |||
| 1180 | =back | ||
| 1181 | |||
| 1182 | Actual costs depend on your specific usage patterns. | ||
| 1183 | |||
| 1184 | =head2 Auto-Fix Issues | ||
| 1185 | |||
| 1186 | B<Problem:> Auto-fix didn't fix everything | ||
| 1187 | |||
| 1188 | B<Solution:> | ||
| 1189 | |||
| 1190 | Some issues can't be auto-fixed: | ||
| 1191 | |||
| 1192 | =over 4 | ||
| 1193 | |||
| 1194 | =item * Complex workflow logic | ||
| 1195 | |||
| 1196 | =item * Custom actions | ||
| 1197 | |||
| 1198 | =item * Project-specific configurations | ||
| 1199 | |||
| 1200 | =back | ||
| 1201 | |||
| 1202 | Review the remaining suggestions and apply manually. | ||
| 1203 | |||
| 1204 | =head2 GitHub Action Issues | ||
| 1205 | |||
| 1206 | B<Problem:> "Permission denied" errors | ||
| 1207 | |||
| 1208 | B<Solution:> | ||
| 1209 | |||
| 1210 | # Ensure correct permissions in workflow | ||
| 1211 | permissions: | ||
| 1212 | contents: write # For auto-fix | ||
| 1213 | pull-requests: write # For comments | ||
| 1214 | |||
| 1215 | B<Problem:> Action not triggering | ||
| 1216 | |||
| 1217 | B<Solution:> | ||
| 1218 | |||
| 1219 | # For scheduled workflows, ensure: | ||
| 1220 | on: | ||
| 1221 | schedule: | ||
| 1222 | - cron: '0 9 * * 1' | ||
| 1223 | workflow_dispatch: # Allows manual trigger | ||
| 1224 | |||
| 1225 | # Test with manual trigger first | ||
| 1226 | |||
| 1227 | =head1 DEPENDENCIES | ||
| 1228 | |||
| 1229 | =head2 Runtime Dependencies | ||
| 1230 | |||
| 1231 | =over 4 | ||
| 1232 | |||
| 1233 | =item * Perl 5.36 or higher | ||
| 1234 | |||
| 1235 | =item * L<YAML::XS> - Fast YAML parsing and generation | ||
| 1236 | |||
| 1237 | =item * L<Path::Tiny> - File and directory operations | ||
| 1238 | |||
| 1239 | =item * L<Term::ANSIColor> - Colored terminal output | ||
| 1240 | |||
| 1241 | =item * L<Getopt::Long> - Command-line option parsing | ||
| 1242 | |||
| 1243 | =item * L<Readonly> - Named constants | ||
| 1244 | |||
| 1245 | =back | ||
| 1246 | |||
| 1247 | =head2 Test Dependencies | ||
| 1248 | |||
| 1249 | =over 4 | ||
| 1250 | |||
| 1251 | =item * L<Test::More> - Testing framework | ||
| 1252 | |||
| 1253 | =item * L<Test::Exception> - Exception testing | ||
| 1254 | |||
| 1255 | =back | ||
| 1256 | |||
| 1257 | =head2 Optional Dependencies | ||
| 1258 | |||
| 1259 | =over 4 | ||
| 1260 | |||
| 1261 | =item * L<Pod::Markdown> - For generating README from POD | ||
| 1262 | |||
| 1263 | =back | ||
| 1264 | |||
| 1265 | =head1 SEE ALSO | ||
| 1266 | |||
| 1267 | =over 4 | ||
| 1268 | |||
| 1269 | =item * L<GitHub Marketplace Releases|https://github.com/marketplace/actions/ghgen-workflow-analyzer> | ||
| 1270 | |||
| 1271 | =item * L<Test Dashboard|https://nigelhorne.github.io/App-GHGen/coverage/> | ||
| 1272 | |||
| 1273 | =item * L<App::Test::Generator> | ||
| 1274 | |||
| 1275 | =back | ||
| 1276 | |||
| 1277 | =head2 GitHub Actions Documentation | ||
| 1278 | |||
| 1279 | =over 4 | ||
| 1280 | |||
| 1281 | =item * L<Workflow Syntax|https://docs.github.com/actions/reference/workflow-syntax-for-github-actions> | ||
| 1282 | |||
| 1283 | =item * L<GitHub Actions Pricing|https://docs.github.com/billing/managing-billing-for-github-actions> | ||
| 1284 | |||
| 1285 | =item * L<Security Hardening|https://docs.github.com/actions/security-guides/security-hardening-for-github-actions> | ||
| 1286 | |||
| 1287 | =item * L<Caching Dependencies|https://docs.github.com/actions/using-workflows/caching-dependencies-to-speed-up-workflows> | ||
| 1288 | |||
| 1289 | =back | ||
| 1290 | |||
| 1291 | =head2 Related Tools | ||
| 1292 | |||
| 1293 | =over 4 | ||
| 1294 | |||
| 1295 | =item * L<act|https://github.com/nektos/act> - Run GitHub Actions locally | ||
| 1296 | |||
| 1297 | =item * L<actionlint|https://github.com/rhysd/actionlint> - Linter for GitHub Actions | ||
| 1298 | |||
| 1299 | =item * L<yamllint|https://github.com/adrienverge/yamllint> - YAML linter | ||
| 1300 | |||
| 1301 | =back | ||
| 1302 | |||
| 1303 | =head1 REPOSITORY | ||
| 1304 | |||
| 1305 | L<https://github.com/nigelhorne/App-GHGen> | ||
| 1306 | |||
| 1307 | =head1 CONTRIBUTING | ||
| 1308 | |||
| 1309 | Contributions are welcome! GHGen is open source and hosted on GitHub. | ||
| 1310 | |||
| 1311 | =head2 Ways to Contribute | ||
| 1312 | |||
| 1313 | =over 4 | ||
| 1314 | |||
| 1315 | =item * B<Report bugs> - L<GitHub Issues|https://github.com/nigelhorne/App-GHGen/issues> | ||
| 1316 | |||
| 1317 | =item * B<Suggest features> - Open an issue with your idea | ||
| 1318 | |||
| 1319 | =item * B<Add language support> - Contribute new workflow templates | ||
| 1320 | |||
| 1321 | =item * B<Improve documentation> - Fix typos, add examples | ||
| 1322 | |||
| 1323 | =item * B<Submit pull requests> - Code contributions | ||
| 1324 | |||
| 1325 | =back | ||
| 1326 | |||
| 1327 | =head2 Development Setup | ||
| 1328 | |||
| 1329 | # Fork and clone | ||
| 1330 | git clone https://github.com/nigelhorne/ghgen.git | ||
| 1331 | cd ghgen | ||
| 1332 | |||
| 1333 | # Install dependencies | ||
| 1334 | cpanm --installdeps . | ||
| 1335 | |||
| 1336 | # Run tests | ||
| 1337 | prove -lr t/ | ||
| 1338 | |||
| 1339 | # Make changes | ||
| 1340 | # ... edit files ... | ||
| 1341 | |||
| 1342 | # Test your changes | ||
| 1343 | perl -Ilib bin/ghgen generate --type=perl | ||
| 1344 | prove -lr t/ | ||
| 1345 | |||
| 1346 | # Commit and push | ||
| 1347 | git add . | ||
| 1348 | git commit -m "Description of changes" | ||
| 1349 | git push origin your-branch | ||
| 1350 | |||
| 1351 | # Open pull request on GitHub | ||
| 1352 | |||
| 1353 | =head2 Adding a New Language | ||
| 1354 | |||
| 1355 | To add support for a new language: | ||
| 1356 | |||
| 1357 | 1. Create generator function in C<lib/App/GHGen/Generator.pm> | ||
| 1358 | |||
| 1359 | 2. Add detection logic in C<lib/App/GHGen/Detector.pm> | ||
| 1360 | |||
| 1361 | 3. Add customization in C<lib/App/GHGen/Interactive.pm> | ||
| 1362 | |||
| 1363 | 4. Add tests in C<t/> | ||
| 1364 | |||
| 1365 | 5. Update documentation | ||
| 1366 | |||
| 1367 | =head1 SUPPORT | ||
| 1368 | |||
| 1369 | This module is provided as-is without any warranty. | ||
| 1370 | |||
| 1371 | Please report any bugs or feature requests to C<bug-app-ghgen at rt.cpan.org>, | ||
| 1372 | or through the web interface at | ||
| 1373 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-GHGen>. | ||
| 1374 | I will be notified, and then you'll | ||
| 1375 | automatically be notified of progress on your bug as I make changes. | ||
| 1376 | |||
| 1377 | You can find documentation for this module with the perldoc command. | ||
| 1378 | |||
| 1379 | perldoc App::GHGen | ||
| 1380 | |||
| 1381 | You can also look for information at: | ||
| 1382 | |||
| 1383 | =head2 Getting Help | ||
| 1384 | |||
| 1385 | =over 4 | ||
| 1386 | |||
| 1387 | =item * L<GitHub Issues|https://github.com/nigelhorne/App-GHGen/issues> - Bug reports and feature requests | ||
| 1388 | |||
| 1389 | =item * L<GitHub Discussions|https://github.com/nigelhorne/App-GHGen/discussions> - Questions and community | ||
| 1390 | |||
| 1391 | =item * Email: L<njh@nigelhorne.com|mailto:njh@nigelhorne.com> | ||
| 1392 | |||
| 1393 | =back | ||
| 1394 | |||
| 1395 | =head2 Commercial Support | ||
| 1396 | |||
| 1397 | For commercial support, consulting, or custom development, contact the author. | ||
| 1398 | |||
| 1399 | =head1 PROGRAMMATIC INTERFACE | ||
| 1400 | |||
| 1401 | C<App::GHGen> itself only carries the release version. The programmatic | ||
| 1402 | interface lives in the submodules, each documented in its own POD: | ||
| 1403 | |||
| 1404 | =over 4 | ||
| 1405 | |||
| 1406 | =item L<App::GHGen::Generator> - C<generate_workflow>, C<list_workflow_types>, C<parse_os_list>, C<parse_version_list> | ||
| 1407 | |||
| 1408 | =item L<App::GHGen::PerlCustomizer> - C<generate_custom_perl_workflow>, C<detect_perl_requirements> | ||
| 1409 | |||
| 1410 | =item L<App::GHGen::Detector> - C<detect_project_type>, C<get_project_indicators> | ||
| 1411 | |||
| 1412 | =item L<App::GHGen::Analyzer> - C<analyze_workflow>, C<find_workflows> | ||
| 1413 | |||
| 1414 | =item L<App::GHGen::Fixer> - C<apply_fixes>, C<fix_workflow>, C<can_auto_fix> | ||
| 1415 | |||
| 1416 | =item L<App::GHGen::CostEstimator> - C<estimate_current_usage>, C<estimate_savings> | ||
| 1417 | |||
| 1418 | =item L<App::GHGen::Reporter> - GitHub Action comment formatting | ||
| 1419 | |||
| 1420 | =item L<App::GHGen::Interactive> - C<customize_workflow> and the prompts | ||
| 1421 | |||
| 1422 | =back | ||
| 1423 | |||
| 1424 | =head3 API SPECIFICATION | ||
| 1425 | |||
| 1426 | =head4 Input | ||
| 1427 | |||
| 1428 | # App::GHGen exports no functions and takes no arguments. | ||
| 1429 | { } | ||
| 1430 | |||
| 1431 | =head4 Output | ||
| 1432 | |||
| 1433 | # The release version, available as $App::GHGen::VERSION or | ||
| 1434 | # App::GHGen->VERSION. | ||
| 1435 | { VERSION => { type => 'scalar', matches => qr/\A\d+\.\d+\z/ } } | ||
| 1436 | |||
| 1437 | =head3 FORMAL SPECIFICATION | ||
| 1438 | |||
| 1439 | VERSION : seq CHAR (the release version, e.g. "0.13") | ||
| 1440 | |||
| 1441 | ∀ m ∈ { App::GHGen::* } • m.VERSION = App::GHGen.VERSION | ||
| 1442 | |||
| 1443 | =head1 AUTHOR | ||
| 1444 | |||
| 1445 | Nigel Horne E<lt>njh@nigelhorne.comE<gt> | ||
| 1446 | |||
| 1447 | L<https://github.com/nigelhorne> | ||
| 1448 | |||
| 1449 | =head1 CONTRIBUTORS | ||
| 1450 | |||
| 1451 | Thanks to all contributors who have helped improve GHGen! | ||
| 1452 | |||
| 1453 | See L<https://github.com/nigelhorne/App-GHGen/graphs/contributors> | ||
| 1454 | |||
| 1455 | =head1 COPYRIGHT AND LICENSE | ||
| 1456 | |||
| 1457 | Copyright 2025-2026 Nigel Horne. | ||
| 1458 | |||
| 1459 | Usage is subject to the GPL2 licence terms. | ||
| 1460 | If you use it, | ||
| 1461 | please let me know. | ||
| 1462 | |||
| 1463 | =cut | ||
| 1464 | |||
| 1465 | 58 | 1; | |