Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Verify license headers under Windows PowerShell 5.1
if: runner.os == 'Windows'
shell: powershell
run: ./packaging/VerifyLicenseHeaders.ps1
- name: Verify runtime and source integration
shell: pwsh
run: ./packaging/VerifyRuntime.ps1 -Configuration '${{ env.CONFIGURATION }}'
Expand Down
35 changes: 30 additions & 5 deletions packaging/VerifyLicenseHeaders.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ $ErrorActionPreference = 'Stop'

$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path

function Get-RepositoryRelativePath {
param( [Parameter( Mandatory = $true )][string] $Path )

$rootPath = [IO.Path]::GetFullPath( $root )
$fullPath = [IO.Path]::GetFullPath( $Path )

if ( $fullPath.Equals( $rootPath, [StringComparison]::OrdinalIgnoreCase ) ) {
return '.'
}

$separator = [IO.Path]::DirectorySeparatorChar.ToString()
$rootPrefix = $rootPath
if ( -not $rootPrefix.EndsWith( $separator, [StringComparison]::Ordinal ) ) {
$rootPrefix += $separator
}

if ( -not $fullPath.StartsWith( $rootPrefix, [StringComparison]::OrdinalIgnoreCase ) ) {
throw "Path '$fullPath' is not within repository root '$rootPath'."
}

return $fullPath.Substring( $rootPrefix.Length ).Replace( '\', '/' )
}

function Get-ProjectAssemblyName {
param( [Parameter( Mandatory = $true )][string] $ProjectPath )

Expand Down Expand Up @@ -52,7 +75,7 @@ function Get-ProjectDescription {
function Get-LicenseKind {
param( [Parameter( Mandatory = $true )][string] $ProjectPath )

$relative = [IO.Path]::GetRelativePath( $root, $ProjectPath ).Replace( '\\', '/' )
$relative = Get-RepositoryRelativePath -Path $ProjectPath
if ( $relative -eq 'Icod.Terminal.csproj' ) {
return 'LGPL'
}
Expand Down Expand Up @@ -163,10 +186,11 @@ foreach ( $project in $projects ) {
$assemblyName = Get-ProjectAssemblyName -ProjectPath $project.FullName
$description = Get-ProjectDescription -AssemblyName $assemblyName
$licenseKind = Get-LicenseKind -ProjectPath $project.FullName
$expectedHeader = Get-ProjectHeader -AssemblyName $assemblyName -Description $description -LicenseKind $licenseKind
$expectedHeader = ( Get-ProjectHeader -AssemblyName $assemblyName -Description $description -LicenseKind $licenseKind ).Replace( "`r`n", "`n" )

if ( -not $content.StartsWith( $expectedHeader, [StringComparison]::Ordinal ) ) {
$failures.Add( "Project header mismatch: $([IO.Path]::GetRelativePath( $root, $project.FullName ))" )
$relativePath = Get-RepositoryRelativePath -Path $project.FullName
$failures.Add( "Project header mismatch: $relativePath" )
}
}

Expand All @@ -180,10 +204,11 @@ foreach ( $source in $sources ) {
$assemblyName = Get-ProjectAssemblyName -ProjectPath $projectPath
$description = Get-ProjectDescription -AssemblyName $assemblyName
$licenseKind = Get-LicenseKind -ProjectPath $projectPath
$expectedHeader = Get-CSharpHeader -AssemblyName $assemblyName -Description $description -LicenseKind $licenseKind
$expectedHeader = ( Get-CSharpHeader -AssemblyName $assemblyName -Description $description -LicenseKind $licenseKind ).Replace( "`r`n", "`n" )

if ( -not $content.StartsWith( $expectedHeader, [StringComparison]::Ordinal ) ) {
$failures.Add( "C# header mismatch: $([IO.Path]::GetRelativePath( $root, $source.FullName ))" )
$relativePath = Get-RepositoryRelativePath -Path $source.FullName
$failures.Add( "C# header mismatch: $relativePath" )
}
}

Expand Down
Loading