Skip to content

chore: update dockerfile for shell in Windows CI #193

chore: update dockerfile for shell in Windows CI

chore: update dockerfile for shell in Windows CI #193

name: Build E2E Test Event Writer
on:
pull_request:
push:
branches:
- main
- "dev/**"
merge_group:
types: [checks_requested]
workflow_dispatch:
permissions:
contents: read
id-token: write
packages: write
env:
EVENT_WRITER_PATH: "${{ github.workspace }}/test/e2e/tools/event-writer/"
jobs:
retina-win-e2e-bpf-images:
name: Build E2E Test Event Writer
runs-on: windows-2022
env:
IS_MERGE_GROUP: ${{ (github.event_name == 'merge_group') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev/v0.0.33-windows' && github.repository == 'microsoft/retina') }}
strategy:
matrix:
platform: ["windows"]
arch: ["amd64"]
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Azure Login
uses: azure/login@v2
if: ${{ env.IS_MERGE_GROUP == 'true' }}
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Docker Login to ghcr.io
uses: docker/login-action@v3
if: ${{ env.IS_MERGE_GROUP != 'true' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set MSBuild path
run: |
echo "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install LLVM 18.1.8
shell: pwsh
run: |
# Install LLVM 18.1.8 to ensure consistent version across runners
try {
choco install llvm --version=18.1.8 --allow-downgrade -y --force
# 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-Host "Successfully installed LLVM 18.1.8"
} catch {
Write-Warning "Failed to install LLVM 18.1.8 via chocolatey: $($_.Exception.Message)"
Write-Host "Continuing with pre-installed LLVM version"
}
- name: Nuget Restore
shell: cmd
run: |
nuget restore .\event_writer.sln
working-directory: ${{ env.EVENT_WRITER_PATH }}
- name: Configure eBPF store
shell: cmd
run: |
.\export_program_info.exe --clear
.\export_program_info.exe
working-directory: ${{ env.EVENT_WRITER_PATH }}\packages\eBPF-for-Windows.x64.0.21.1\build\native\bin
- name: Build Event-Writer
shell: cmd
run: |
msbuild /m /t:Clean /p:Configuration=Release /p:Platform=x64 /restore event_writer.sln
msbuild /m /p:Configuration=Release /p:Platform=x64 /restore event_writer.sln
working-directory: ${{ env.EVENT_WRITER_PATH }}
- name: Determine Docker tag
id: tag
shell: pwsh
run: |
$TAG = $(git tag --points-at HEAD)
if (-not $TAG) {
$TAG = $(git rev-parse --short HEAD)
}
echo "tag=$TAG" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Build and push images
shell: pwsh
working-directory: ${{ env.EVENT_WRITER_PATH }}
run: |
$isMergeGroup = "${{ env.IS_MERGE_GROUP }}" -eq "true"
if (-not $isMergeGroup) {
$image = "ghcr.io/${{ github.repository }}/test/e2e-test-event-writer".ToLower()
} else {
$image = "${{ vars.ACR_NAME }}/${{ github.repository }}/test/e2e-test-event-writer".ToLower()
}
$tag = "${{ steps.tag.outputs.tag }}"
docker build -f "./Dockerfile" -t "${image}:${tag}" -t "${image}:latest" .
docker push "${image}:${tag}"
docker push "${image}:latest"