summary refs log tree commit diff
path: root/pkgs/development/tools/continuous-integration/github-runner/default.nix
diff options
context:
space:
mode:
authorPavol Rusnak <pavol@rusnak.io>2022-01-03 17:08:44 +0100
committerGitHub <noreply@github.com>2022-01-03 17:08:44 +0100
commit3dc3e1ef581c8773909231e3cdc656b96c8ce821 (patch)
treeaec8003d09a99c58ff1fccc3a9ff89cf87f333ff /pkgs/development/tools/continuous-integration/github-runner/default.nix
parent8fe985265f73b57f499ee225d4aac424fbe8d3c8 (diff)
parent8b138c90318712d0a0c19732a32a4d1394f5168f (diff)
downloadnixpkgs-3dc3e1ef581c8773909231e3cdc656b96c8ce821.tar
nixpkgs-3dc3e1ef581c8773909231e3cdc656b96c8ce821.tar.gz
nixpkgs-3dc3e1ef581c8773909231e3cdc656b96c8ce821.tar.bz2
nixpkgs-3dc3e1ef581c8773909231e3cdc656b96c8ce821.tar.lz
nixpkgs-3dc3e1ef581c8773909231e3cdc656b96c8ce821.tar.xz
nixpkgs-3dc3e1ef581c8773909231e3cdc656b96c8ce821.tar.zst
nixpkgs-3dc3e1ef581c8773909231e3cdc656b96c8ce821.zip
Merge pull request #152387 from kfollesdal/kfollesdal/github-runner_2.286.0
github-runner update to 2.286.0 with dotnet sdk 6.0
Diffstat (limited to 'pkgs/development/tools/continuous-integration/github-runner/default.nix')
-rw-r--r--pkgs/development/tools/continuous-integration/github-runner/default.nix90
1 files changed, 62 insertions, 28 deletions
diff --git a/pkgs/development/tools/continuous-integration/github-runner/default.nix b/pkgs/development/tools/continuous-integration/github-runner/default.nix
index e784e3fe330..1b95903c601 100644
--- a/pkgs/development/tools/continuous-integration/github-runner/default.nix
+++ b/pkgs/development/tools/continuous-integration/github-runner/default.nix
@@ -10,7 +10,7 @@
 , icu
 , libkrb5
 , lib
-, linkFarm
+, linkFarmFromDrvs
 , lttng-ust
 , makeWrapper
 , nodejs-12_x
@@ -18,33 +18,38 @@
 , openssl
 , stdenv
 , zlib
+, writeShellApplication
+, nuget-to-nix
 }:
 let
-  deps = (import ./deps.nix { inherit fetchurl; });
-  nugetPackages = map
-    (x: {
-      name = "${x.name}.nupkg";
-      path = "${x}";
-    })
-    deps;
-  nugetSource = linkFarm "nuget-packages" nugetPackages;
-
-  dotnetSdk = dotnetCorePackages.sdk_3_1;
-  runtimeId =
-    if stdenv.isAarch64
-    then "linux-arm64"
-    else "linux-x64";
+  nugetSource = linkFarmFromDrvs "nuget-packages" (
+    import ./deps.nix {
+      fetchNuGet = { pname, version, sha256 }: fetchurl {
+        name = "${pname}.${version}.nupkg";
+        url = "https://www.nuget.org/api/v2/package/${pname}/${version}";
+        inherit sha256;
+      };
+    }
+  );
+
+  dotnetSdk = dotnetCorePackages.sdk_6_0;
+  # Map Nix systems to .NET runtime ids
+  runtimeIds = {
+    "x86_64-linux" = "linux-x64";
+    "aarch64-linux" = "linux-arm64";
+  };
+  runtimeId = runtimeIds.${stdenv.system};
   fakeSha1 = "0000000000000000000000000000000000000000";
 in
 stdenv.mkDerivation rec {
   pname = "github-runner";
-  version = "2.285.1";
+  version = "2.286.0";
 
   src = fetchFromGitHub {
     owner = "actions";
     repo = "runner";
     rev = "v${version}";
-    hash = "sha256-SlKUuebsoZ9OgYuDTNOlY1KMg01LFSFazrLCctiFq3A=";
+    hash = "sha256-a3Kh65NTpVlKUer59rna7NWIQSxh1edU9MwguakzydI=";
   };
 
   nativeBuildInputs = [
@@ -80,7 +85,7 @@ stdenv.mkDerivation rec {
   postPatch = ''
     # Relax the version requirement
     substituteInPlace src/global.json \
-      --replace '3.1.302' '${dotnetSdk.version}'
+      --replace '6.0.100' '${dotnetSdk.version}'
 
     # Disable specific tests
     substituteInPlace src/dir.proj \
@@ -116,14 +121,6 @@ stdenv.mkDerivation rec {
     runHook postConfigure
   '';
 
-  postConfigure = ''
-    # `crossgen` dependency is called during build
-    patchelf \
-      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      --set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}" \
-      $HOME/.nuget/packages/microsoft.netcore.app.runtime.${runtimeId}/*/tools/crossgen
-  '';
-
   buildPhase = ''
     runHook preBuild
 
@@ -142,6 +139,8 @@ stdenv.mkDerivation rec {
 
   disabledTests = [
     # Self-updating is patched out, hence this test will fail
+    "FullyQualifiedName!=GitHub.Runner.Common.Tests.Listener.SelfUpdaterL0.TestSelfUpdateAsync_ValidateHash"
+    "FullyQualifiedName!=GitHub.Runner.Common.Tests.Listener.SelfUpdaterL0.TestSelfUpdateAsync"
     "FullyQualifiedName!=GitHub.Runner.Common.Tests.Listener.RunnerL0.TestRunOnceHandleUpdateMessage"
   ] ++ lib.optionals (stdenv.hostPlatform.system == "aarch64-linux") [
     # "JavaScript Actions in Alpine containers are only supported on x64 Linux runners. Detected Linux Arm64"
@@ -281,11 +280,46 @@ stdenv.mkDerivation rec {
     wrap config.sh --prefix PATH : ${lib.makeBinPath [ glibc.bin ]}
   '';
 
+  # Script to create deps.nix file for dotnet dependencies. Run it with
+  # $(nix-build -A github-runner.passthru.createDepsFile)/bin/create-deps-file
+  #
+  # Default output path is /tmp/${pname}-deps.nix, but can be overriden with cli argument.
+  #
+  # Inspired by passthru.fetch-deps in pkgs/build-support/build-dotnet-module/default.nix
+  passthru.createDepsFile = writeShellApplication {
+    name = "create-deps-file";
+    runtimeInputs = [ dotnetSdk nuget-to-nix ];
+    text = ''
+      rundir=$(pwd)
+
+      printf "\n* Setup workdir\n"
+      workdir="$(mktemp -d /tmp/${pname}.XXX)"
+      cp -rT "${src}" "$workdir"
+      chmod -R +w "$workdir"
+      trap 'rm -rf "$workdir"' EXIT
+
+      pushd "$workdir"
+
+      mkdir nuget_pkgs
+
+      ${lib.concatMapStrings (rid: ''
+      printf "\n* Restore ${pname} (${rid}) dotnet project\n"
+      dotnet restore src/ActionsRunner.sln --packages nuget_pkgs --no-cache --force --runtime "${rid}"
+      '') (lib.attrValues runtimeIds)}
+
+      cd "$rundir"
+      deps_file=''${1-"/tmp/${pname}-deps.nix"}
+      printf "\n* Make %s file\n" "$(basename "$deps_file")"
+      nuget-to-nix "$workdir/nuget_pkgs" > "$deps_file"
+      printf "\n* Dependency file writen to %s" "$deps_file"
+    '';
+  };
+
   meta = with lib; {
     description = "Self-hosted runner for GitHub Actions";
     homepage = "https://github.com/actions/runner";
     license = licenses.mit;
-    maintainers = with maintainers; [ veehaitch newam ];
-    platforms = [ "x86_64-linux" "aarch64-linux" ];
+    maintainers = with maintainers; [ veehaitch newam kfollesdal ];
+    platforms = attrNames runtimeIds;
   };
 }