Skip to content

GrexyLoco/K.Actions.PSModuleValidation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

63 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

K.Actions.PSModuleValidation

GitHub PowerShell License

πŸ§ͺ Current Test Status

Tests Security Integration Cross-Platform

Platform Compatibility

Ubuntu Windows

πŸ“Š Status: failing | Updated: 2025-08-19 01:11:54 UTC | Run: #6 | Auto-generated

Comprehensive validation action for PowerShell modules featuring security scans, code quality analysis, and automated testing with enterprise-grade reporting.

πŸš€ Features

  • πŸ›‘οΈ Security Scanning: GitLeaks for secret detection
  • πŸ“ Code Quality: Super-Linter with PSScriptAnalyzer, JSCPD, and more
  • πŸ§ͺ Automated Testing: Pester v5 with code coverage
  • πŸ“Š Rich Reporting: Detailed GitHub summaries with metrics
  • ⚑ High Performance: Optimized for CI/CD pipelines
  • πŸ”§ Configurable: Flexible inputs for various project needs

πŸ“‹ Usage

Basic Usage

name: PowerShell Module Validation

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main ]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Validate PowerShell Module
        uses: GrexyLoco/K.Actions.PSModuleValidation@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          module-name: 'MyModule'

Advanced Configuration

      - name: Validate PowerShell Module
        uses: GrexyLoco/K.Actions.PSModuleValidation@v1
        with:
          test-path: './Tests'
          output-path: './TestResults.xml'
          validate-all-codebase: 'true'
          github-token: ${{ secrets.GITHUB_TOKEN }}
          module-name: 'MyAdvancedModule'
          pester-configuration: |
            {
              "Run": {
                "Path": "./Tests",
                "PassThru": true
              },
              "Output": {
                "Verbosity": "Detailed"
              },
              "TestResult": {
                "Enabled": true,
                "OutputPath": "./TestResults.xml",
                "OutputFormat": "NUnitXml"
              },
              "CodeCoverage": {
                "Enabled": true,
                "OutputFormat": "JaCoCo",
                "Path": ["*.ps1", "*.psm1"],
                "Threshold": 80
              }
            }

πŸ”§ Inputs

Input Description Required Default
test-path Path to the test directory containing Pester tests. If empty, auto-discovery will search for test files up to 5 levels deep. No '' (auto-discovery)
output-path Path for test results XML output No ./TestResults.xml
validate-all-codebase Whether to validate all codebase or only changed files No false
github-token GitHub token for Super-Linter Yes -
pester-configuration Custom Pester configuration (JSON format) No Default config
module-name Name of the PowerShell module (for reporting) No PowerShell Module

πŸ“€ Outputs

Output Description
test-success Whether all tests passed successfully
total-tests Total number of tests executed
passed-tests Number of tests that passed
failed-tests Number of tests that failed
skipped-tests Number of tests that were skipped
test-duration Total test execution duration (seconds)
test-results-path Path to the test results XML file
coverage-percentage Code coverage percentage

πŸ›‘οΈ Security Features

GitLeaks Integration

  • Secret Detection: Scans for exposed API keys, credentials, and sensitive data
  • Pattern Matching: 100+ built-in patterns for common secrets
  • Zero False Positives: Tuned for PowerShell module development

Security Patterns Detected

  • πŸ”‘ API Keys (AWS, Google, GitHub, Azure, etc.)
  • πŸ” Private Keys (RSA, SSH, PGP)
  • πŸ“§ Email addresses in code
  • 🌐 URLs with embedded credentials
  • πŸ’³ Credit card numbers
  • πŸ—„οΈ Database connection strings

πŸ“Š Quality Gates

Super-Linter Integration

  • PowerShell: PSScriptAnalyzer with best practices
  • JSCPD: Copy-paste detection and code duplication analysis
  • Markdown: Documentation formatting validation
  • YAML/JSON: Configuration file validation

Code Quality Standards

  • βœ… PowerShell best practices (PSScriptAnalyzer)
  • βœ… Code formatting consistency
  • βœ… Documentation standards
  • βœ… Configuration file integrity
  • βœ… Duplication detection (JSCPD)

πŸ§ͺ Testing Framework

Pester v5 Integration

  • Modern Testing: Latest Pester framework with enhanced features
  • Code Coverage: Built-in coverage analysis with configurable thresholds
  • Flexible Configuration: JSON-based configuration support
  • Artifact Upload: Test results automatically uploaded as artifacts

πŸ” Smart Test Discovery

  • Auto-Discovery: If no test path is specified, the action will recursively search up to 5 levels deep for folders named Test or Tests.
  • Strict File Pattern: Only files ending with .Test.ps1 or .Tests.ps1 inside these folders are considered valid Pester tests.
  • Warning for Missing Tests: If a test folder exists but no valid test files are found, a warning is issued (not an error).
  • Error Only When: Tests exist but fail to pass.

Example Test Discovery Convention

YourModule/
β”œβ”€β”€ Tests/
β”‚   β”œβ”€β”€ MyFeature.Tests.ps1
β”‚   └── AnotherFeature.Test.ps1
└── ...

Test Reporting

  • πŸ“Š Comprehensive test metrics
  • πŸ“ˆ Code coverage analysis
  • ⚑ Performance monitoring
  • 🎯 Quality gate validation
  • ⚠️ Warning for missing tests (not error)

πŸ“‹ Requirements

  • GitHub Actions Runner: Ubuntu Latest (recommended)
  • PowerShell: 5.1+ (automatically available on Ubuntu runners)
  • Pester: v5.0+ (automatically installed if missing)
  • Test Structure: Tests should be in a dedicated directory

πŸ—οΈ Project Structure

Your PowerShell module should follow this structure:

YourModule/
β”œβ”€β”€ YourModule.psd1          # Module manifest
β”œβ”€β”€ YourModule.psm1          # Module file
β”œβ”€β”€ Tests/                   # Test directory
β”‚   β”œβ”€β”€ YourModule.Tests.ps1 # Pester tests
β”‚   └── ...
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── validate.yml     # This action
└── README.md

πŸ”— Integration Examples

Using Outputs in Subsequent Steps

      - name: Validate Module
        id: validate
        uses: GrexyLoco/K.Actions.PSModuleValidation@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          module-name: 'MyModule'

      - name: Check Results
        if: always()
        run: |
          echo "Tests passed: ${{ steps.validate.outputs.test-success }}"
          echo "Total tests: ${{ steps.validate.outputs.total-tests }}"
          echo "Coverage: ${{ steps.validate.outputs.coverage-percentage }}%"
          echo "Duration: ${{ steps.validate.outputs.test-duration }}s"

Conditional Deployment

      - name: Deploy to PowerShell Gallery
        if: steps.validate.outputs.test-success == 'true' && steps.validate.outputs.coverage-percentage >= '80'
        run: |
          # Deployment logic here

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🏷️ Versioning

This action follows Semantic Versioning with automated releases using K.Actions.NextActionVersion.

Release Automation

  • Conventional Commits: Use feat:, fix:, BREAKING CHANGE: for automatic version bumps
  • Git Tag-Based: Versions are calculated from Git history, not manifest files
  • Smart Detection: Only creates releases when changes warrant a version bump
  • Branch Patterns: feature/ β†’ minor, bugfix/ β†’ patch, major/ β†’ major

Available Versions

See the releases page for all versions, or reference the tags.

πŸ› Issues & Support

πŸ™ Acknowledgments

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •