From a7111513a75372833a1b2bf862b41ce04d94efb8 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 28 Nov 2024 11:26:20 +0100 Subject: [PATCH] ci: Fix reproducibility tests after release --- src/header.ps1 | 200 +++++++++--------- ...tion_test__sha256-linux-64-executable.snap | 4 +- ...test__sha256-linux-aarch64-executable.snap | 4 +- ...ration_test__sha256-osx-64-executable.snap | 4 +- ...ion_test__sha256-osx-arm64-executable.snap | 4 +- ...ration_test__sha256-win-64-executable.snap | 4 +- 6 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/header.ps1 b/src/header.ps1 index 60cde9f..2b33d8f 100644 --- a/src/header.ps1 +++ b/src/header.ps1 @@ -1,100 +1,100 @@ -$ErrorActionPreference = "Stop" - -function New-TemporaryDirectory { - $parent = [System.IO.Path]::GetTempPath() - [string] $name = [System.Guid]::NewGuid() - $tempDir = New-Item -ItemType Directory -Path (Join-Path $parent $name) - return $tempDir.FullName -} - -$TEMPDIR = New-TemporaryDirectory -$USAGE = @" -Usage: $($MyInvocation.MyCommand.Name) [OPTIONS] - -Arguments: - Path to an environment packed using pixi-pack - -Options: - -o, --output-directory Where to unpack the environment. The environment will be unpacked into a subdirectory of this path [default: env] - -e, --env-name Name of the environment [default: env] - -s, --shell Sets the shell [options: bash, zsh, xonsh, cmd, powershell, fish, nushell] - -v, --verbose Increase logging verbosity - -q, --quiet Decrease logging verbosity - -h, --help Print help -"@ - -foreach ($arg in $args) { - if ($arg -eq "-h" -or $arg -eq "--help") { - Write-Output $USAGE - exit 0 - } -} - -# Extract the archive and pixi-pack executable, and decode them -$scriptContent = Get-Content -Raw -Path $MyInvocation.MyCommand.Path -$lines = $scriptContent -split "`r?`n" - -$headerLine = $null -$archiveLine = $null - -# Find the lines where __END_HEADER__ and __END_ARCHIVE__ occur -for ($i = 0; $i -lt $lines.Count; $i++) { - if ($lines[$i] -like "*__END_HEADER__*") { - $headerLine = $i + 2 - } - if ($lines[$i] -like "*__END_ARCHIVE__*") { - $archiveLine = $i + 1 - } -} - -if (-not $headerLine -or -not $archiveLine) { - Write-Error "ERROR: Markers __END_HEADER__ or __END_ARCHIVE__ not found." - exit 1 -} - -# Extract Base64 content for the tar archive -$archiveContent = $lines[($headerLine)..($archiveLine - 2)] -join "" -$archiveContent = $archiveContent.Trim() - -# Decode Base64 content into tar file -try { - $decodedArchive = [System.Convert]::FromBase64String($archiveContent) - $archivePath = "$TEMPDIR\archive.tar" - [System.IO.File]::WriteAllBytes($archivePath, $decodedArchive) -} catch { - Write-Error "ERROR: Failed to decode Base64 archive content: $_" - exit 1 -} - -# Extract Base64 content for pixi-pack executable -$pixiPackContent = $lines[($archiveLine)..($lines.Count - 1)] -join "" -$pixiPackContent = $pixiPackContent.Trim() - -# Decode Base64 content into the pixi-pack executable file -try { - $decodedPixiPack = [System.Convert]::FromBase64String($pixiPackContent) - $pixiPackPath = "$TEMPDIR\pixi-pack.exe" - [System.IO.File]::WriteAllBytes($pixiPackPath, $decodedPixiPack) -} catch { - Write-Error "Failed to decode Base64 pixi-pack content: $_" - exit 1 -} - -# Build the command with flags -$arguments = @("unpack") -$arguments += $args - -# Add the path to the archive -$arguments += $archivePath - -& $pixiPackPath $arguments -if ($LASTEXITCODE -ne 0) { - Remove-Item -Path $TEMPDIR -Recurse -Force - exit $LASTEXITCODE -} - -Remove-Item -Path $TEMPDIR -Recurse -Force - -exit 0 - -__END_HEADER__ +$ErrorActionPreference = "Stop" + +function New-TemporaryDirectory { + $parent = [System.IO.Path]::GetTempPath() + [string] $name = [System.Guid]::NewGuid() + $tempDir = New-Item -ItemType Directory -Path (Join-Path $parent $name) + return $tempDir.FullName +} + +$TEMPDIR = New-TemporaryDirectory +$USAGE = @" +Usage: $($MyInvocation.MyCommand.Name) [OPTIONS] + +Arguments: + Path to an environment packed using pixi-pack + +Options: + -o, --output-directory Where to unpack the environment. The environment will be unpacked into a subdirectory of this path [default: env] + -e, --env-name Name of the environment [default: env] + -s, --shell Sets the shell [options: bash, zsh, xonsh, cmd, powershell, fish, nushell] + -v, --verbose Increase logging verbosity + -q, --quiet Decrease logging verbosity + -h, --help Print help +"@ + +foreach ($arg in $args) { + if ($arg -eq "-h" -or $arg -eq "--help") { + Write-Output $USAGE + exit 0 + } +} + +# Extract the archive and pixi-pack executable, and decode them +$scriptContent = Get-Content -Raw -Path $MyInvocation.MyCommand.Path +$lines = $scriptContent -split "`r?`n" + +$headerLine = $null +$archiveLine = $null + +# Find the lines where __END_HEADER__ and __END_ARCHIVE__ occur +for ($i = 0; $i -lt $lines.Count; $i++) { + if ($lines[$i] -like "*__END_HEADER__*") { + $headerLine = $i + 2 + } + if ($lines[$i] -like "*__END_ARCHIVE__*") { + $archiveLine = $i + 1 + } +} + +if (-not $headerLine -or -not $archiveLine) { + Write-Error "ERROR: Markers __END_HEADER__ or __END_ARCHIVE__ not found." + exit 1 +} + +# Extract Base64 content for the tar archive +$archiveContent = $lines[($headerLine)..($archiveLine - 2)] -join "" +$archiveContent = $archiveContent.Trim() + +# Decode Base64 content into tar file +try { + $decodedArchive = [System.Convert]::FromBase64String($archiveContent) + $archivePath = "$TEMPDIR\archive.tar" + [System.IO.File]::WriteAllBytes($archivePath, $decodedArchive) +} catch { + Write-Error "ERROR: Failed to decode Base64 archive content: $_" + exit 1 +} + +# Extract Base64 content for pixi-pack executable +$pixiPackContent = $lines[($archiveLine)..($lines.Count - 1)] -join "" +$pixiPackContent = $pixiPackContent.Trim() + +# Decode Base64 content into the pixi-pack executable file +try { + $decodedPixiPack = [System.Convert]::FromBase64String($pixiPackContent) + $pixiPackPath = "$TEMPDIR\pixi-pack.exe" + [System.IO.File]::WriteAllBytes($pixiPackPath, $decodedPixiPack) +} catch { + Write-Error "Failed to decode Base64 pixi-pack content: $_" + exit 1 +} + +# Build the command with flags +$arguments = @("unpack") +$arguments += $args + +# Add the path to the archive +$arguments += $archivePath + +& $pixiPackPath $arguments +if ($LASTEXITCODE -ne 0) { + Remove-Item -Path $TEMPDIR -Recurse -Force + exit $LASTEXITCODE +} + +Remove-Item -Path $TEMPDIR -Recurse -Force + +exit 0 + +__END_HEADER__ diff --git a/tests/snapshots/integration_test__sha256-linux-64-executable.snap b/tests/snapshots/integration_test__sha256-linux-64-executable.snap index 499c9c0..b6d3c2f 100644 --- a/tests/snapshots/integration_test__sha256-linux-64-executable.snap +++ b/tests/snapshots/integration_test__sha256-linux-64-executable.snap @@ -1,7 +1,7 @@ --- source: tests/integration_test.rs -assertion_line: 352 +assertion_line: 358 expression: "&sha256_digest" snapshot_kind: text --- -5A797AC80010BCFCE103F53892CDEA582C82364264CE6C4FF8EF5643F23CD3BD +00FFF8329F4CCECC1BC5D5210770ABDF61DFA471288A5265D6C171BE705E416E diff --git a/tests/snapshots/integration_test__sha256-linux-aarch64-executable.snap b/tests/snapshots/integration_test__sha256-linux-aarch64-executable.snap index 663668e..eb8ec31 100644 --- a/tests/snapshots/integration_test__sha256-linux-aarch64-executable.snap +++ b/tests/snapshots/integration_test__sha256-linux-aarch64-executable.snap @@ -1,7 +1,7 @@ --- source: tests/integration_test.rs -assertion_line: 352 +assertion_line: 358 expression: "&sha256_digest" snapshot_kind: text --- -2D9DACCC1641D534A8B4003F121296F37D550C07B87108DFBE135D06FDD5D8A2 +A54DBE60FBFE8FAC7D5334D899092DDAE7154E829F4E817ED38442FBEDC710AE diff --git a/tests/snapshots/integration_test__sha256-osx-64-executable.snap b/tests/snapshots/integration_test__sha256-osx-64-executable.snap index 08df1f0..e513e5b 100644 --- a/tests/snapshots/integration_test__sha256-osx-64-executable.snap +++ b/tests/snapshots/integration_test__sha256-osx-64-executable.snap @@ -1,7 +1,7 @@ --- source: tests/integration_test.rs -assertion_line: 352 +assertion_line: 358 expression: "&sha256_digest" snapshot_kind: text --- -5D75D036EA7C29A43E15755D79381827A34B3160026776AC3D5A53B2073082B8 +5DD69B8319D10E1B210404C096FC2621F701EEBFAA1DB047922A249D6D34B80C diff --git a/tests/snapshots/integration_test__sha256-osx-arm64-executable.snap b/tests/snapshots/integration_test__sha256-osx-arm64-executable.snap index d478955..619a499 100644 --- a/tests/snapshots/integration_test__sha256-osx-arm64-executable.snap +++ b/tests/snapshots/integration_test__sha256-osx-arm64-executable.snap @@ -1,7 +1,7 @@ --- source: tests/integration_test.rs -assertion_line: 352 +assertion_line: 358 expression: "&sha256_digest" snapshot_kind: text --- -906049EA301E1E033E5AF4E12630B0A0C4BDD60D7F6F05741F0A10F3638214A6 +DA8DCC36D8F284F7CB4882F32C6AB7BE34A9A59BDC18839109C9F10C737B0CEE diff --git a/tests/snapshots/integration_test__sha256-win-64-executable.snap b/tests/snapshots/integration_test__sha256-win-64-executable.snap index 4753e8a..47d841c 100644 --- a/tests/snapshots/integration_test__sha256-win-64-executable.snap +++ b/tests/snapshots/integration_test__sha256-win-64-executable.snap @@ -1,7 +1,7 @@ --- source: tests/integration_test.rs -assertion_line: 366 +assertion_line: 358 expression: "&sha256_digest" snapshot_kind: text --- -D651688B08263EA415C95AF1298D337088953CD260BFFC1AB287D75E2F467D2A +66EE65C5068E586279361987E7F3921F9159619827439946FE32A61C2A8B5C39