Skip to content

feat(ci): Add CI job to validate PowerShell copyright and license headers #353

@WilliamBerryiii

Description

@WilliamBerryiii

Issue Description

Add a CI job that validates all PowerShell files (.ps1, .psm1, .psd1) contain the required Microsoft copyright and MIT license header at the top of the file.

Required Header Format

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

The header must appear at the very beginning of the file (lines 1-2). Additional metadata comments (purpose, author) may follow but are not required.

Acceptance Criteria

  • Create validation script in scripts/linting/ that checks all PowerShell files
  • Script returns non-zero exit code when files are missing headers
  • Script outputs list of non-compliant files with their paths
  • Add npm script alias for local execution (e.g., npm run lint:copyright)
  • Integrate into existing CI linting workflow
  • Document expected header format in scripts/linting/README.md

Additional Context

Files to Check

  • All .ps1 files (scripts)
  • All .psm1 files (modules)
  • All .psd1 files (module manifests)

Exclusions to Consider

  • scripts/tests/ directory (test files may have different conventions)
  • Vendor/third-party files if any exist

Example Validation Logic

$expectedLine1 = '# Copyright (c) Microsoft Corporation.'
$expectedLine2 = '# Licensed under the MIT license.'

$content = Get-Content -Path $file -TotalCount 2
if ($content[0] -ne $expectedLine1 -or $content[1] -ne $expectedLine2) {
    # File is non-compliant
}

Related

  • Existing linting scripts in scripts/linting/
  • PSScriptAnalyzer integration at scripts/linting/Invoke-PSScriptAnalyzer.ps1

Metadata

Metadata

Assignees

No one assigned

    Labels

    ciContinuous integrationfeatureNew feature triggering minor version bump

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions