Skip to content

Commit

Permalink
Lint PowerShell
Browse files Browse the repository at this point in the history
- Lint PowerShell scripts.
- Fix lint warnings.
  • Loading branch information
martincostello committed Oct 2, 2024
1 parent 2f85ff9 commit f402dc0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
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
}
}

0 comments on commit f402dc0

Please sign in to comment.