|
1 | 1 | { |
2 | 2 | lib, |
| 3 | + stdenv, |
| 4 | + bash, |
3 | 5 | buildGoModule, |
4 | 6 | fetchFromGitLab, |
5 | | - bash, |
| 7 | + nix-update-script, |
| 8 | + versionCheckHook, |
6 | 9 | }: |
7 | 10 |
|
8 | | -let |
9 | | - version = "17.2.0"; |
10 | | -in |
11 | | -buildGoModule rec { |
12 | | - inherit version; |
| 11 | +buildGoModule (finalAttrs: { |
13 | 12 | pname = "gitlab-runner"; |
14 | | - |
15 | | - commonPackagePath = "gitlab.com/gitlab-org/gitlab-runner/common"; |
16 | | - ldflags = [ |
17 | | - "-X ${commonPackagePath}.NAME=gitlab-runner" |
18 | | - "-X ${commonPackagePath}.VERSION=${version}" |
19 | | - "-X ${commonPackagePath}.REVISION=v${version}" |
20 | | - ]; |
21 | | - |
22 | | - # For patchShebangs |
23 | | - buildInputs = [ bash ]; |
24 | | - |
25 | | - vendorHash = "sha256-1MwHss76apA9KoFhEU6lYiUACrPMGYzjhds6nTyNuJI="; |
| 13 | + version = "17.2.0"; |
26 | 14 |
|
27 | 15 | src = fetchFromGitLab { |
28 | 16 | owner = "gitlab-org"; |
29 | 17 | repo = "gitlab-runner"; |
30 | | - rev = "v${version}"; |
| 18 | + tag = "v${finalAttrs.version}"; |
31 | 19 | hash = "sha256-a2Igy4DS3fYTvPW1vvDrH/DjMQ4lG9cm/P3mFr+y9s4="; |
32 | 20 | }; |
33 | 21 |
|
| 22 | + vendorHash = "sha256-1MwHss76apA9KoFhEU6lYiUACrPMGYzjhds6nTyNuJI="; |
| 23 | + |
| 24 | + # For patchShebangs |
| 25 | + nativeBuildInputs = [ bash ]; |
| 26 | + |
34 | 27 | patches = [ |
35 | 28 | ./fix-shell-path.patch |
36 | 29 | ./remove-bash-test.patch |
37 | 30 | ]; |
38 | 31 |
|
39 | | - prePatch = '' |
40 | | - # Remove some tests that can't work during a nix build |
| 32 | + prePatch = |
| 33 | + '' |
| 34 | + # Remove some tests that can't work during a nix build |
41 | 35 |
|
42 | | - # Requires to run in a git repo |
43 | | - sed -i "s/func TestCacheArchiverAddingUntrackedFiles/func OFF_TestCacheArchiverAddingUntrackedFiles/" commands/helpers/file_archiver_test.go |
44 | | - sed -i "s/func TestCacheArchiverAddingUntrackedUnicodeFiles/func OFF_TestCacheArchiverAddingUntrackedUnicodeFiles/" commands/helpers/file_archiver_test.go |
| 36 | + # Requires to run in a git repo |
| 37 | + sed -i "s/func TestCacheArchiverAddingUntrackedFiles/func OFF_TestCacheArchiverAddingUntrackedFiles/" commands/helpers/file_archiver_test.go |
| 38 | + sed -i "s/func TestCacheArchiverAddingUntrackedUnicodeFiles/func OFF_TestCacheArchiverAddingUntrackedUnicodeFiles/" commands/helpers/file_archiver_test.go |
45 | 39 |
|
46 | | - # No writable developer environment |
47 | | - rm common/build_test.go |
48 | | - rm common/build_settings_test.go |
49 | | - rm executors/custom/custom_test.go |
| 40 | + # No writable developer environment |
| 41 | + rm common/build_test.go |
| 42 | + rm common/build_settings_test.go |
| 43 | + rm executors/custom/custom_test.go |
50 | 44 |
|
51 | | - # No docker during build |
52 | | - rm executors/docker/terminal_test.go |
53 | | - rm executors/docker/docker_test.go |
54 | | - rm helpers/docker/auth/auth_test.go |
55 | | - rm executors/docker/services_test.go |
56 | | - ''; |
| 45 | + # No docker during build |
| 46 | + rm executors/docker/terminal_test.go |
| 47 | + rm executors/docker/docker_test.go |
| 48 | + rm helpers/docker/auth/auth_test.go |
| 49 | + rm executors/docker/services_test.go |
| 50 | + '' |
| 51 | + + lib.optionalString stdenv.buildPlatform.isDarwin '' |
| 52 | + # No keychain access during build breaks X.509 certificate tests |
| 53 | + rm helpers/certificate/x509_test.go |
| 54 | + rm network/client_test.go |
| 55 | + ''; |
57 | 56 |
|
58 | 57 | excludedPackages = [ |
59 | 58 | # CI helper script for pushing images to Docker and ECR registries |
| 59 | + # |
60 | 60 | # https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/4139 |
61 | 61 | "./scripts/sync-docker-images" |
62 | 62 | ]; |
63 | 63 |
|
64 | | - postInstall = '' |
65 | | - install packaging/root/usr/share/gitlab-runner/clear-docker-cache $out/bin |
66 | | - ''; |
| 64 | + ldflags = |
| 65 | + let |
| 66 | + ldflagsPackageVariablePrefix = "gitlab.com/gitlab-org/gitlab-runner/common"; |
| 67 | + in |
| 68 | + [ |
| 69 | + "-X ${ldflagsPackageVariablePrefix}.NAME=gitlab-runner" |
| 70 | + "-X ${ldflagsPackageVariablePrefix}.VERSION=${finalAttrs.version}" |
| 71 | + "-X ${ldflagsPackageVariablePrefix}.REVISION=${finalAttrs.src.tag}" |
| 72 | + ]; |
67 | 73 |
|
68 | 74 | preCheck = '' |
69 | 75 | # Make the tests pass outside of GitLab CI |
70 | 76 | export CI=0 |
71 | 77 | ''; |
72 | 78 |
|
73 | | - meta = with lib; { |
| 79 | + # Many tests start servers which bind to ports |
| 80 | + __darwinAllowLocalNetworking = true; |
| 81 | + |
| 82 | + postInstall = '' |
| 83 | + install packaging/root/usr/share/gitlab-runner/clear-docker-cache $out/bin |
| 84 | + ''; |
| 85 | + |
| 86 | + doInstallCheck = true; |
| 87 | + |
| 88 | + nativeInstallCheckInputs = [ versionCheckHook ]; |
| 89 | + |
| 90 | + versionCheckProgramArg = "--version"; |
| 91 | + |
| 92 | + passthru = { |
| 93 | + updateScript = nix-update-script { }; |
| 94 | + }; |
| 95 | + |
| 96 | + meta = { |
74 | 97 | description = "GitLab Runner the continuous integration executor of GitLab"; |
75 | | - license = licenses.mit; |
76 | | - homepage = "https://docs.gitlab.com/runner/"; |
77 | | - platforms = platforms.unix ++ platforms.darwin; |
78 | | - maintainers = with maintainers; [ zimbatm ] ++ teams.gitlab.members; |
| 98 | + homepage = "https://docs.gitlab.com/runner"; |
| 99 | + license = lib.licenses.mit; |
| 100 | + mainProgram = "gitlab-runner"; |
| 101 | + maintainers = with lib.maintainers; [ zimbatm ] ++ lib.teams.gitlab.members; |
79 | 102 | }; |
80 | | -} |
| 103 | +}) |
0 commit comments