mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-10-29 03:16:43 +08:00
After https://gitea.com/gitea/runner/pulls/1304, logrus stayed only to forward logs from docker/cli and moby/go-archive. The runner used a small part of those: volume parsing, the build context tar, the `ssh://` connection and registry credentials. Own code that matches them replaces them, so logrus leaves the module graph. docker/cli stays for its logrus-free `opts` and `connhelper/ssh` packages. Other dependencies that the standard library or existing ones cover go too: mergo, httprouter (replaced by `http.ServeMux`), retry-go, go-isatty, go-selinux, container-device-interface, gotest.tools and go-cmp (replaced by testify). The binary shrinks by 5%. Behaviour differences: 1. An unreadable file in a build context is skipped with a warning, where go-archive left a truncated tar. 2. Build contexts no longer carry `security.capability` xattrs. 3. The cache and artifact servers answer HEAD on GET routes, and no longer redirect trailing slashes or answer OPTIONS. *Written by Claude.* --------- Co-authored-by: bircni <bircni@icloud.com> Reviewed-on: https://gitea.com/gitea/runner/pulls/1319 Reviewed-by: bircni <bircni@icloud.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <2021+silverwind@noreply.gitea.com>
36 lines
1006 B
Go
36 lines
1006 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build !WITHOUT_DOCKER && (linux || darwin || netbsd)
|
|
|
|
package container
|
|
|
|
import (
|
|
"archive/tar"
|
|
"os"
|
|
"path/filepath"
|
|
"syscall"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateBuildContextKeepsHardlinkedSpecialFilesLinked(t *testing.T) {
|
|
dir := t.TempDir()
|
|
require.NoError(t, syscall.Mkfifo(filepath.Join(dir, "first"), 0o644))
|
|
require.NoError(t, os.Link(filepath.Join(dir, "first"), filepath.Join(dir, "second")))
|
|
|
|
buildContext, err := createBuildContext(t.Context(), dir, "Dockerfile")
|
|
require.NoError(t, err)
|
|
defer buildContext.Close()
|
|
reader := tar.NewReader(buildContext)
|
|
first, err := reader.Next()
|
|
require.NoError(t, err)
|
|
assert.Equal(t, byte(tar.TypeFifo), first.Typeflag)
|
|
second, err := reader.Next()
|
|
require.NoError(t, err)
|
|
assert.Equal(t, byte(tar.TypeLink), second.Typeflag)
|
|
assert.Equal(t, first.Name, second.Linkname)
|
|
}
|