From bee19eb317f3230290e9116747bca380beea8c2f Mon Sep 17 00:00:00 2001 From: Bartosz Blizniak Date: Tue, 7 Jul 2026 11:43:49 +0100 Subject: [PATCH] ci: first-run fixes and temporary test-repository default - PSScriptAnalyzer: rename Test-ZipEntries to Test-ZipArchive, inline the directory-creation helper - tests: add gzip/gunzip/cat to the restricted-PATH wget stubs; update remaining --version assertions to the real CLI output format - default repository temporarily points at the test repo (TODO reverts before release) Co-Authored-By: Claude Fable 5 --- install.ps1 | 23 +++++++++-------------- install.sh | 3 ++- tests/detect_target.bats | 5 +++++ tests/install.bats | 6 +++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/install.ps1 b/install.ps1 index 8b29da0..85aee94 100644 --- a/install.ps1 +++ b/install.ps1 @@ -19,7 +19,8 @@ param( ), [string]$Target = $env:CLOUDSMITH_CLI_TARGET, [string]$OutputFile = $env:CLOUDSMITH_CLI_OUTPUT_FILE, - [string]$Repository = $(if ($env:CLOUDSMITH_CLI_REPOSITORY) { $env:CLOUDSMITH_CLI_REPOSITORY } else { "cloudsmith/cli-standalone" }), + # TODO: revert to the production repository before release. + [string]$Repository = $(if ($env:CLOUDSMITH_CLI_REPOSITORY) { $env:CLOUDSMITH_CLI_REPOSITORY } else { "bart-demo-org-terraform/cli-binary-release-test" }), [string]$ManifestUrl = $env:CLOUDSMITH_CLI_MANIFEST_URL, [switch]$Force ) @@ -265,7 +266,7 @@ function Test-CloudsmithExecutable { return $true } -function Test-ZipEntries { +function Test-ZipArchive { param([Parameter(Mandatory = $true)][string]$Archive) Add-Type -AssemblyName System.IO.Compression.FileSystem @@ -307,7 +308,7 @@ function Write-InstallResult { if ($OutputFile) { $parent = Split-Path -Parent $OutputFile if ($parent) { - New-LiteralDirectory -Path $parent + [void][System.IO.Directory]::CreateDirectory($parent) } $utf8WithoutBom = New-Object System.Text.UTF8Encoding($false) [IO.File]::WriteAllLines($OutputFile, $lines, $utf8WithoutBom) @@ -317,12 +318,6 @@ function Write-InstallResult { } } -function New-LiteralDirectory { - param([Parameter(Mandatory = $true)][string]$Path) - - [void][System.IO.Directory]::CreateDirectory($Path) -} - try { if ($Version -notmatch '^[A-Za-z0-9._+-]+$' -or $Version -eq '.' -or $Version -eq '..') { throw "install.ps1: invalid version: $Version" @@ -338,9 +333,9 @@ try { Write-InstallerLog "detected target $resolvedTarget" $temporaryRoot = Join-Path $InstallRoot ".tmp" - New-LiteralDirectory -Path $temporaryRoot + [void][System.IO.Directory]::CreateDirectory($temporaryRoot) $script:WorkDir = Join-Path $temporaryRoot ([Guid]::NewGuid().ToString("N")) - New-LiteralDirectory -Path $script:WorkDir + [void][System.IO.Directory]::CreateDirectory($script:WorkDir) $manifestFile = Join-Path $script:WorkDir "manifest.txt" if (-not $ManifestUrl) { @@ -381,7 +376,7 @@ try { $binDirectory = Join-Path $finalParent "cloudsmith" $executable = Join-Path $binDirectory "cloudsmith.exe" $metadataFile = Join-Path $binDirectory ".cloudsmith-installation" - New-LiteralDirectory -Path $finalParent + [void][System.IO.Directory]::CreateDirectory($finalParent) $lockPath = Join-Path $finalParent ".install.lock" $deadline = [DateTime]::UtcNow.AddSeconds(120) @@ -426,10 +421,10 @@ try { if (-not $archiveName.EndsWith('.zip', [StringComparison]::OrdinalIgnoreCase)) { throw "install.ps1: unsupported archive format: $archiveName" } - Test-ZipEntries -Archive $archiveFile + Test-ZipArchive -Archive $archiveFile $extractDirectory = Join-Path $script:WorkDir "extract" - New-LiteralDirectory -Path $extractDirectory + [void][System.IO.Directory]::CreateDirectory($extractDirectory) [System.IO.Compression.ZipFile]::ExtractToDirectory($archiveFile, $extractDirectory) $stagedDirectory = Join-Path $extractDirectory "cloudsmith" diff --git a/install.sh b/install.sh index 0114806..3288337 100755 --- a/install.sh +++ b/install.sh @@ -10,7 +10,8 @@ PROGRAM="install.sh" # Where releases are downloaded from. Flags and CLOUDSMITH_CLI_* environment # variables override the defaults; --manifest-url bypasses URL construction. DOWNLOAD_BASE_URL="https://dl.cloudsmith.io/public" -DEFAULT_REPOSITORY="cloudsmith/cli-standalone" +# TODO: revert to the production repository before release. +DEFAULT_REPOSITORY="bart-demo-org-terraform/cli-binary-release-test" MANIFEST_NAME_PREFIX="cloudsmith-cli-manifest" REPOSITORY="${CLOUDSMITH_CLI_REPOSITORY:-$DEFAULT_REPOSITORY}" diff --git a/tests/detect_target.bats b/tests/detect_target.bats index e4eb559..865d0e1 100644 --- a/tests/detect_target.bats +++ b/tests/detect_target.bats @@ -82,6 +82,11 @@ write_ldd_stub() { } @test "linux/x86_64 with glibc (getconf) is detected as linux-x86_64-gnu" { + # The real filesystem probe (/etc/alpine-release, ld-musl) answers before the + # getconf stub can, so this scenario is untestable on a musl host. + if [ -f /etc/alpine-release ] || ls /lib/ld-musl-*.so.1 >/dev/null 2>&1; then + skip "musl host: filesystem probe wins over the getconf stub" + fi write_uname_stub Linux x86_64 write_getconf_stub gnu diff --git a/tests/install.bats b/tests/install.bats index 9e74ae2..7e96000 100644 --- a/tests/install.bats +++ b/tests/install.bats @@ -27,7 +27,7 @@ make_path_without_curl() { mkdir -p "$bin" local cmd path - for cmd in sh mkdir mktemp rm rmdir awk tr tar chmod mv dirname grep cp sha256sum shasum openssl sleep; do + for cmd in sh mkdir mktemp rm rmdir awk tr tar gzip gunzip cat chmod mv dirname grep cp sha256sum shasum openssl sleep; do path="$(command -v "$cmd" 2>/dev/null || true)" if [ -n "$path" ] && [ ! -e "$bin/$cmd" ]; then ln -s "$path" "$bin/$cmd" @@ -92,7 +92,7 @@ executable=$bin_dir/cloudsmith" run "$bin_dir/cloudsmith" --version [ "$status" -eq 0 ] - [ "$output" = "cloudsmith 1.19.0" ] + [[ "$output" == *"CLI Package Version: 1.19.0"* ]] } @test "--help prints usage with HOME and XDG_DATA_HOME unset" { @@ -630,5 +630,5 @@ executable=$bin_dir/cloudsmith" [ -x "$bin" ] run "$bin" --version [ "$status" -eq 0 ] - [ "$output" = "cloudsmith 1.19.0" ] + [[ "$output" == *"CLI Package Version: 1.19.0"* ]] }