Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 {
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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())
+ }
}
25 changes: 0 additions & 25 deletions pkgs/by-name/gi/gitlab-runner/fix-shell-path.patch

This file was deleted.

48 changes: 36 additions & 12 deletions pkgs/by-name/gi/gitlab-runner/package.nix
Original file line number Diff line number Diff line change
@@ -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 = ''
Expand All @@ -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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I am wrong but, I think the .git folder is stripped out, so git rev-parse won't work.
Have you tested this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. I switched back to draft, as I made a mistake while pushing. 17.9.2 introduced further changes (mroe tests fail when not there is no .git directory). I'm currently trying some more things...

'';

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
Comment on lines +76 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install -Dm755 out/binaries/gitlab-runner-$GOOS-$GOARCH "$out/bin/gitlab-runner"

install packaging/root/usr/share/gitlab-runner/clear-docker-cache $out/bin
'';

Expand All @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions pkgs/by-name/gi/gitlab-runner/replace-make-go-invocations.patch
Original file line number Diff line number Diff line change
@@ -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)