Skip to content
Open
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
13 changes: 13 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ jobs:
files: ./coverage.out
fail_ci_if_error: false

windows-install:
name: Windows Installer
runs-on: windows-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Test Windows installer
shell: pwsh
run: ./scripts/install-windows-test.ps1

# Monitor code coverage and TODO/FIXME-type comments
health-score:
name: Health Score
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-windows-dev.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function install_slack_cli {
$slack_cli_new_binary_path = "$($slack_cli_dir)\bin\${confirmed_alias}.exe"

delay 0.3 "Extracting the executable to:`n $slack_cli_new_binary_path"
Expand-Archive "$($slack_cli_dir)\slack_cli.zip" -DestinationPath "$($slack_cli_dir)" -Force
Microsoft.PowerShell.Archive\Expand-Archive "$($slack_cli_dir)\slack_cli.zip" -DestinationPath "$($slack_cli_dir)" -Force
Move-Item -Path $slack_cli_binary_path -Destination $slack_cli_new_binary_path -Force

$User = [System.EnvironmentVariableTarget]::User
Expand Down
70 changes: 70 additions & 0 deletions scripts/install-windows-test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2022-2026 Salesforce, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

$ErrorActionPreference = "Stop"
$qualifiedCommand = "Microsoft.PowerShell.Archive\Expand-Archive"
$installerPaths = @(
(Join-Path $PSScriptRoot "install-windows.ps1"),
(Join-Path $PSScriptRoot "install-windows-dev.ps1")
)

foreach ($installerPath in $installerPaths) {
$tokens = $null
$parseErrors = $null
$ast = [System.Management.Automation.Language.Parser]::ParseFile(
$installerPath,
[ref]$tokens,
[ref]$parseErrors
)

if ($parseErrors.Count -gt 0) {
throw "PowerShell parser errors in $installerPath"
}

$archiveCommands = $ast.FindAll({
param($node)
$node -is [System.Management.Automation.Language.CommandAst] -and
$node.GetCommandName() -like "*Expand-Archive"
}, $true)

if ($archiveCommands.Count -ne 1 -or $archiveCommands[0].GetCommandName() -ne $qualifiedCommand) {
throw "$installerPath must call $qualifiedCommand exactly once"
}
}

$testRoot = Join-Path ([System.IO.Path]::GetTempPath()) "slack-cli-install-$([guid]::NewGuid())"
$sourcePath = Join-Path $testRoot "source"
$destinationPath = Join-Path $testRoot "destination"
$archivePath = Join-Path $testRoot "slack_cli.zip"

try {
New-Item -ItemType Directory -Path (Join-Path $sourcePath "bin") -Force | Out-Null
Set-Content -LiteralPath (Join-Path $sourcePath "bin\slack.exe") -Value "test"
Microsoft.PowerShell.Archive\Compress-Archive -Path (Join-Path $sourcePath "*") -DestinationPath $archivePath

function Expand-Archive {
throw "The shadowing command should not be called"
}

Microsoft.PowerShell.Archive\Expand-Archive -LiteralPath $archivePath -DestinationPath $destinationPath -Force

if (!(Test-Path -LiteralPath (Join-Path $destinationPath "bin\slack.exe"))) {
throw "The qualified archive command did not extract bin\slack.exe"
}
}
finally {
if (Test-Path -LiteralPath $testRoot) {
Remove-Item -LiteralPath $testRoot -Recurse -Force
}
}
2 changes: 1 addition & 1 deletion scripts/install-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function install_slack_cli {
$slack_cli_new_binary_path = "$($slack_cli_dir)\bin\${confirmed_alias}.exe"

delay 0.3 "Extracting the executable to:`n $slack_cli_new_binary_path"
Expand-Archive "$($slack_cli_dir)\slack_cli.zip" -DestinationPath "$($slack_cli_dir)" -Force
Microsoft.PowerShell.Archive\Expand-Archive "$($slack_cli_dir)\slack_cli.zip" -DestinationPath "$($slack_cli_dir)" -Force
Move-Item -Path $slack_cli_binary_path -Destination $slack_cli_new_binary_path -Force

$User = [System.EnvironmentVariableTarget]::User
Expand Down