-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
254 lines (222 loc) · 8.77 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
254 lines (222 loc) · 8.77 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
build_receiver_desktop_macos_aarch64:
stage: receiver_desktop
image: ghcr.io/cirruslabs/macos-ventura-xcode@sha256:3380f24929d01a7ac48a554dd242340739387822cf1cb0d96be839ef91b89daf
tags:
- macscript
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_STRATEGY: clone
# GIT_SUBMODULE_DEPTH: 1
GIT_DEPTH: 0
before_script:
- env | grep -E '^(CI_|FCAST_|R2_|CLOUDFLARE_|AWS_|CERT_)' > .cienv
script:
- cirrus run build_receiver_macos_aarch64 --artifacts-dir . --env-file .cienv
artifacts:
untracked: false
when: on_success
access: all
expire_in: "3 days"
paths:
- build_receiver_macos_aarch64/binary/target/fcast-receiver-*.dmg
- build_receiver_macos_aarch64/binary/target/fcast-receiver-*.tar.gz
when: manual
variables:
PROXMOX_HOST: "127.0.0.1"
PROXMOX_NODE: "green"
TEMPLATE_VMID: "101" # Source VM/template ID to clone
VM_NAME: "ci-runner-${CI_PIPELINE_ID}"
# CLONE_TYPE: "1" # 0 = linked, 1 = full
CLONE_TYPE: "0" # 0 = linked, 1 = full
.proxmox_auth: &proxmox_auth
# Build auth header for Proxmox API
- export PROXMOX_AUTH="PVEAPIToken=${PROXMOX_USER}!${PROXMOX_TOKEN_ID}=${PROXMOX_TOKEN_SECRET}"
provision_windows_vm_receiver:
stage: receiver_windows
image: alpine:latest
when: manual
tags:
- proxmoxshell
before_script:
- *proxmox_auth
script:
# Get next available VMID
- |
export NEXT_VMID=$(curl -s -k \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/cluster/nextid" | jq -r '.data')
echo "VMID=${NEXT_VMID}" >> provision.env
echo "Using VMID: ${NEXT_VMID}"
# Clone and capture UPID
- |
CLONE_RESPONSE=$(curl -s -k -X POST \
-H "Authorization: ${PROXMOX_AUTH}" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "newid=${NEXT_VMID}&name=${VM_NAME}&full=${CLONE_TYPE}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/qemu/${TEMPLATE_VMID}/clone")
UPID=$(echo "$CLONE_RESPONSE" | jq -r '.data')
echo "Clone task started: $UPID"
# Poll task status
- |
UPID_ENCODED=$(printf '%s' "$UPID" | jq -sRr @uri)
LATEST_TEMP=""
while true; do
TASK_STATUS=$(curl -s -k \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/tasks/${UPID_ENCODED}/status")
STATUS=$(echo "$TASK_STATUS" | jq -r '.data.status')
if [ "$STATUS" = "stopped" ]; then
EXIT_STATUS=$(echo "$TASK_STATUS" | jq -r '.data.exitstatus')
if [ "$EXIT_STATUS" = "OK" ]; then
echo "Clone completed successfully!"
break
else
echo "Clone failed: $EXIT_STATUS"
exit 1
fi
fi
# Get progress from task log
TASK_LOG=$(curl -s -k \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/tasks/${UPID_ENCODED}/log?limit=10000")
# Show the latest log line (clone progress appears here)
LATEST=$(echo "$TASK_LOG" | jq -r '.data | sort_by(.n) | last | .t // "waiting..."')
if [ "$LATEST_TEMP" != "$LATEST" ]; then
echo "Status: $STATUS | $LATEST"
LATEST_TEMP="$LATEST"
fi
sleep 5
done
# Start the VM
- |
curl -s -k -X POST \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/qemu/${NEXT_VMID}/status/start"
# Wait for VM to get an IP (via QEMU guest agent)
- |
echo "Waiting for VM to boot and get IP..."
for i in $(seq 1 60); do
IP=$(curl -s -k \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/qemu/${NEXT_VMID}/agent/network-get-interfaces" 2>/dev/null \
| jq -r '.data.result[]? | select(.name != "Loopback Pseudo-Interface 1") | ."ip-addresses"[]? | select(."ip-address-type" == "ipv4") | ."ip-address"' \
| head -1)
if [ -n "$IP" ] && [ "$IP" != "null" ]; then
echo "VM_IP=${IP}" >> provision.env
echo "VM is up at: ${IP}"
break
fi
echo "Waiting for Start and IP... (${i}/60)"
sleep 10
done
artifacts:
reports:
dotenv: provision.env
build_receiver_for_win_x64:
stage: receiver_windows
image: alpine:latest
tags:
- proxmoxshell
allow_failure: true
needs:
- job: provision_windows_vm_receiver
artifacts: true
script:
# Wait for SSH to be ready
- |
for i in $(seq 1 30); do
if sshpass -p "${PROXMOX_WIN_PASSWORD}" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 "${PROXMOX_WIN_USER}@${VM_IP}" "echo ready" 2>/dev/null; then
echo "SSH is ready!"
break
fi
echo "Waiting for SSH... ($i/30)"
sleep 10
done
- |
sshpass -p "${PROXMOX_WIN_PASSWORD}" ssh -o StrictHostKeyChecking=no "${PROXMOX_WIN_USER}@${VM_IP}" powershell -NoProfile -NonInteractive -Command - <<PS
Set-ExecutionPolicy Bypass -Scope Process -Force
Set-PSDebug -Trace 1
winget install --id Git.Git -e --source winget
\$env:PATH += ";C:\Program Files\Git\bin"
Start-Job -ScriptBlock {
winget install --id=NASM.NASM -e --accept-package-agreements --accept-source-agreements
winget install --id=Kitware.CMake -e --accept-package-agreements --accept-source-agreements
winget install --id=LLVM.LLVM -e --accept-package-agreements --accept-source-agreements
winget install --id=Python.Python.3.14 -e --accept-package-agreements --accept-source-agreements
winget install --id=Ninja-build.Ninja -e --accept-package-agreements --accept-source-agreements
winget install --id=Google.flatbuffers -e --accept-package-agreements --accept-source-agreements
}
Start-Job -ScriptBlock {
rustup self update
rustup install nightly
rustup default nightly
}
git clone --recursive --depth=1 "https://gitlab.futo.org/videostreaming/fcast-receiver-windows-build-deps.git"
git clone --recursive --depth=1 -b ${CI_COMMIT_REF_NAME} "https://gitlab.futo.org/videostreaming/fcast.git"
Get-Job | Wait-Job
Get-Job | Receive-Job
Get-Job | Remove-Job
cd fcast-receiver-windows-build-deps
Start-Process 'msiexec.exe' -ArgumentList '/i "wix-cli-x64.msi" /qn' -Wait
cd ..
\$env:PATH += ";C:\Users\\\$Env:UserName\AppData\Local\bin\NASM"
\$env:PATH += ";C:\Program Files\CMake\bin"
\$env:PATH += ";C:\Program Files\LLVM\bin"
\$env:PATH += ";C:\Users\\\$Env:UserName\AppData\Local\Programs\Python\Python314\"
\$env:PATH += ";C:\Users\\\$Env:UserName\AppData\Local\Programs\Python\Python314\Scripts"
\$env:PATH += ";C:\Users\\\$Env:UserName\AppData\Local\Programs\Python\Launcher"
\$env:PATH += ";C:\Users\\\$Env:UserName\AppData\Roaming\Python\Python314\Scripts"
\$env:PATH += ";C:\Users\\\$Env:UserName\AppData\Local\Microsoft\WinGet\Links\"
\$env:PATH += ";C:\Program Files\WiX Toolset v6.0\bin"
\$env:CC = "clang-cl"
\$env:CXX = "clang-cl"
cd fcast
pip3 install meson pkgconf
\$env:PKG_CONFIG = (python -c "import pkgconf; print(pkgconf.get_executable())")
cargo xtask receiver build-windows-installer --gst-ref 1.29.2
PS
- |
sshpass -p "${PROXMOX_WIN_PASSWORD}" scp -o StrictHostKeyChecking=no "${PROXMOX_WIN_USER}@${VM_IP}:C:/Users/${PROXMOX_WIN_USER}/fcast/target/win-build/*.msi" .
artifacts:
untracked: false
when: on_success
access: all
expire_in: "3 days"
paths:
- ./*.msi
cleanup_vm_receiver:
stage: receiver_windows
image: alpine:latest
tags:
- proxmoxshell
needs:
- job: provision_windows_vm_receiver
artifacts: true
- job: build_receiver_for_win_x64
before_script:
- *proxmox_auth
script:
# Stop the VM
- |
curl -s -k -X POST \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/qemu/${VMID}/status/stop"
# Wait for VM to stop
- |
echo "Waiting for VM to stop..."
for i in $(seq 1 30); do
STATUS=$(curl -s -k \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/qemu/${VMID}/status/current" | jq -r '.data.status')
if [ "$STATUS" = "stopped" ]; then
echo "VM stopped!"
break
fi
sleep 5
done
# Delete the VM
- |
curl -s -k -X DELETE \
-H "Authorization: ${PROXMOX_AUTH}" \
"https://${PROXMOX_HOST}:8006/api2/json/nodes/${PROXMOX_NODE}/qemu/${VMID}"
echo "VM ${VMID} deleted"