mirror of
https://gitea.com/gitea/act_runner
synced 2026-09-21 19:37:07 +02:00
fix: prepare macOS VM workspace and archive without AppleDouble
This commit is contained in:
@@ -164,7 +164,7 @@ func (e *MacOSVMEnvironment) CopyDir(destPath, srcPath string, useGitIgnore bool
|
|||||||
writeDone <- err
|
writeDone <- err
|
||||||
}()
|
}()
|
||||||
|
|
||||||
script := `mkdir -p "$1" && /usr/bin/tar -xf - -C "$1"`
|
script := `export COPYFILE_DISABLE=1; mkdir -p "$1" && /usr/bin/tar -xf - -C "$1"`
|
||||||
cmdErr := e.runExecutor(ctx, pipeReader, e.Stdout, e.Stderr, "exec", "--stdin", e.VMName, "/bin/sh", "-c", script, "sh", destPath)
|
cmdErr := e.runExecutor(ctx, pipeReader, e.Stdout, e.Stderr, "exec", "--stdin", e.VMName, "/bin/sh", "-c", script, "sh", destPath)
|
||||||
_ = pipeReader.Close()
|
_ = pipeReader.Close()
|
||||||
writeErr := <-writeDone
|
writeErr := <-writeDone
|
||||||
@@ -203,7 +203,7 @@ func (e *MacOSVMEnvironment) GetContainerArchive(ctx context.Context, srcPath st
|
|||||||
if common.Dryrun(ctx) {
|
if common.Dryrun(ctx) {
|
||||||
return nil, errors.New("DRYRUN is not supported in GetContainerArchive")
|
return nil, errors.New("DRYRUN is not supported in GetContainerArchive")
|
||||||
}
|
}
|
||||||
cmd := exec.CommandContext(ctx, e.executorPath, "exec", e.VMName, "/usr/bin/tar", "-cf", "-", srcPath)
|
cmd := exec.CommandContext(ctx, e.executorPath, "exec", e.VMName, "/usr/bin/env", "COPYFILE_DISABLE=1", "/usr/bin/tar", "-cf", "-", srcPath)
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -277,7 +277,7 @@ func (e *MacOSVMEnvironment) waitReady(ctx context.Context) error {
|
|||||||
|
|
||||||
var lastErr error
|
var lastErr error
|
||||||
for {
|
for {
|
||||||
if err := e.runExecutor(ctx, nil, io.Discard, io.Discard, "exec", e.VMName, "/bin/true"); err == nil {
|
if err := e.runExecutor(ctx, nil, io.Discard, io.Discard, "exec", e.VMName, "/usr/bin/true"); err == nil {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
lastErr = err
|
lastErr = err
|
||||||
|
|||||||
@@ -34,13 +34,17 @@ func TestMacOSVMEnvironmentIntegration(t *testing.T) {
|
|||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
vmName := fmt.Sprintf("gitea-runner-test-%d", time.Now().UnixNano())
|
vmName := fmt.Sprintf("gitea-runner-test-%d", time.Now().UnixNano())
|
||||||
|
base := "/Users/admin/runner"
|
||||||
|
if os.Getenv("RUNNER_EXECUTOR_MACOS_DEV_MODE") == "1" {
|
||||||
|
base = t.TempDir()
|
||||||
|
}
|
||||||
env, err := NewMacOSVMEnvironment(MacOSVMEnvironmentInput{
|
env, err := NewMacOSVMEnvironment(MacOSVMEnvironmentInput{
|
||||||
Path: "/Users/admin/runner/scratch/" + vmName,
|
Path: base + "/scratch/" + vmName,
|
||||||
TmpDir: "/Users/admin/runner/scratch/" + vmName + "/tmp",
|
TmpDir: base + "/scratch/" + vmName + "/tmp",
|
||||||
ToolCache: "/Users/admin/runner/scratch/" + vmName + "/tool_cache",
|
ToolCache: base + "/scratch/" + vmName + "/tool_cache",
|
||||||
Workdir: t.TempDir(),
|
Workdir: t.TempDir(),
|
||||||
GuestWorkdir: "/Users/admin/runner/workspace/" + vmName,
|
GuestWorkdir: base + "/workspace/" + vmName,
|
||||||
ActPath: "/Users/admin/runner/scratch/" + vmName + "/act",
|
ActPath: base + "/scratch/" + vmName + "/act",
|
||||||
Image: image,
|
Image: image,
|
||||||
VMName: vmName,
|
VMName: vmName,
|
||||||
ExecutorPath: "runner-executor-macos",
|
ExecutorPath: "runner-executor-macos",
|
||||||
@@ -55,6 +59,7 @@ func TestMacOSVMEnvironmentIntegration(t *testing.T) {
|
|||||||
|
|
||||||
require.NoError(t, env.Create(nil, nil)(ctx))
|
require.NoError(t, env.Create(nil, nil)(ctx))
|
||||||
require.NoError(t, env.Start(false)(ctx))
|
require.NoError(t, env.Start(false)(ctx))
|
||||||
|
require.NoError(t, os.MkdirAll(env.GuestWorkdir, 0o755))
|
||||||
|
|
||||||
require.NoError(t, env.Copy("/tmp", &FileEntry{
|
require.NoError(t, env.Copy("/tmp", &FileEntry{
|
||||||
Name: "gitea-runner-macos.txt",
|
Name: "gitea-runner-macos.txt",
|
||||||
|
|||||||
@@ -494,6 +494,7 @@ func (rc *RunContext) startMacOSVMEnvironment() common.Executor {
|
|||||||
jobContainer.Pull(rc.Config.ForcePull),
|
jobContainer.Pull(rc.Config.ForcePull),
|
||||||
jobContainer.Create(nil, nil),
|
jobContainer.Create(nil, nil),
|
||||||
jobContainer.Start(false),
|
jobContainer.Start(false),
|
||||||
|
jobContainer.Exec([]string{"/bin/mkdir", "-p", guestWorkdir, actPath, tmpDir, toolCache}, nil, "", "/"),
|
||||||
rc.captureJobContainerInfo(),
|
rc.captureJobContainerInfo(),
|
||||||
jobContainer.Copy(jobContainer.GetActPath()+"/", &container.FileEntry{
|
jobContainer.Copy(jobContainer.GetActPath()+"/", &container.FileEntry{
|
||||||
Name: "workflow/event.json",
|
Name: "workflow/event.json",
|
||||||
|
|||||||
Reference in New Issue
Block a user