-
Notifications
You must be signed in to change notification settings - Fork 303
149 lines (129 loc) · 5.03 KB
/
Copy pathe2e-test-event-writer.yml
File metadata and controls
149 lines (129 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Build E2E Test Event Writer
on:
workflow_call:
pull_request:
push:
branches:
- main
- "dev/**"
workflow_dispatch:
permissions:
contents: read
id-token: write
packages: write
env:
EVENT_WRITER_PATH: "${{ github.workspace }}/test/e2e/tools/event-writer/"
EBPF_VERSION: "1.1.0"
XDP_SDK_VERSION: "1.3.0"
jobs:
retina-win-e2e-bpf-images:
name: Build E2E Test Event Writer
runs-on: windows-2022
env:
PUBLISH_TO_ACR: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
platform: ["windows"]
arch: ["amd64"]
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Azure Login
uses: azure/login@f5d393ae46f8fde4be8b75f32e3fc50e654ad0ca # v3.0.1
if: ${{ env.PUBLISH_TO_ACR == 'true' }}
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION }}
- name: Ensure Docker daemon is running
shell: pwsh
run: |
$timeout = 120
$timer = [Diagnostics.Stopwatch]::StartNew()
while ($timer.Elapsed.TotalSeconds -lt $timeout) {
$svc = Get-Service docker -ErrorAction SilentlyContinue
if ($svc -and $svc.Status -ne 'Running') {
Start-Service docker -ErrorAction SilentlyContinue
}
$result = docker info 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "Docker daemon is ready"
return
}
Write-Host "Waiting for Docker daemon to start..."
Start-Sleep -Seconds 5
}
throw "Docker daemon failed to start within $timeout seconds"
- name: Docker Login to ACR
if: ${{ env.PUBLISH_TO_ACR == 'true' }}
shell: pwsh
run: az acr login --name "${{ vars.ACR_NAME }}"
- name: Docker Login to ghcr.io
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
if: ${{ env.PUBLISH_TO_ACR != '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.${{ env.EBPF_VERSION }}\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 /v:detailed 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: |
$publishToAcr = "${{ env.PUBLISH_TO_ACR }}" -eq "true"
if (-not $publishToAcr) {
$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" .
if ("${{ github.event_name }}" -ne "pull_request") {
docker push "${image}:${tag}"
docker push "${image}:latest"
} else {
Write-Host "Skipping image push for pull_request runs"
}