commit
4b762a4dcf
|
@ -353,14 +353,11 @@ def nix_eval_config(
|
||||||
worker_names: list[str],
|
worker_names: list[str],
|
||||||
github_token_secret: str,
|
github_token_secret: str,
|
||||||
supported_systems: list[str],
|
supported_systems: list[str],
|
||||||
automerge_users: list[str] = [],
|
|
||||||
max_memory_size: int = 4096,
|
max_memory_size: int = 4096,
|
||||||
) -> util.BuilderConfig:
|
) -> util.BuilderConfig:
|
||||||
"""
|
"""
|
||||||
Uses nix-eval-jobs to evaluate hydraJobs from flake.nix in parallel.
|
Uses nix-eval-jobs to evaluate hydraJobs from flake.nix in parallel.
|
||||||
For each evaluated attribute a new build pipeline is started.
|
For each evaluated attribute a new build pipeline is started.
|
||||||
If all builds succeed and the build was for a PR opened by the flake update bot,
|
|
||||||
this PR is merged.
|
|
||||||
"""
|
"""
|
||||||
factory = util.BuildFactory()
|
factory = util.BuildFactory()
|
||||||
# check out the source
|
# check out the source
|
||||||
|
@ -406,44 +403,6 @@ def nix_eval_config(
|
||||||
haltOnFailure=True,
|
haltOnFailure=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if len(automerge_users) > 0:
|
|
||||||
|
|
||||||
def check_auto_merge(step: steps.BuildStep) -> bool:
|
|
||||||
print("Checking if we should merge")
|
|
||||||
props = step.build.getProperties()
|
|
||||||
if props.getProperty("event") != "pull_request":
|
|
||||||
print("Not a pull request")
|
|
||||||
return False
|
|
||||||
if props.getProperty(
|
|
||||||
"github.repository.default_branch"
|
|
||||||
) != props.getProperty("branch"):
|
|
||||||
print("Not on default branch")
|
|
||||||
return False
|
|
||||||
if not any(
|
|
||||||
owner in automerge_users for owner in props.getProperty("owners")
|
|
||||||
):
|
|
||||||
print(
|
|
||||||
f"PR opened by {step.getProperty('owner')} not in {automerge_users}"
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
factory.addStep(
|
|
||||||
steps.ShellCommand(
|
|
||||||
name="Merge pull-request",
|
|
||||||
env=dict(GITHUB_TOKEN=util.Secret(github_token_secret)),
|
|
||||||
command=[
|
|
||||||
"gh",
|
|
||||||
"pr",
|
|
||||||
"merge",
|
|
||||||
"--repo",
|
|
||||||
util.Property("project"),
|
|
||||||
"--rebase",
|
|
||||||
util.Property("pullrequesturl"),
|
|
||||||
],
|
|
||||||
doStepIf=check_auto_merge,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return util.BuilderConfig(
|
return util.BuilderConfig(
|
||||||
name=f"{project.name}/nix-eval",
|
name=f"{project.name}/nix-eval",
|
||||||
|
@ -500,6 +459,7 @@ def nix_build_config(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
factory.addStep(
|
factory.addStep(
|
||||||
steps.ShellCommand(
|
steps.ShellCommand(
|
||||||
name="Register gcroot",
|
name="Register gcroot",
|
||||||
|
@ -513,8 +473,7 @@ def nix_build_config(
|
||||||
"-r",
|
"-r",
|
||||||
util.Property("out_path"),
|
util.Property("out_path"),
|
||||||
],
|
],
|
||||||
doStepIf=util.Interpolate("branch")
|
doStepIf=lambda s: s.getProperty("branch") == s.getProperty("github.repository.default_branch"),
|
||||||
== util.Interpolate("github.repository.default_branch"),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
factory.addStep(
|
factory.addStep(
|
||||||
|
@ -634,7 +593,6 @@ def config_for_project(
|
||||||
[worker_names[0]],
|
[worker_names[0]],
|
||||||
github_token_secret=github.token_secret_name,
|
github_token_secret=github.token_secret_name,
|
||||||
supported_systems=nix_supported_systems,
|
supported_systems=nix_supported_systems,
|
||||||
automerge_users=[github.buildbot_user],
|
|
||||||
max_memory_size=nix_eval_max_memory_size,
|
max_memory_size=nix_eval_max_memory_size,
|
||||||
),
|
),
|
||||||
nix_build_config(
|
nix_build_config(
|
||||||
|
|
Loading…
Reference in a new issue