Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint PowerShell #748

Merged
merged 1 commit into from
Oct 2, 2024
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/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ jobs:
config: '.markdownlint.json'
globs: |
**/*.md

- name: Lint PowerShell
shell: pwsh
run: Invoke-ScriptAnalyzer -Path . -Recurse -IncludeDefaultRules -ReportSummary -Severity @('Error','Warning') -EnableExit
20 changes: 11 additions & 9 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $dotnetVersion = (Get-Content $sdkFile | Out-String | ConvertFrom-Json).sdk.vers
$installDotNetSdk = $false;

if (($null -eq (Get-Command "dotnet" -ErrorAction SilentlyContinue)) -and ($null -eq (Get-Command "dotnet.exe" -ErrorAction SilentlyContinue))) {
Write-Host "The .NET SDK is not installed."
Write-Information "The .NET SDK is not installed."
$installDotNetSdk = $true
}
else {
Expand All @@ -44,7 +44,7 @@ else {
}

if ($installedDotNetVersion -ne $dotnetVersion) {
Write-Host "The required version of the .NET SDK is not installed. Expected $dotnetVersion."
Write-Information "The required version of the .NET SDK is not installed. Expected $dotnetVersion."
$installDotNetSdk = $true
}
}
Expand All @@ -64,20 +64,20 @@ if ($installDotNetSdk -eq $true) {
$installScript = Join-Path $env:DOTNET_INSTALL_DIR "install.sh"
Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile $installScript -UseBasicParsing
chmod +x $installScript
& $installScript --version "$dotnetVersion" --install-dir "$env:DOTNET_INSTALL_DIR" --no-path
& $installScript --version $dotnetVersion --install-dir $env:DOTNET_INSTALL_DIR --no-path
}
else {
$installScript = Join-Path $env:DOTNET_INSTALL_DIR "install.ps1"
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile $installScript -UseBasicParsing
& $installScript -Version "$dotnetVersion" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath
& $installScript -Version $dotnetVersion -InstallDir $env:DOTNET_INSTALL_DIR -NoPath
}
}
}
else {
$env:DOTNET_INSTALL_DIR = Split-Path -Path (Get-Command dotnet).Path
}

$dotnet = Join-Path "$env:DOTNET_INSTALL_DIR" "dotnet"
$dotnet = Join-Path $env:DOTNET_INSTALL_DIR "dotnet"

if ($installDotNetSdk -eq $true) {
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
Expand Down Expand Up @@ -110,10 +110,12 @@ function DotNetTest {
}
}

Write-Host "Packaging library..." -ForegroundColor Green
Write-Information "Packaging library..."
DotNetPack $libraryProject

Write-Host "Running tests..." -ForegroundColor Green
ForEach ($testProject in $testProjects) {
DotNetTest $testProject
if (-Not $SkipTests) {
Write-Information "Running tests..."
ForEach ($testProject in $testProjects) {
DotNetTest $testProject
}
}