2026-04-26 11:39:40 -04:00
|
|
|
name: CI Test
|
|
|
|
|
on:
|
|
|
|
|
push:
|
2026-05-01 14:42:56 -04:00
|
|
|
branches: [main]
|
2026-04-26 11:39:40 -04:00
|
|
|
workflow_dispatch:
|
2026-05-01 11:44:43 -04:00
|
|
|
|
|
|
|
|
env:
|
2026-05-01 14:32:47 -04:00
|
|
|
# WIN_HOST is the host machine reachable from inside the job container.
|
|
|
|
|
# Resolved at runtime to the container's default gateway, since Forgejo Runner
|
|
|
|
|
# creates a per-job Docker network whose gateway IP varies between runs.
|
2026-05-01 11:44:43 -04:00
|
|
|
WIN_PORT: 2210
|
|
|
|
|
WIN_USER: edr
|
|
|
|
|
|
2026-04-26 11:39:40 -04:00
|
|
|
jobs:
|
|
|
|
|
hello:
|
|
|
|
|
runs-on: docker
|
|
|
|
|
steps:
|
|
|
|
|
- name: Say hello
|
|
|
|
|
run: |
|
|
|
|
|
echo "Hello from Forgejo Actions!"
|
|
|
|
|
echo "Runner: $RUNNER_NAME"
|
|
|
|
|
uname -a
|
|
|
|
|
node --version
|
|
|
|
|
- name: Math check
|
|
|
|
|
run: echo "2+2 = $((2+2))"
|
2026-05-01 11:44:43 -04:00
|
|
|
|
|
|
|
|
windows-test:
|
|
|
|
|
runs-on: docker
|
|
|
|
|
steps:
|
2026-05-02 06:31:40 -04:00
|
|
|
- name: Checkout
|
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
2026-05-01 11:44:43 -04:00
|
|
|
- name: Install sshpass
|
|
|
|
|
run: |
|
|
|
|
|
apt-get update -qq
|
2026-05-01 14:32:47 -04:00
|
|
|
apt-get install -y -qq sshpass openssh-client iproute2
|
|
|
|
|
|
|
|
|
|
- name: Resolve host gateway
|
|
|
|
|
run: |
|
|
|
|
|
GW=$(ip route | awk '/default/ {print $3; exit}')
|
|
|
|
|
echo "WIN_HOST=$GW" >> "$GITHUB_ENV"
|
|
|
|
|
echo "Using host gateway: $GW"
|
2026-05-01 11:44:43 -04:00
|
|
|
|
|
|
|
|
- name: Wait for Windows VM SSH
|
|
|
|
|
env:
|
|
|
|
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
|
|
|
|
run: |
|
|
|
|
|
for i in $(seq 1 30); do
|
|
|
|
|
if sshpass -e ssh -o StrictHostKeyChecking=no -o ConnectTimeout=3 \
|
|
|
|
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" "exit" 2>/dev/null; then
|
|
|
|
|
echo "VM SSH ready"; exit 0
|
|
|
|
|
fi
|
|
|
|
|
echo "[$i/30] waiting for VM..."; sleep 5
|
|
|
|
|
done
|
|
|
|
|
echo "VM SSH never became ready"; exit 1
|
|
|
|
|
|
|
|
|
|
- name: Smoke test on Windows
|
|
|
|
|
env:
|
|
|
|
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
|
|
|
|
run: |
|
|
|
|
|
sshpass -e ssh -o StrictHostKeyChecking=no \
|
|
|
|
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" \
|
|
|
|
|
"whoami && ver && echo windows-smoke-ok"
|
|
|
|
|
|
2026-05-01 14:42:56 -04:00
|
|
|
# Verifies the revert actually wiped the previous run's marker.
|
|
|
|
|
# Fails fast if it finds C:\ci-marker.txt, which would only be there if
|
|
|
|
|
# a previous CI run left it behind and the revert step didn't restore gold.
|
|
|
|
|
- name: Verify clean baseline (no marker from prior run)
|
|
|
|
|
env:
|
|
|
|
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
|
|
|
|
run: |
|
|
|
|
|
out=$(sshpass -e ssh -o StrictHostKeyChecking=no \
|
|
|
|
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" \
|
|
|
|
|
"if exist C:\\ci-marker.txt (echo MARKER_EXISTS & type C:\\ci-marker.txt) else (echo CLEAN)")
|
|
|
|
|
echo "$out"
|
|
|
|
|
echo "$out" | grep -q "^CLEAN" || { echo "marker from previous run survived — revert is broken"; exit 1; }
|
|
|
|
|
|
2026-05-02 06:31:40 -04:00
|
|
|
- name: Copy tests into VM
|
|
|
|
|
env:
|
|
|
|
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
|
|
|
|
run: |
|
|
|
|
|
sshpass -e ssh -o StrictHostKeyChecking=no \
|
|
|
|
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" \
|
|
|
|
|
"if not exist C:\\ci mkdir C:\\ci"
|
|
|
|
|
sshpass -e scp -o StrictHostKeyChecking=no \
|
|
|
|
|
-P "$WIN_PORT" -r tests \
|
|
|
|
|
"$WIN_USER@$WIN_HOST:C:/ci/"
|
|
|
|
|
|
|
|
|
|
- name: Run PowerShell tests on Windows
|
|
|
|
|
env:
|
|
|
|
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
|
|
|
|
run: |
|
|
|
|
|
sshpass -e ssh -o StrictHostKeyChecking=no \
|
|
|
|
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" \
|
|
|
|
|
"powershell -NoProfile -ExecutionPolicy Bypass -File C:\\ci\\tests\\run-tests.ps1"
|
|
|
|
|
|
2026-05-01 14:42:56 -04:00
|
|
|
- name: Drop marker file (would persist without revert)
|
2026-05-01 11:44:43 -04:00
|
|
|
env:
|
|
|
|
|
SSHPASS: ${{ secrets.WINDOWS_SSH_PASSWORD }}
|
|
|
|
|
run: |
|
|
|
|
|
sshpass -e ssh -o StrictHostKeyChecking=no \
|
|
|
|
|
-p "$WIN_PORT" "$WIN_USER@$WIN_HOST" \
|
2026-05-01 14:42:56 -04:00
|
|
|
"echo run=${GITHUB_RUN_NUMBER} sha=${GITHUB_SHA} > C:\\ci-marker.txt && type C:\\ci-marker.txt"
|
2026-05-01 14:37:49 -04:00
|
|
|
|
|
|
|
|
# Always-runs cleanup: rolls the VM back to the gold snapshot on the host.
|
|
|
|
|
# In a separate job so it fires even when windows-test crashes mid-step.
|
|
|
|
|
revert-vm:
|
|
|
|
|
runs-on: docker
|
|
|
|
|
needs: [windows-test]
|
|
|
|
|
if: always()
|
|
|
|
|
steps:
|
|
|
|
|
- name: Install client tools
|
|
|
|
|
run: |
|
|
|
|
|
apt-get update -qq
|
|
|
|
|
apt-get install -y -qq curl iproute2
|
|
|
|
|
|
|
|
|
|
- name: Trigger revert on host
|
|
|
|
|
env:
|
|
|
|
|
REVERT_TOKEN: ${{ secrets.REVERT_TOKEN }}
|
|
|
|
|
run: |
|
|
|
|
|
GW=$(ip route | awk '/default/ {print $3; exit}')
|
|
|
|
|
echo "calling revert endpoint at $GW:8765"
|
|
|
|
|
curl -fsSL --max-time 90 -X POST \
|
|
|
|
|
-H "Authorization: Bearer $REVERT_TOKEN" \
|
|
|
|
|
"http://$GW:8765/revert"
|