mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-08 16:20:29 +00:00
enhance: test on Windows and fix what it found (#1348)
Adds a weekly and on-demand workflow that runs the cross-compiled tests on Windows Server 2025 Core in a [dockur/windows](https://github.com/dockur/windows) QEMU VM, and fixes the Windows bugs it found in host and UNC paths, env handling, shell quoting, post-task scripts, health checks, checkout, action symlinks, step summaries, Git client certificates and docker mode from a Windows host. Host-mode steps now emit UTF-8, `bash` falls back to Git's bash instead of the WSL launcher, the runner can run as a native Windows service, steps can keep background helpers with `RUNNER_TRACKING_ID`, and Windows arm64 binaries are released. Fixes: https://gitea.com/gitea/runner/issues/1339 Fixes: https://gitea.com/gitea/runner/issues/637 Fixes: https://gitea.com/gitea/runner/issues/1172 Fixes: https://gitea.com/gitea/runner/issues/347 Reviewed-on: https://gitea.com/gitea/runner/pulls/1348 Reviewed-by: bircni <[email protected]>
This commit is contained in:
1 parent
6e42621b4a
commit
d6f5b68a0d
85 files changed
+2578
-620
No files matched your search
@@ -4,69 +4,25 @@
|
||||
package process
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// startOrphanMaker starts a process that spawns a detached, long-lived child and
|
||||
// exits, leaving the child parentless. Returns the cmd and the child's PID file.
|
||||
func startOrphanMaker(t *testing.T) (*exec.Cmd, string) {
|
||||
t.Helper()
|
||||
|
||||
pidFile := filepath.Join(t.TempDir(), "child.pid")
|
||||
script := fmt.Sprintf(
|
||||
`$c = Start-Process powershell -PassThru -ArgumentList '-NoProfile','-Command','Start-Sleep -Seconds 600'; `+
|
||||
`Set-Content -LiteralPath %q -Value $c.Id`, pidFile)
|
||||
|
||||
cmd := exec.Command("powershell.exe", "-NoProfile", "-Command", script)
|
||||
require.NoError(t, cmd.Start())
|
||||
t.Cleanup(func() { _ = cmd.Process.Kill() })
|
||||
|
||||
return cmd, pidFile
|
||||
}
|
||||
|
||||
// awaitChildPID waits until the spawned child has reported its PID and is running.
|
||||
func awaitChildPID(t *testing.T, pidFile string) int {
|
||||
t.Helper()
|
||||
|
||||
var childPID int
|
||||
require.Eventually(t, func() bool {
|
||||
b, err := os.ReadFile(pidFile)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
s := strings.TrimSpace(string(b))
|
||||
if s == "" {
|
||||
return false
|
||||
}
|
||||
childPID, _ = strconv.Atoi(s)
|
||||
return childPID > 0 && processAlive(childPID)
|
||||
}, 20*time.Second, 200*time.Millisecond, "child process should start")
|
||||
|
||||
return childPID
|
||||
}
|
||||
|
||||
// TestGroupClosePropagatesToOrphan covers what the per-step Killer cannot: a
|
||||
// completed step's orphan, reachable only by closing the job object.
|
||||
func TestGroupClosePropagatesToOrphan(t *testing.T) {
|
||||
group, err := NewGroup()
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { _ = group.Close() })
|
||||
|
||||
cmd, pidFile := startOrphanMaker(t)
|
||||
cmd, ready := newTestProcess(t, "orphan", false)
|
||||
require.NoError(t, cmd.Start())
|
||||
require.NoError(t, group.Assign(cmd.Process))
|
||||
|
||||
childPID := awaitChildPID(t, pidFile)
|
||||
childPID := ready()
|
||||
|
||||
require.NoError(t, cmd.Wait()) // the step process exits cleanly, like a passing step
|
||||
require.NoError(t, cmd.Wait())
|
||||
require.Eventually(t, func() bool {
|
||||
return !processAlive(cmd.Process.Pid)
|
||||
}, 20*time.Second, 200*time.Millisecond, "the step process should have exited on its own")
|
||||
|
||||
Reference in new issue
Block a user