Skip to content

Build Socket 2.1 prerelease as a Node 27 SEA #49

Build Socket 2.1 prerelease as a Node 27 SEA

Build Socket 2.1 prerelease as a Node 27 SEA #49

Workflow file for this run

name: Bazel on Windows
on:
pull_request:
branches: [main, v1.x]
paths:
- .github/workflows/bazel-windows.yml
- package.json
- pnpm-lock.yaml
- src/commands/manifest/bazel/**
- test/fixtures/manifest-bazel/**
push:
branches: [main, v1.x]
paths:
- .github/workflows/bazel-windows.yml
- package.json
- pnpm-lock.yaml
- src/commands/manifest/bazel/**
- test/fixtures/manifest-bazel/**
permissions:
contents: read
concurrency:
group: bazel-windows-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
maven:
name: Maven on Windows x64
runs-on: windows-2022
timeout-minutes: 45
defaults:
run:
shell: pwsh
steps:
- name: Checkout source
env:
CHECKOUT_REF: ${{ github.sha }}
GITHUB_TOKEN: ${{ github.token }}
SERVER_URL: ${{ github.server_url }}
REPOSITORY: ${{ github.repository }}
run: |
$PSNativeCommandUseErrorActionPreference = $true
git init -q
git config --local advice.detachedHead false
git remote add origin "$env:SERVER_URL/$env:REPOSITORY"
$auth = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("x-access-token:$env:GITHUB_TOKEN"))
$env:GIT_CONFIG_COUNT = '1'
$env:GIT_CONFIG_KEY_0 = "http.$env:SERVER_URL/.extraheader"
$env:GIT_CONFIG_VALUE_0 = "AUTHORIZATION: basic $auth"
git fetch --no-tags --depth=1 origin $env:CHECKOUT_REF
git checkout -q --detach FETCH_HEAD
- name: Install pinned toolchains
run: |
$tools = Join-Path $env:RUNNER_TEMP 'bazel-tools'
New-Item -ItemType Directory -Force "$tools/bin" | Out-Null
function Get-VerifiedTool($url, $file, $sha256) {
Invoke-WebRequest -Uri $url -OutFile $file
if ((Get-FileHash $file -Algorithm SHA256).Hash.ToLowerInvariant() -ne $sha256) {
throw "Checksum mismatch for $file"
}
}
Get-VerifiedTool 'https://nodejs.org/dist/v24.14.1/node-v24.14.1-win-x64.zip' "$tools/node.zip" '6e50ce5498c0cebc20fd39ab3ff5df836ed2f8a31aa093cecad8497cff126d70'
Get-VerifiedTool 'https://api.nuget.org/v3-flatcontainer/python/3.12.10/python.3.12.10.nupkg' "$tools/python.zip" '0eb85c2dfccccf1b17352de4c397f69194035b7d37149eacc16f1147d93de3b8'
Get-VerifiedTool 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.6%2B7/OpenJDK21U-jdk_x64_windows_hotspot_21.0.6_7.zip' "$tools/java.zip" '897c8eebb0f85a99ccecbd482ebae9a45d88c19d6077054f6529ebab49b6d259'
Get-VerifiedTool 'https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-windows-amd64.exe' "$tools/bin/bazelisk.exe" '023734f33ed6b9c6d65468fe20bb2c5fb32473ccb8aca2fc5bf1521e61ce1622'
Get-VerifiedTool 'https://github.com/pnpm/pnpm/releases/download/v10.33.0/pnpm-win-x64.exe' "$tools/bin/pnpm.exe" 'afc96009dc39fe23a835d65192049e6a995f342496b175585dc2beda7d42d33f'
Expand-Archive "$tools/node.zip" "$tools/node"
Expand-Archive "$tools/python.zip" "$tools/python"
Expand-Archive "$tools/java.zip" "$tools/java"
"$tools/node/node-v24.14.1-win-x64" | Add-Content $env:GITHUB_PATH
"$tools/python/tools" | Add-Content $env:GITHUB_PATH
"$tools/java/jdk-21.0.6+7/bin" | Add-Content $env:GITHUB_PATH
"$tools/bin" | Add-Content $env:GITHUB_PATH
"JAVA_HOME=$tools/java/jdk-21.0.6+7" | Add-Content $env:GITHUB_ENV
'USE_BAZEL_VERSION=7.4.1' | Add-Content $env:GITHUB_ENV
'SOCKET_BAZEL_OUTPUT_ROOT=C:/sb' | Add-Content $env:GITHUB_ENV
New-Item -ItemType Directory -Force 'C:/sb' | Out-Null
- name: Record versions and verify prerequisites
run: |
$PSNativeCommandUseErrorActionPreference = $true
git rev-parse HEAD
node --version
pnpm --version
bazelisk --version
python --version
java -version
Write-Output "PowerShell $($PSVersionTable.PSVersion)"
Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, OSArchitecture
Get-Command node, bazelisk, python, java | Select-Object Name, Source
- name: Install dependencies and build
run: |
$PSNativeCommandUseErrorActionPreference = $true
pnpm install --frozen-lockfile
pnpm build
- name: Test executable handling and prerequisites
run: |
$PSNativeCommandUseErrorActionPreference = $true
pnpm test:unit src/commands/manifest/bazel/bazel-bin-detect.test.mts src/commands/manifest/bazel/bazel-process.test.mts src/commands/manifest/bazel/bazel-java-shim.test.mts src/commands/manifest/bazel/bazel-python-shim.test.mts src/commands/manifest/bazel/bazel-query-runner.test.mts src/commands/manifest/bazel/bazel-cquery.test.mts
- name: Install the packaged CLI
run: |
$PSNativeCommandUseErrorActionPreference = $true
$packages = Join-Path $env:RUNNER_TEMP 'bazel-packages'
$installation = Join-Path $env:RUNNER_TEMP 'bazel-installation'
pnpm pack --pack-destination $packages
$tarball = Get-ChildItem "$packages/*.tgz" | Select-Object -First 1
npm install --ignore-scripts --no-audit --no-fund --prefix $installation $tarball.FullName
"SOCKET_BAZEL_TEST_CLI=$installation/node_modules/socket/bin/cli.js" | Add-Content $env:GITHUB_ENV
- name: Verify Maven manifests and cleanup
env:
SOCKET_BAZEL_INTEGRATION: '1'
run: |
$PSNativeCommandUseErrorActionPreference = $true
pnpm exec vitest run --config vitest.e2e.config.mts src/commands/manifest/bazel/bazel-native.e2e.test.mts