push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
diff --git a/shells/bash.go b/shells/bash.go
index 18d608445..f158ffc0b 100644
--- a/shells/bash.go
+++ b/shells/bash.go
@@ -3,6 +3,7 @@ package shells
import (
"bytes"
"fmt"
+ "os/exec"
"path"
"runtime"
"strconv"
@@ -307,7 +308,11 @@ func (b *BashShell) GetConfiguration(info common.ShellScriptInfo) (*common.Shell
script.Command = "su"
if runtime.GOOS == OSLinux {
- script.Arguments = []string{"-s", "/bin/" + b.Shell, info.User, "-c", script.CmdLine}
+ shellPath, err := exec.LookPath(b.Shell)
+ if err != nil {
+ shellPath = "/bin/" + b.Shell
+ }
+ script.Arguments = []string{"-s", shellPath, info.User, "-c", script.CmdLine}
} else {
script.Arguments = []string{info.User, "-c", script.CmdLine}
}

View File

@@ -0,0 +1,118 @@
{
lib,
stdenv,
bash,
buildGoModule,
fetchFromGitLab,
nix-update-script,
versionCheckHook,
}:
buildGoModule (finalAttrs: {
pname = "gitlab-runner";
version = "18.3.1";
src = fetchFromGitLab {
owner = "gitlab-org";
repo = "gitlab-runner";
tag = "v${finalAttrs.version}";
hash = "sha256-D8CNY+lQEK2DgiGfScPxDPday3re/LN4i5jEJTGbshY=";
};
vendorHash = "sha256-vP/htZiUp5qL4TMw6AgNW/TVcvx+pl6rxp41SK5g4XM=";
# For patchShebangs
buildInputs = [ bash ];
patches = [
./fix-shell-path.patch
./remove-bash-test.patch
];
prePatch = ''
# Remove some tests that can't work during a nix build
# Needs the build directory to be a git repo
substituteInPlace commands/helpers/file_archiver_test.go \
--replace-fail "func TestCacheArchiverAddingUntrackedFiles" "func OFF_TestCacheArchiverAddingUntrackedFiles" \
--replace-fail "func TestCacheArchiverAddingUntrackedUnicodeFiles" "func OFF_TestCacheArchiverAddingUntrackedUnicodeFiles"
rm shells/abstract_test.go
# No writable developer environment
rm common/build_settings_test.go
rm common/build_test.go
rm executors/custom/custom_test.go
# No Docker during build
rm executors/docker/docker_test.go
rm executors/docker/services_test.go
rm executors/docker/terminal_test.go
rm helpers/docker/auth/auth_test.go
# No Kubernetes during build
rm executors/kubernetes/feature_test.go
rm executors/kubernetes/kubernetes_test.go
rm executors/kubernetes/overwrites_test.go
''
+ lib.optionalString stdenv.buildPlatform.isDarwin ''
# Invalid bind arguments break Unix socket tests
substituteInPlace commands/wrapper_test.go \
--replace-fail "func TestRunnerWrapperCommand_createListener" "func OFF_TestRunnerWrapperCommand_createListener"
# No keychain access during build breaks X.509 certificate tests
substituteInPlace helpers/certificate/x509_test.go \
--replace-fail "func TestCertificate" "func OFF_TestCertificate"
substituteInPlace network/client_test.go \
--replace-fail "func TestClientInvalidSSL" "func OFF_TestClientInvalidSSL"
'';
excludedPackages = [
# Nested dependency Go module, used with go.mod replace directive
#
# https://gitlab.com/gitlab-org/gitlab-runner/-/commit/57ea9df5d8a8deb78c8d1972930bbeaa80d05e78
"./helpers/runner_wrapper/api"
# Helper scripts for upstream Make targets, not intended for downstream consumers
"./scripts"
];
ldflags =
let
ldflagsPackageVariablePrefix = "gitlab.com/gitlab-org/gitlab-runner/common";
in
[
"-X ${ldflagsPackageVariablePrefix}.NAME=gitlab-runner"
"-X ${ldflagsPackageVariablePrefix}.VERSION=${finalAttrs.version}"
"-X ${ldflagsPackageVariablePrefix}.REVISION=v${finalAttrs.version}"
];
preCheck = ''
# Make the tests pass outside of GitLab CI
export CI=0
'';
# Many tests start servers which bind to ports
__darwinAllowLocalNetworking = true;
postInstall = ''
install packaging/root/usr/share/gitlab-runner/clear-docker-cache $out/bin
'';
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
passthru = {
updateScript = nix-update-script { };
};
meta = {
description = "GitLab Runner the continuous integration executor of GitLab";
homepage = "https://docs.gitlab.com/runner";
license = lib.licenses.mit;
mainProgram = "gitlab-runner";
maintainers = with lib.maintainers; [ zimbatm ];
teams = [ lib.teams.gitlab ];
};
})

View File

@@ -0,0 +1,82 @@
diff --git a/shells/bash_test.go b/shells/bash_test.go
index 9ed9e65ff..02b6e6d5f 100644
--- a/shells/bash_test.go
+++ b/shells/bash_test.go
@@ -4,11 +4,9 @@ package shells
import (
"path"
- "runtime"
"testing"
"github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-runner/common"
)
@@ -90,65 +88,6 @@ func TestBash_CheckForErrors(t *testing.T) {
}
}
-func TestBash_GetConfiguration(t *testing.T) {
- tests := map[string]struct {
- info common.ShellScriptInfo
- cmd string
- args []string
- os string
- }{
- `bash`: {
- info: common.ShellScriptInfo{Shell: "bash", Type: common.NormalShell},
- cmd: "bash",
- },
- `bash -l`: {
- info: common.ShellScriptInfo{Shell: "bash", Type: common.LoginShell},
- cmd: "bash",
- args: []string{"-l"},
- },
- `su -s /bin/bash foobar -c bash`: {
- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.NormalShell},
- cmd: "su",
- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash"},
- os: OSLinux,
- },
- `su -s /bin/bash foobar -c $'bash -l'`: {
- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell},
- cmd: "su",
- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash -l"},
- os: OSLinux,
- },
- `su -s /bin/sh foobar -c $'sh -l'`: {
- info: common.ShellScriptInfo{Shell: "sh", User: "foobar", Type: common.LoginShell},
- cmd: "su",
- args: []string{"-s", "/bin/sh", "foobar", "-c", "sh -l"},
- os: OSLinux,
- },
- `su foobar -c $'bash -l'`: {
- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell},
- cmd: "su",
- args: []string{"foobar", "-c", "bash -l"},
- os: "darwin",
- },
- }
-
- for tn, tc := range tests {
- t.Run(tn, func(t *testing.T) {
- if tc.os != "" && tc.os != runtime.GOOS {
- t.Skipf("test only runs on %s", tc.os)
- }
-
- sh := BashShell{Shell: tc.info.Shell}
- config, err := sh.GetConfiguration(tc.info)
- require.NoError(t, err)
-
- assert.Equal(t, tc.cmd, config.Command)
- assert.Equal(t, tc.args, config.Arguments)
- assert.Equal(t, tn, config.CmdLine)
- })
- }
-}
-
func Test_BashWriter_isTmpFile(t *testing.T) {
tmpDir := "/foo/bar"
bw := BashWriter{TemporaryPath: tmpDir}