amoeba commented on code in PR #2858:
URL: https://github.com/apache/arrow-adbc/pull/2858#discussion_r2635516609


##########
.github/workflows/native-windows.yml:
##########
@@ -260,16 +260,19 @@ jobs:
         with:
           fetch-depth: 0
           persist-credentials: false
-      - uses: 
bwoodsend/setup-winlibs-action@ceefd070f6288838003797de3b06d7bc01e52842  # v1.16
-        id: winlibs-64
-        with:
-          runtime: ucrt
-          add_to_path: true
-      - name: Remove default mingw from PATH
+      - name: Setup Winlibs posix UCRT
         shell: pwsh
         run: |
-          # Remove mingw64 bin from PATH to avoid conflicts with winlibs
-          $env:PATH = $env:PATH -replace [regex]::Escape("C:\mingw64\bin;"), 
"" -replace [regex]::Escape(";C:\mingw64\bin"), ""
+          $winlibsTags = Invoke-RestMethod 
"https://api.github.com/repos/brechtsanders/winlibs_mingw/tags";
+          $latestWinlibsTag = ($winlibsTags | Where-Object { $_.name -match 
"posix.*ucrt" -and $_.name -notmatch "snapshot" })[0].name
+          $latestWinlibsRelease = Invoke-RestMethod 
"https://api.github.com/repos/brechtsanders/winlibs_mingw/releases/tags/$latestWinlibsTag";
+          $latestWinlibsAsset = $latestWinlibsRelease.assets | Where-Object { 
$_.name -like "winlibs-x86_64-posix-seh-gcc-*-mingw-w64ucrt-*.7z" } | 
Select-Object -First 1
+          $latestWinlibsArchive = "$env:TEMP\latestWinlibs.7z"
+          Invoke-WebRequest $latestWinlibsAsset.browser_download_url -OutFile 
$latestWinlibsArchive
+          7z x $latestWinlibsArchive -o"$env:LOCALAPPDATA" -y
+          $winlibsMingwBin = Join-Path $env:LOCALAPPDATA "mingw64\bin"
+          $env:PATH="$winlibsMingwBin;${env:PATH}"
+

Review Comment:
   Nice. A couple of things that would be good to change:
   
   1. Pin to a specific release and verify the hash of the download is correct
   2. Set up caching to save time and resources
   
   Could you test something like this? I tested some of the commands but 
haven't tested all the steps.
   
   ```
   - name: Set Winlibs version
     id: winlibs-version
     shell: pwsh
     run: |
       $winlibs_asset_name = 
"winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64msvcrt-13.0.0-r4.7z"
       echo "winlibs_asset_name=$winlibs_asset_name" >> $env:GITHUB_OUTPUT
   
   - name: Cache Winlibs
     id: cache-winlibs
     uses: actions/cache@v5
     with:
       path: ~/winlibs
       key: winlibs-${{ steps.winlibs-version.outputs.winlibs_asset_name }}
   
   - name: Download and setup Winlibs 
     if: steps.cache-winlibs.outputs.cache-hit != 'true'
     shell: pwsh
     run: |
       $base_url = 
"https://github.com/brechtsanders/winlibs_mingw/releases/download/15.2.0posix-13.0.0-msvcrt-r4/";
       $asset_name = "${{ steps.winlibs-version.outputs.winlibs_asset_name }}"
       $hash_expected = 
"7858e774c7fdb4834c30fb26723446c6032e83b7c96699bb92d3931845de1ed6"
       $url = $base_url + $asset_name
   
       Invoke-WebRequest -Uri $url -OutFile $asset_name -UseBasicParsing
       $hash_actual = (Get-FileHash -Path $asset_name -Algorithm 
SHA256).Hash.ToLower()
       if ($hash_actual -ne $hash_expected) { throw "SHA256 hash mismatch!" }
   
       7z x $asset_name -o"$HOME/winlibs" -y
   
   - name: Add Winlibs to PATH
     shell: pwsh
     run: |
       $winlibsMingwBin = Join-Path $HOME "winlibs\mingw64\bin"
       echo $winlibsMingwBin >> $env:GITHUB_PATH
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to