-
Notifications
You must be signed in to change notification settings - Fork 674
chore: replace chocolatey with native binaries #6639
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
Open
mihaibuzgau
wants to merge
1
commit into
main
Choose a base branch
from
chore/cli-1379_useNativeWinDeps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| Param() | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| try { | ||
| $python = Get-Command python -ErrorAction SilentlyContinue | ||
| if (-not $python) { | ||
| $python = Get-Command python3 -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| if (-not $python) { | ||
| throw "Python is expected to be preinstalled on the CircleCI Windows image, but was not found." | ||
| } | ||
|
|
||
| Write-Host "Using Python at $($python.Path)" | ||
|
|
||
| try { | ||
| & $python.Path -m pip install --upgrade pip | ||
| } | ||
| catch { | ||
| Write-Host "Failed to upgrade pip, continuing: $($_.Exception.Message)" | ||
| } | ||
|
|
||
| & $python.Path -m pip install uv | ||
| } | ||
| catch { | ||
| Write-Error "Failed to ensure Python/uv: $($_.Exception.Message)" | ||
| exit 1 | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| Param() | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| # Load previously persisted tool PATH entries if present | ||
| $envScript = 'C:\tools-cache\snyk-env.ps1' | ||
| if (Test-Path $envScript) { | ||
| . $envScript | ||
| } | ||
|
|
||
| try { | ||
| $dotnetVersion = '8.0.100' | ||
| $cacheDir = 'C:\tools-cache' | ||
| $installerPath = Join-Path $cacheDir "dotnet-sdk-$dotnetVersion-win-x64.exe" | ||
| $expectedSha256 = 'd77a87a78264fcfb1703a7064795ccb10938cdfaea64a03cb0f36b1cda379f82' | ||
|
|
||
| if (-not (Test-Path $cacheDir)) { | ||
| New-Item -ItemType Directory -Path $cacheDir | Out-Null | ||
| } | ||
|
|
||
| if (-not (Test-Path $installerPath)) { | ||
| Write-Host "Downloading .NET SDK $dotnetVersion installer..." | ||
| $url = "https://builds.dotnet.microsoft.com/dotnet/Sdk/$dotnetVersion/dotnet-sdk-$dotnetVersion-win-x64.exe" | ||
| curl.exe -L $url -o $installerPath | ||
| } | ||
|
|
||
| Write-Host 'Verifying .NET SDK installer checksum...' | ||
| $hash = Get-FileHash -Path $installerPath -Algorithm SHA256 | ||
| if ($hash.Hash.ToLower() -ne $expectedSha256.ToLower()) { | ||
| throw "Checksum verification failed for $installerPath. Expected $expectedSha256 but got $($hash.Hash.ToLower())." | ||
| } | ||
|
|
||
| Write-Host "Installing .NET SDK $dotnetVersion..." | ||
| & $installerPath /install /quiet /norestart /log "$cacheDir\dotnet-sdk-install.log" | ||
|
|
||
| # Locate installed dotnet.exe using the known default installation path (%ProgramFiles%\dotnet) | ||
| $dotnetExe = "C:\Program Files\dotnet\dotnet.exe" | ||
| if (-not (Test-Path $dotnetExe)) { | ||
| throw ".NET SDK $dotnetVersion did not install correctly; expected $dotnetExe to exist." | ||
| } | ||
|
|
||
| $dotnetPath = Split-Path $dotnetExe -Parent | ||
|
|
||
| Write-Host "Adding $dotnetPath to PATH for current session..." | ||
| $Env:Path = "$dotnetPath;" + $Env:Path | ||
|
|
||
| try { | ||
| if (-not (Test-Path $profile)) { | ||
| New-Item -Path $profile -ItemType File -Force | Out-Null | ||
| } | ||
| $pathUpdateLine = '$Env:Path = "' + $dotnetPath + ';" + $Env:Path' | ||
| $profileContent = Get-Content -Path $profile -ErrorAction SilentlyContinue | ||
| if (-not $profileContent -or -not ($profileContent -contains $pathUpdateLine)) { | ||
| $pathUpdateLine | Out-File -FilePath $profile -Append -Encoding UTF8 | ||
| } | ||
| } | ||
| catch { | ||
| Write-Host "Warning: failed to persist .NET PATH update to profile: $($_.Exception.Message)" | ||
| } | ||
|
|
||
| # Append PATH update to shared environment script for CircleCI steps | ||
| try { | ||
| $envScript = 'C:\tools-cache\snyk-env.ps1' | ||
| if (-not (Test-Path $envScript)) { | ||
| New-Item -Path $envScript -ItemType File -Force | Out-Null | ||
| } | ||
| $pathUpdateLine = '$Env:Path = "' + $dotnetPath + ';" + $Env:Path' | ||
| $existing = Get-Content -Path $envScript -ErrorAction SilentlyContinue | ||
| if (-not $existing -or -not ($existing -contains $pathUpdateLine)) { | ||
| $pathUpdateLine | Out-File -FilePath $envScript -Append -Encoding UTF8 | ||
| } | ||
| } | ||
| catch { | ||
| Write-Host "Warning: failed to persist .NET PATH update to env script: $($_.Exception.Message)" | ||
| } | ||
| } | ||
| catch { | ||
| Write-Error "Failed to install .NET SDK: $($_.Exception.Message)" | ||
| exit 1 | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: This block adds quite some duplication which is difficult to maintain just to load environment variables, is there a way to avoid this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: maybe re-use this approach.