Skip to content

fix(grpc/exec): fix RefDec in exit's eventcache path #3097

fix(grpc/exec): fix RefDec in exit's eventcache path

fix(grpc/exec): fix RefDec in exit's eventcache path #3097

name: Windows Build and Smoke
on:
pull_request:
paths-ignore:
- "**.md"
push:
branches:
- main
- v*
paths-ignore:
- "**.md"
env:
TEMP: D:\temp
GOARCH: amd64
GOOS: windows
GOCACHE: D:\gocache
GOMODCACHE: D:\gomodcache
BUILD_CONFIGURATION: Release
BUILD_PLATFORM: x64
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
windows-ebpf-prog-build:
name: Build Windows ebpf programs
runs-on: windows-2025
timeout-minutes: 25
permissions:
contents: read
steps:
- name: Create Temp Directory
shell: pwsh
run: mkdir D:\temp
- name: Checkout Tetragon Repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- name: "Download LLVM 18.1.8"
id: download-llvm
uses: ./.github/actions/download-file
with:
file-url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/LLVM-18.1.8-win64.exe"
download-dir: "${{ runner.temp }}"
- name: Install LLVM 18.1.8
shell: pwsh
run: |
# Install LLVM 18.1.8 to ensure consistent version across runners
try {
Start-Process -FilePath "${{ steps.download-llvm.outputs.downloaded-file }}" `
-ArgumentList "/S" `
-Wait `
-NoNewWindow `
-PassThru
# Add installed LLVM to PATH first so it takes precedence
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Output "✓ Successfully installed LLVM 18.1.8"
Write-Output "Clang (LLVM):"
Write-Output " $(& 'C:\Program Files\LLVM\bin\clang.exe' --version)"
}
catch {
Write-Warning "✗ Failed to install LLVM 18.1.8: $($_.Exception.Message)"
Write-Output "Continuing with pre-installed LLVM version"
}
- name: Set up Environment Variables
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
powershell.exe "echo 'msvc_tools_path=%VCToolsInstallDir%' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
powershell.exe "echo 'msvc_tools_version=%VCToolsVersion%' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
powershell.exe "echo 'ASAN_WIN_CONTINUE_ON_INTERCEPTION_FAILURE=true' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
powershell.exe "echo 'VCINSTALLDIR=%VCINSTALLDIR%' | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append"
powershell.exe "echo '%VCINSTALLDIR%\tools\llvm\bin' | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
with:
msbuild-architecture: x64
- name: Check Clang version (MSVC)
shell: pwsh
run: |
Write-Output " $(& 'clang.exe' --version)"
- name: Check Clang version (LLVM)
shell: pwsh
run: |
Write-Output " $(& 'C:\Program Files\LLVM\bin\clang.exe' --version)"
- name: Clone msft/ntosebpfext
id: download-ntosebpfet
shell: pwsh
working-directory: ${{ runner.temp }}
run: |
git clone --recursive https://github.com/microsoft/ntosebpfext.git
cd ${{ runner.temp }}\ntosebpfext
git checkout tags/v0.6.0
- name: Copy Process_monitor.c file
shell: pwsh
run: |
Copy-Item -Path "${{ github.workspace }}/bpf/windows/process_monitor.c" `
-Destination "${{ runner.temp }}/ntosebpfext/tools/process_monitor_bpf/process_monitor.c" `
-Force
- name: Configuring repo for first build
shell: pwsh
working-directory: ${{ runner.temp }}/ntosebpfext
env:
CXXFLAGS: /ZH:SHA_256 ${{ env.CXX_FLAGS }}
LDFLAGS: ${{ env.LD_FLAGS }}
run: |
./scripts/initialize_repo.ps1
- name: Build Process monitor ebpf program
shell: pwsh
working-directory: ${{ runner.temp }}\ntosebpfext
run: |
msbuild -target:Tools\process_monitor_bpf:Rebuild `
/m `
/p:Configuration=${{ env.BUILD_CONFIGURATION }} `
/p:Platform=${{ env.BUILD_PLATFORM }} `
/bl:${{ env.BUILD_PLATFORM }}_${{ env.BUILD_CONFIGURATION }}\build_logs\build.binlog `
${{ env.BUILD_OPTIONS }} `
${{ env.SOLUTION_FILE_PATH }}
- name: Zip Build Output
shell: pwsh
working-directory: ${{ runner.temp }}/ntosebpfext
run: |
Compress-Archive `
-Path ${{ env.BUILD_PLATFORM }}/${{ env.BUILD_CONFIGURATION }} `
-DestinationPath ./build-${{ env.BUILD_PLATFORM }}.${{ env.BUILD_CONFIGURATION }}.zip
- name: Upload Build Output
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: ntosebpfext-build-output
path: ${{ runner.temp }}/ntosebpfext/build-${{ env.BUILD_PLATFORM }}.${{ env.BUILD_CONFIGURATION }}.zip
retention-days: 5
windows-tetragon-build:
name: Build, Unit Test and Upload Windows Tetragon and Tetra Binaries
runs-on: windows-2025
timeout-minutes: 15
needs: windows-ebpf-prog-build
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
# renovate: datasource=golang-version depName=go
go-version: "1.25.6"
- name: Create Temp Directories
shell: pwsh
run: |
mkdir D:\temp
mkdir D:\temp\test
- name: Build and Zip tetragon Windows binaries
working-directory: ${{ github.workspace }}
shell: pwsh
run: |
go build -o ${{ github.workspace }}/Tetra.exe ${{ github.workspace }}/cmd/tetra/
go build -o ${{ github.workspace }}/Tetragon.exe ${{ github.workspace }}/cmd/tetragon/
New-Item -ItemType Directory -Path ${{ runner.temp }}/Tetragon-Windows
Copy-Item ${{ github.workspace }}/*.exe -Destination ${{ runner.temp }}/Tetragon-Windows/
Compress-Archive -Path ${{ runner.temp }}/Tetragon-Windows/* -DestinationPath ${{ runner.temp }}/Tetragon-Windows.zip
Get-ChildItem -Recurse ${{ runner.temp }}
- name: Upload Tetragon Windows binaries
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: tetragon-windows-build-output
path: ${{ runner.temp }}/Tetragon-Windows.zip
retention-days: 5
windows-smoke-test:
name: Deploy and Test tetragon for Windows
runs-on: windows-2025
timeout-minutes: 15
needs:
- windows-tetragon-build
- windows-ebpf-prog-build
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create Temp Directories
shell: pwsh
run: |
mkdir D:\temp
mkdir D:\temp\test
- name: Download eBPF for Windows MSI
id: download-ebpf
uses: ./.github/actions/download-file
with:
file-url: "https://github.com/microsoft/ebpf-for-windows/releases/download/Release-v1.0.0-rc1/ebpf-for-windows.x64.1.0.0-rc1.msi"
download-dir: "${{ runner.temp }}"
- name: Install eBPF for Windows MSI
uses: ./.github/actions/install-msi
with:
msi-file: "${{ steps.download-ebpf.outputs.downloaded-file }}"
log-file: "${{ runner.temp }}/efw-install.log"
- name: Add eBPF for Windows to PATH
shell: pwsh
run: echo "C:/Program Files/ebpf-for-windows" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Download ntosebpfext-build-output
id: download-ntosebpfext-build-output
uses: ./.github/actions/download-artifact
with:
artifact-name: "ntosebpfext-build-output"
download-dir: "${{ runner.temp }}/staging"
- name: Download tetragon-windows-build-output
id: download-tetragon-windows-build-output
uses: ./.github/actions/download-artifact
with:
artifact-name: "tetragon-windows-build-output"
download-dir: "${{ runner.temp }}/staging"
- name: Setup Tetragon for Windows
shell: pwsh
working-directory: ${{ github.workspace }}
run: |
${{ github.workspace }}/install/windows/setup-windows.ps1 `
${{ runner.temp }}/staging/tetragon-windows-build-output/Tetragon-Windows.zip `
${{ runner.temp }}/staging/ntosebpfext-build-output/build-x64.Release.zip
- name: Run Smoke test Windows
shell: pwsh
working-directory: C:\Program Files\Tetragon\cmd
#env:
# PATH: ${{ runner.temp }};"C:\Program Files\ebpf-for-windows"
run: |
# Tests
Write-Output "::group::PATH:"
$env:Path -split ';'
Write-Output "::endgroup::"
$jsonFilePath = "C:\Program Files\Tetragon\events.json"
# Start the process in the background and capture its PID
$TetragonArgs = @(
'--export-filename "' + $jsonFilePath + '"'
)
$tetragonBackgroundProcess = Start-Process `
-FilePath "C:\Program Files\Tetragon\cmd\Tetragon.exe" `
-WorkingDirectory "C:\Program Files\Tetragon\cmd" `
-ArgumentList $TetragonArgs `
-RedirectStandardOutput "C:\Program Files\Tetragon\tetragon.log" `
-NoNewWindow `
-PassThru
Start-Sleep -Seconds 5
if(Get-Process -id $tetragonBackgroundProcess.Id) {
Write-Output "✓ Tetragon is Running"
}
else {
throw "✗ Tetragon Could not be started"
}
# Run notepad and look for it in event log
$notepad = Start-Process -FilePath "C:\Windows\System32\notepad.exe" -PassThru
$notepadPID = $notepad.Id
Write-Host "Process launched with PID: $notepadPID"
$searchString = "\{\""process_exec\""\:\{\""process\""\:\{\""exec_id\""\:\"".{16,30}\""\,.{0,1}\""pid\""\:$notepadPID\,.{0,1}\""uid\""\:[0-9]{0,9}\,.{0,1}\""binary\""\:\""C:\\\\Windows\\\\system32\\\\notepad.exe\"""
Write-Host "Looking for regex: $searchString"
$jsonContent = Get-Content -Path $jsonFilePath
# Search for the PID in the JSON file
if ($jsonContent -match $searchString) {
Write-Host "Found PID $notepadPID in JSON file: $searchString"
} else {
Write-Host "PID $notepadPID not found in event file: $jsonContent "
throw "PID not found in event JSON file."
}