diff --git a/.github/scripts/Invoke-WslBash.ps1 b/.github/scripts/Invoke-WslBash.ps1 index 8770126675..fa07f64cc3 100644 --- a/.github/scripts/Invoke-WslBash.ps1 +++ b/.github/scripts/Invoke-WslBash.ps1 @@ -1,3 +1,7 @@ +# Copyright (c) Advanced Micro Devices, Inc., or its affiliates. +# +# SPDX-License-Identifier: MIT + # Runs a bash script inside the pinned WSL guest. # # Piping script text to `wsl.exe` from Windows PowerShell 5.1 is unreliable: diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index cf70d8e8b4..d4f6cda1aa 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -1,11 +1,21 @@ -# PSScriptAnalyzer configuration for the repo's PowerShell scripts -# (install.ps1, scripts/*.ps1). Used by the prek hook and CI. +# Copyright (c) Advanced Micro Devices, Inc., or its affiliates. +# +# SPDX-License-Identifier: MIT + +# PSScriptAnalyzer configuration for the repo's PowerShell scripts: every tracked +# .ps1 file, as listed by `git ls-files '*.ps1'` in xtask/src/powershell.rs +# (today install.ps1 and .github/scripts/Invoke-WslBash.ps1). Used by the prek +# hook and CI. +# +# Only .ps1 files are linted. The licence-header check (licenserc.toml) also +# covers .psm1 and .psd1, so a module or data file added later gets a header but +# no analyzer pass until the xtask and the hook's `files:` pattern are extended. @{ # Enforce the full default rule set at Warning and Error severity. Severity = @('Error', 'Warning') - # install.ps1 and the acceptance/packaging scripts are user-facing console - # programs where `Write-Host` is the intended way to print progress to the - # terminal, so the "avoid Write-Host" rule does not apply here. + # install.ps1 is a user-facing console program where `Write-Host` is the + # intended way to print progress to the terminal, so the "avoid Write-Host" + # rule does not apply here. ExcludeRules = @('PSAvoidUsingWriteHost') } diff --git a/install.ps1 b/install.ps1 index 33c391f91f..c1c9da0c91 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,3 +1,7 @@ +# Copyright (c) Advanced Micro Devices, Inc., or its affiliates. +# +# SPDX-License-Identifier: MIT + param( [Parameter(Position = 0)] [string] $Channel = $env:ROCM_CLI_CHANNEL, diff --git a/licenserc.toml b/licenserc.toml index 93d2bbd258..76b94d760c 100644 --- a/licenserc.toml +++ b/licenserc.toml @@ -8,9 +8,17 @@ ## folder is vendored verbatim into the amd/skills catalog, whose skills carry ## no headers. The licence is stated in the skill's own skill-card.md instead. +## The header text is a template rendered per file. PowerShell files get an ASCII +## `(c)` instead of the copyright sign: a file with any non-ASCII byte needs a +## BOM, and install.ps1 cannot have one because a BOM breaks `irm ... | iex`. The +## other PowerShell files follow so the whole family reads the same. [header] text = """ +{% if attrs.filename is endingwith(".ps1") or attrs.filename is endingwith(".psm1") or attrs.filename is endingwith(".psd1") -%} +Copyright (c) Advanced Micro Devices, Inc., or its affiliates. +{%- else -%} Copyright © Advanced Micro Devices, Inc., or its affiliates. +{%- endif %} SPDX-License-Identifier: MIT """ @@ -21,6 +29,9 @@ includes = [ "**/*.py", "**/*.sh", "**/*.md", + "**/*.ps1", + "**/*.psm1", + "**/*.psd1", ] excludes = [ @@ -35,3 +46,12 @@ excludes = [ [[rules]] extensions = ["md"] style_out = "xml" + +## hawkeye has no built-in comment syntax for PowerShell: without this rule a +## .ps1/.psm1/.psd1 file is reported `unsupported` and silently skipped (exit 0), +## so `includes` alone would not enforce anything. Only `hawkeye check +## --fail-on-unknown` turns that into a failure, and neither the CI job nor the +## prek hook passes the flag. +[[rules]] +extensions = ["ps1", "psm1", "psd1"] +style_out = "script"