-
Notifications
You must be signed in to change notification settings - Fork 312
170 lines (159 loc) · 6.91 KB
/
Copy pathbuildtest.yaml
File metadata and controls
170 lines (159 loc) · 6.91 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Build and Test
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
name: Dotnet build
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Build
run: dotnet build --configuration Release
- name: Test
run: dotnet test --configuration Release --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory TestResults --settings CodeCoverage.runsettings --no-build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
directory: ./TestResults
files: '*.cobertura.xml'
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-results-${{ matrix.os }}
path: ./TestResults
if: ${{ always() }} # Always run this step even on failure
# Test code gen for visual studio compatibility >> https://github.com/kubernetes-client/csharp/pull/1008
codgen:
runs-on: windows-2025-vs2026
name: MSBuild build
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57 # v3.0.0
- name: Setup dotnet SDK
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: '10.0.1xx'
- name: Restore nugets (msbuild)
run: msbuild .\src\KubernetesClient\ -t:restore -p:RestorePackagesConfig=true
- name: Build (msbuild)
run: msbuild .\src\KubernetesClient\
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Minikube
run: minikube start
- name: Test
run: |
true > skip.log
env K8S_E2E_MINIKUBE=1 dotnet test tests/E2E.Tests --logger "SkipTestLogger;file=$PWD/skip.log" -p:BuildInParallel=false
if [ -s skip.log ]; then
cat skip.log
echo "CASES MUST NOT BE SKIPPED"
exit 1
fi
- name: AOT Test
run: |
true > skip.log
env K8S_E2E_MINIKUBE=1 dotnet test tests/E2E.Aot.Tests --logger "SkipTestLogger;file=$PWD/skip.log" -p:BuildInParallel=false
if [ -s skip.log ]; then
cat skip.log
echo "CASES MUST NOT BE SKIPPED"
exit 1
fi
# Run the .NET Framework 4.8 e2e suite (KubernetesClient.Classic) against a
# real Kubernetes cluster on Windows. There is no native Windows Kubernetes
# distribution, so the kindest/node image (which bundles containerd, kubelet
# and the control-plane components) is imported into WSL2 with oci-to-wsl.
# The Linux e2e job already covers the modern (net8/9/10) client libraries.
# WSL2 requires windows-2025 (windows-2022 only has WSL1).
e2e-windows-wsl:
runs-on: windows-2025
name: e2e classic (wsl)
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: 10.0.x
- name: Import kindest/node into WSL
uses: tg123/oci-to-wsl@902e4b0d7f3e7608dbd581e9e2fd473907a279a8 # main
with:
profile: .github/e2e/kind-wsl.yaml
- name: Start kind cluster in WSL
shell: pwsh
run: |
# Reboot the distro so the systemd configuration written by the profile
# takes effect.
wsl --shutdown
# WSL terminates the lightweight VM once its last session exits, which
# tears down the API server between steps. Hold an idle session open in
# the background so the cluster stays up for the host-side test steps.
Start-Process -FilePath wsl -ArgumentList '-d','kind','-u','root','--','sleep','infinity'
# Bring up the single node control plane in place.
wsl -d kind -u root -- bash /usr/local/bin/bootstrap-kind.sh
# Get the WSL2 VM's IP address. In NAT mode the host can reach this
# IP directly via the virtual switch.
$wslIp = ((wsl -d kind -- hostname -I).Trim() -split '\s+', 0, 'RegexMatch' | Where-Object { $_ -match '^\d+\.\d+\.\d+\.\d+$' } | Select-Object -First 1)
if (-not $wslIp) { throw "Could not determine WSL IP" }
Write-Output "WSL IP: $wslIp"
# Export a kubeconfig for the Windows host, rewriting the server URL
# to the WSL VM's IP address reachable from Windows.
wsl -d kind -u root -- cat /etc/kubernetes/admin.conf | Out-File -Encoding ascii kind.kubeconfig
(Get-Content kind.kubeconfig) -replace 'server: https://[^ ]+', "server: https://${wslIp}:6443" | Set-Content kind.kubeconfig
# .NET Framework 4.8 does not support custom trust stores, so skip TLS
# verification for the self-signed K8s CA (this is a CI-only cluster).
(Get-Content kind.kubeconfig) -replace 'certificate-authority-data:.*', 'insecure-skip-tls-verify: true' | Set-Content kind.kubeconfig
# Wait until the API server is reachable from the Windows host.
$ok = $false
foreach ($i in 1..60) {
if ((Test-NetConnection -ComputerName $wslIp -Port 6443 -WarningAction SilentlyContinue).TcpTestSucceeded) {
$ok = $true
break
}
Start-Sleep -Seconds 5
}
if (-not $ok) {
throw "API server on ${wslIp}:6443 was not reachable from the Windows host"
}
- name: Test
shell: pwsh
env:
K8S_E2E_MINIKUBE: "1"
KUBECONFIG: ${{ github.workspace }}\kind.kubeconfig
run: |
[IO.File]::WriteAllText("$PWD/skip.log", "")
dotnet test tests/E2E.Classic.Tests --logger "SkipTestLogger;file=$PWD/skip.log" -p:BuildInParallel=false
$skipContent = [IO.File]::ReadAllText("$PWD/skip.log").Trim()
if ($skipContent.Length -gt 0) {
Write-Output $skipContent
Write-Error "CASES MUST NOT BE SKIPPED"
exit 1
}
on:
pull_request:
types: [assigned, opened, synchronize, reopened]