nixpkgs/pkgs/development/tools/continuous-integration/github-runner/patches/dir-proj.patch
Vincent Haupert f4af2f267a
nixos/github-runner: init at v2.277.1 (#116775)
* github-runner: init at 2.277.1

* nixos/github-runner: initial version

* nixos/github-runner: add warning if tokenFile in Nix store

* github-runner: don't accept unexpected attrs

* github-runner: formatting nits

* github-runner: add pre and post hooks to checkPhase

* nixos/github-runner: update ExecStartPre= comment

* nixos/github-runner: adapt tokenFile option description

Also note that not only a change to the option value will trigger a
reconfiguration but also modifications to the file's content.

* nixos/github-runner: remove mkDefault for DynamicUser=

* nixos/github-runner: create a parent for systemd dirs

Adds a parent directory "github-runner/" to all of the systemd lifecycle
directories StateDirectory=, RuntimeDirectory= and LogDirectory=.

Doing this has two motivations:

1. Something like this would required if we want to support multiple
   runners configurations. Please note that this is already possible
   using NixOS containers.
2. Having an additional parent directory makes it easier to remap
   any of the directories. Without a parent, systemd is going to
   complain if, for example, the given StateDirectory= is a symlink.

* nixos/github-runner: use specifier to get abs runtime path

* nixos/github-runner: use hostname as default for option `name`

Until now, the runner registration did not set the `--name` argument if
the configuration option was `null`, the default for the option.
According to GitHub's documentation, this instructs the registration
script to use the machine's hostname.

This commit causes the registration to always pass the `--name` argument
to the runner configuration script. The option now defaults to
`networking.hostName` which should be always set on NixOS.

This change becomes necessary as the systemd service name includes the
name of the runner since fcfa809 and, hence, expects it to be set. Thus,
an unset `name` option leads to an error.

* nixos/github-runner: use types.str for `name` option

Forcing a `name` option to comply with a pattern which could also be
used as a hostname is probably not required by GitHub.

* nixos/github-runner: pass dir paths explicitly for ExecStartPre=

* nixos/github-runner: update variable and script naming

* nixos/github-runner: let systemd choose the user/group

User and group naming restrictions are a complex topic [1] that I don't
even want to touch. Let systemd figure out the username and group and
reference it in our scripts through the USER environment variable.

[1] https://systemd.io/USER_NAMES/

* Revert "nixos/github-runner: use types.str for `name` option"

The escaping applied to the subdirectory paths given to StateDirectory=,
RuntimeDirectory= and LogsDirectory= apparently doesn't use the same
strategy that is used to escape unit names (cf. systemd-escape(1)). This
makes it unreasonably hard to construct reliable paths which work for
StateDirectory=/RuntimeDirectory=/LogsDirectory= and ExecStartPre=.

Against this background, I decided to (re-)apply restrictions to the
name a user might give for the GitHub runner. The pattern for
`networking.hostName` seems like a reasonable choice, also as its value
is the default if the `name` option isn't set.

This reverts commit 193ac67ba337990c22126da24a775c497dbc7e7d.

* nixos/github-runner: use types.path for `tokenFile` option

* nixos/github-runner: escape options used as shell arguments

* nixos/github-runner: wait for network-online.target

* github-runner: ignore additional online tests
2021-04-10 10:17:10 +00:00

54 lines
2.6 KiB
Diff

From 4267ee7fa5169b4fd5ce732118769e559806a390 Mon Sep 17 00:00:00 2001
From: Vincent Haupert <mail@vincent-haupert.de>
Date: Sat, 13 Mar 2021 21:52:03 +0100
Subject: [PATCH] Patch dir.proj
Don't execute Git for GitInfoCommitHash property
Don't restore for build target
Don't restore for test target
---
src/dir.proj | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/dir.proj b/src/dir.proj
index 1c91e0c..8b27d3f 100644
--- a/src/dir.proj
+++ b/src/dir.proj
@@ -2,9 +2,6 @@
<Project ToolsVersion="14.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="GenerateConstant">
- <Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true">
- <Output TaskParameter="ConsoleOutput" PropertyName="GitInfoCommitHash" />
- </Exec>
<Message Text="Building $(Product): $(GitInfoCommitHash) --- $(PackageRuntime)" Importance="high"/>
<ItemGroup>
@@ -39,14 +36,13 @@
</ItemGroup>
<Target Name="Build" DependsOnTargets="GenerateConstant">
- <MSBuild Targets="Restore" Projects="@(ProjectFiles)" StopOnFirstFailure="true" />
<MSBuild Targets="Publish" Projects="@(ProjectFiles)" BuildInParallel="false" StopOnFirstFailure="true" Properties="Configuration=$(BUILDCONFIG);PackageRuntime=$(PackageRuntime);Version=$(RunnerVersion);RuntimeIdentifier=$(PackageRuntime);PublishDir=$(MSBuildProjectDirectory)/../_layout/bin" />
<Exec Command="%22$(DesktopMSBuild)%22 Runner.Service/Windows/RunnerService.csproj /p:Configuration=$(BUILDCONFIG) /p:OutputPath=%22$(MSBuildProjectDirectory)/../_layout/bin%22" ConsoleToMSBuild="true" Condition="'$(PackageRuntime)' == 'win-x64' Or '$(PackageRuntime)' == 'win-x86'" />
</Target>
<Target Name="Test" DependsOnTargets="GenerateConstant">
- <Exec Command="dotnet build Test/Test.csproj -c $(BUILDCONFIG) /p:PackageRuntime=$(PackageRuntime)" ConsoleToMSBuild="true" />
- <Exec Command="dotnet test Test/Test.csproj --no-build --logger:trx" ConsoleToMSBuild="true" />
+ <Exec Command="dotnet build Test/Test.csproj --no-restore -c $(BUILDCONFIG) /p:PackageRuntime=$(PackageRuntime)" ConsoleToMSBuild="true" />
+ <Exec Command="dotnet test Test/Test.csproj --no-restore --no-build --logger:trx" ConsoleToMSBuild="true" />
</Target>
<Target Name="Layout" DependsOnTargets="Clean;Build">
@@ -84,4 +80,4 @@
<RemoveDir Directories="Test/bin" />
<RemoveDir Directories="Test/obj" />
</Target>
-</Project>
\ No newline at end of file
+</Project>
--
2.30.1