File Coverage

blib/lib/App/GHGen.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 11 11 100.0


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