From 7dcaf4d07d4121e5caaac7195eb66a1595cfb843 Mon Sep 17 00:00:00 2001 From: Leona Maroni Date: Sat, 15 Mar 2025 12:38:11 +0100 Subject: [PATCH] gitlab-runner: 17.2.0 -> 17.9.1 * Switch build invocations to make * Fix build errors on darwin --- .../disable-kubernetes-test-on-aarch64.patch | 14 ++++++ .../disable-unix-socket-tests-on-darwin.patch | 42 ++++++++++++++++ ...ble-x509-certificate-check-on-darwin.patch | 24 ++++++++++ .../gi/gitlab-runner/fix-shell-path.patch | 25 ---------- pkgs/by-name/gi/gitlab-runner/package.nix | 48 ++++++++++++++----- .../replace-make-go-invocations.patch | 29 +++++++++++ 6 files changed, 145 insertions(+), 37 deletions(-) create mode 100644 pkgs/by-name/gi/gitlab-runner/disable-kubernetes-test-on-aarch64.patch create mode 100644 pkgs/by-name/gi/gitlab-runner/disable-unix-socket-tests-on-darwin.patch create mode 100644 pkgs/by-name/gi/gitlab-runner/disable-x509-certificate-check-on-darwin.patch delete mode 100644 pkgs/by-name/gi/gitlab-runner/fix-shell-path.patch create mode 100644 pkgs/by-name/gi/gitlab-runner/replace-make-go-invocations.patch diff --git a/pkgs/by-name/gi/gitlab-runner/disable-kubernetes-test-on-aarch64.patch b/pkgs/by-name/gi/gitlab-runner/disable-kubernetes-test-on-aarch64.patch new file mode 100644 index 0000000000000..23ffc7cf055a1 --- /dev/null +++ b/pkgs/by-name/gi/gitlab-runner/disable-kubernetes-test-on-aarch64.patch @@ -0,0 +1,14 @@ +diff --git a/executors/kubernetes/kubernetes_test.go b/executors/kubernetes/kubernetes_test.go +index ba50f31e0..c500e3a26 100644 +--- a/executors/kubernetes/kubernetes_test.go ++++ b/executors/kubernetes/kubernetes_test.go +@@ -2815,6 +2815,9 @@ func TestPrepare(t *testing.T) { + if runtime.GOOS == "windows" { + return false, "skipping test, because we are running on windows" + } ++ if runtime.GOARCH == "arm64" { ++ return false, "skipping test, because of fix assertion we should be on x86" ++ } + return true, "" + }, + WindowsKernelVersionGetter: func() string { diff --git a/pkgs/by-name/gi/gitlab-runner/disable-unix-socket-tests-on-darwin.patch b/pkgs/by-name/gi/gitlab-runner/disable-unix-socket-tests-on-darwin.patch new file mode 100644 index 0000000000000..df1f06cead975 --- /dev/null +++ b/pkgs/by-name/gi/gitlab-runner/disable-unix-socket-tests-on-darwin.patch @@ -0,0 +1,42 @@ +diff --git a/commands/wrapper_test.go b/commands/wrapper_test.go +index c897c8170..b5ad47acf 100644 +--- a/commands/wrapper_test.go ++++ b/commands/wrapper_test.go +@@ -16,10 +16,13 @@ import ( + func TestRunnerWrapperCommand_createListener(t *testing.T) { + testSocketPath := filepath.Join(t.TempDir(), "test.sock") + +- skipOnWindows := func(t *testing.T) { ++ skipCondition := func(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Test doesn't work reliably on Windows (unix socket usage)") + } ++ if runtime.GOOS == "darwin" { ++ t.Skip("Test doesn't work reliably on Darwin with enabled sandbox") ++ } + } + + tests := map[string]struct { +@@ -36,19 +39,19 @@ func TestRunnerWrapperCommand_createListener(t *testing.T) { + }, + }, + "proper unix socket - unix://": { +- skip: skipOnWindows, ++ skip: skipCondition, + grpcAddress: fmt.Sprintf("unix://%s", testSocketPath), + expectedNetwork: "unix", + expectedAddress: testSocketPath, + }, + "proper unix socket - unix:": { +- skip: skipOnWindows, ++ skip: skipCondition, + grpcAddress: fmt.Sprintf("unix://%s", testSocketPath), + expectedNetwork: "unix", + expectedAddress: testSocketPath, + }, + "invalid unix socket": { +- skip: skipOnWindows, ++ skip: skipCondition, + grpcAddress: fmt.Sprintf("unix:/%s", testSocketPath), + assertError: func(t *testing.T, err error) { + var eerr *net.OpError diff --git a/pkgs/by-name/gi/gitlab-runner/disable-x509-certificate-check-on-darwin.patch b/pkgs/by-name/gi/gitlab-runner/disable-x509-certificate-check-on-darwin.patch new file mode 100644 index 0000000000000..4701f69d1be3c --- /dev/null +++ b/pkgs/by-name/gi/gitlab-runner/disable-x509-certificate-check-on-darwin.patch @@ -0,0 +1,24 @@ +diff --git a/helpers/certificate/x509_test.go b/helpers/certificate/x509_test.go +index 8afe0d9e8..7eac8a691 100644 +--- a/helpers/certificate/x509_test.go ++++ b/helpers/certificate/x509_test.go +@@ -8,6 +8,7 @@ import ( + "net" + "net/http" + "regexp" ++ "runtime" + "testing" + + "github.com/stretchr/testify/assert" +@@ -62,6 +63,9 @@ func TestCertificate(t *testing.T) { + _, err = client.Do(req) + assert.Error(t, err) + // Error messages provided by Linux and MacOS respectively. +- const want = "certificate signed by unknown authority|certificate is not trusted" +- assert.Regexp(t, regexp.MustCompile(want), err.Error()) ++ // Nix sandbox prevents the test from working ++ if runtime.GOOS != "darwin" { ++ const want = "certificate signed by unknown authority|certificate is not trusted" ++ assert.Regexp(t, regexp.MustCompile(want), err.Error()) ++ } + } diff --git a/pkgs/by-name/gi/gitlab-runner/fix-shell-path.patch b/pkgs/by-name/gi/gitlab-runner/fix-shell-path.patch deleted file mode 100644 index b70b95e7be0b9..0000000000000 --- a/pkgs/by-name/gi/gitlab-runner/fix-shell-path.patch +++ /dev/null @@ -1,25 +0,0 @@ -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} - } diff --git a/pkgs/by-name/gi/gitlab-runner/package.nix b/pkgs/by-name/gi/gitlab-runner/package.nix index 61d2af6ac7c87..ff4fa28a8f63a 100644 --- a/pkgs/by-name/gi/gitlab-runner/package.nix +++ b/pkgs/by-name/gi/gitlab-runner/package.nix @@ -1,34 +1,39 @@ -{ lib, buildGoModule, fetchFromGitLab, bash }: +{ + lib, + buildGoModule, + fetchFromGitLab, + bash, +}: let - version = "17.2.0"; + version = "17.9.2"; in buildGoModule rec { inherit version; pname = "gitlab-runner"; - commonPackagePath = "gitlab.com/gitlab-org/gitlab-runner/common"; - ldflags = [ - "-X ${commonPackagePath}.NAME=gitlab-runner" - "-X ${commonPackagePath}.VERSION=${version}" - "-X ${commonPackagePath}.REVISION=v${version}" - ]; - # For patchShebangs buildInputs = [ bash ]; - vendorHash = "sha256-1MwHss76apA9KoFhEU6lYiUACrPMGYzjhds6nTyNuJI="; + vendorHash = "sha256-t/FVaDga2ogyqgVdJuBMSyls3rricfqIy5bFSH4snk4="; src = fetchFromGitLab { owner = "gitlab-org"; repo = "gitlab-runner"; rev = "v${version}"; - hash = "sha256-a2Igy4DS3fYTvPW1vvDrH/DjMQ4lG9cm/P3mFr+y9s4="; + hash = "sha256-kcDsjmx/900p2ux7dyGHSOVqXxxVhg2/o0a3NYcqIrA="; }; patches = [ - ./fix-shell-path.patch ./remove-bash-test.patch + # Asserts for x86_64 architecture + # https://gitlab.com/gitlab-org/gitlab-runner/-/issues/38697 + ./disable-kubernetes-test-on-aarch64.patch + # Fails in nix sandbox + ./disable-unix-socket-tests-on-darwin.patch + # Fails in nix sandbox + # Returns OSStatus -26276 + ./disable-x509-certificate-check-on-darwin.patch ]; prePatch = '' @@ -50,13 +55,26 @@ buildGoModule rec { rm executors/docker/services_test.go ''; + postPatch = '' + substituteInPlace Makefile --replace-fail "export VERSION := \$(shell ./ci/version)" "export VERSION := ${version}" + substituteInPlace Makefile --replace-fail "REVISION := \$(shell git rev-parse --short=8 HEAD || echo unknown)" "REVISION := v${version}" + ''; + excludedPackages = [ # CI helper script for pushing images to Docker and ECR registries # https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/4139 "./scripts/sync-docker-images" ]; + buildPhase = '' + runHook preBuild + make -j $NIX_BUILD_CORES runner-and-helper-bin-host + runHook postBuild + ''; + postInstall = '' + mkdir $out/bin + cp out/binaries/gitlab-runner-$GOOS-$GOARCH $out/bin/gitlab-runner install packaging/root/usr/share/gitlab-runner/clear-docker-cache $out/bin ''; @@ -65,6 +83,12 @@ buildGoModule rec { export CI=0 ''; + checkPhase = '' + runHook preCheck + make simple-test + runHook postCheck + ''; + meta = with lib; { description = "GitLab Runner the continuous integration executor of GitLab"; license = licenses.mit; diff --git a/pkgs/by-name/gi/gitlab-runner/replace-make-go-invocations.patch b/pkgs/by-name/gi/gitlab-runner/replace-make-go-invocations.patch new file mode 100644 index 0000000000000..ebd86a1eaf240 --- /dev/null +++ b/pkgs/by-name/gi/gitlab-runner/replace-make-go-invocations.patch @@ -0,0 +1,29 @@ +diff --git a/Makefile b/Makefile +index e948db0d6d..cd0957251e 100644 +--- a/Makefile ++++ b/Makefile +@@ -3,14 +3,10 @@ + export PACKAGE_NAME ?= $(NAME) + export VERSION := $(shell ./ci/version) + REVISION := $(shell git rev-parse --short=8 HEAD || echo unknown) +-BRANCH := $(shell git show-ref | grep "$(REVISION)" | grep -v HEAD | awk '{print $$2}' | sed 's|refs/remotes/origin/||' | sed 's|refs/heads/||' | sort | head -n 1) ++BRANCH := + export TESTFLAGS ?= -cover + +-LATEST_STABLE_TAG := $(shell git -c versionsort.prereleaseSuffix="-rc" -c versionsort.prereleaseSuffix="-RC" tag -l "v*.*.*" | sort -rV | awk '!/rc/' | head -n 1) + export IS_LATEST := +-ifeq ($(shell git describe --exact-match --match $(LATEST_STABLE_TAG) >/dev/null 2>&1; echo $$?), 0) +-export IS_LATEST := true +-endif + + PACKAGE_CLOUD ?= runner/gitlab-runner + PACKAGE_CLOUD_URL ?= https://packages.gitlab.com +@@ -32,7 +28,7 @@ + export MAIN_PACKAGE ?= gitlab.com/gitlab-org/gitlab-runner + + GO_LDFLAGS ?= -X $(COMMON_PACKAGE_NAMESPACE).NAME=$(APP_NAME) -X $(COMMON_PACKAGE_NAMESPACE).VERSION=$(VERSION) \ +- -X $(COMMON_PACKAGE_NAMESPACE).BRANCH=$(BRANCH) \ ++ -X $(COMMON_PACKAGE_NAMESPACE).REVISION=$(REVISION) -X $(COMMON_PACKAGE_NAMESPACE).BRANCH=$(BRANCH) \ + -w + + GO_TEST_LDFLAGS ?= -X $(COMMON_PACKAGE_NAMESPACE).NAME=$(APP_NAME)