Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows/eval: run when base branch changed #372475

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wolfgangwalther
Copy link
Contributor

This is based on #371216, so the biggest chunk of commits is from that PR and should be reviewed / commented on there.

Only the last two commits are relevant for this PR. Here, we first change the way we react to the "edited" event for pull_request_target. This avoids running jobs when only title or description of a PR change. This then allows us to run eval on base branch changes as well, without triggering those on small edits all the time.

Tested the concepts, but not the final PR in that constellation, yet.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: policy discussion 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions labels Jan 9, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jan 9, 2025
@wolfgangwalther wolfgangwalther force-pushed the ci-pull-request-target-edited branch 2 times, most recently from 6c24f43 to 941a690 Compare January 11, 2025 21:01
@wolfgangwalther
Copy link
Contributor Author

Tested the concepts, but not the final PR in that constellation, yet.

Now tested. Forgot to pass through permission for the tag job, fixed.

It works. Here's how:

  • When changing the title of a PR, we get a single skipped job:
    20250111-215242-061778333
    Because this is triggered via a different workflow file, the successful jobs from before are still visible and are not removed.
  • When changing the base branch of the PR, we get additional jobs. Example:
    20250111-215609-456517845
    All the jobs that are new for the base branch change are prefixed with "Edited / Base /". In this example we can see that the old job from before are also not replaced, thus the eval from before is still running. We can't prevent them from still showing up, but we can eventually skip the jobs that are still running with something like ci/eval: cancel previous run if new code is pushed #357990 (comment).

Not visible on the second screenshot, yet: We are also running eval again after the base branch change, which is the point of all of this:
20250111-215947-822711236

All of that happened in wolfgangwalther#632.

@wolfgangwalther
Copy link
Contributor Author

@infinisil WDYT?

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

I reviewed it for now. Clever! Though also rather messy 😅, so I'm a bit undecided whether we should have this.

Advantages:

  • Doesn't run CI when PR title/body is changed.
    • Less resource usage
    • No more waiting for CI in such cases.

Disadvantages:

  • Temporarily messy and potentially confusing CI results in the rare case of changing the base branch
  • Duplicated parts in the workflows
  • More complexity

Based on that, and unless I'm missing anything, I don't feel inclined to have this. Instead it would be best for GitHub to address https://github.com/orgs/community/discussions/64119 so that we don't need such a workaround, I've made a comment about that in NixOS/foundation#25 (comment).

@@ -8,7 +8,7 @@ name: Check that Nix files are formatted

on:
pull_request_target:
types: [opened, synchronize, reopened, edited]
workflow_call:
Copy link
Member

Choose a reason for hiding this comment

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

These lines should have some generic comment indicating that it's used via edited-base.yml

.github/workflows/edited-base.yml Show resolved Hide resolved
.github/workflows/edited-base.yml Show resolved Hide resolved
@wolfgangwalther
Copy link
Contributor Author

wolfgangwalther commented Jan 13, 2025

I reviewed it for now. Clever! Though also rather messy 😅, so I'm a bit undecided whether we should have this.

It's the least messy, at least by output, that I could make it :D, but yes I agree.

  • Doesn't run CI when PR title/body is changed.

    • Less resource usage
    • No more waiting for CI in such cases.

This happens quite frequently to me, when I'm merging backport PRs. Building and testing stuff, then going through a final check of the changelog.. yeah all, good set the checkmark "acceptable for release".. ah, damn CI is running again.

I merge in those cases and don't wait for CI, but I'll always get error notifications, because those jobs can't finish when the PR's branch is suddenly gone.

  • Duplicated parts in the workflows

  • More complexity

My idea was to come back with more of the same. In this case it's technically a "correctness" issue, so I did that first.

But I also think the following is quite annoying:

20250113-202912-375807953

I have a ton of checks.. and those visible at the top are always a list of "get-merge-commit", because we run this so often.

With the same approach as in edited-base.yml, i.e. calling those other workflows via workflow_call, we could run the merge-commit job once and pass the result to all other workflows. This would give us much less cluttered output.

One more step would then be to collect most of the small "check" jobs into a single job, so it only appears once. I really don't need to see maintainers-sorted, nix-format, nixf-tidy, editorconfig etc. etc. all in separate jobs in the list. They are almost never failing and I could easily look it up which step failed.

My goal: Make the "check list" usable without scrolling. Not everything, but at least have useful information at the top already.

We could probably make this a bit easier to understand in the workflows folder, if we went a step further, made all actual jobs be called by workflow_call only. Then put them into a jobs folder or so, and have only those "trigger workflows" in the workflows folder.

Doing it this way would also give us a nice overview of: One file has all the jobs that will run on a branch push, one file has all the jobs that will run on a PR, ... Potentially easier to reach consistent results with that.

Based on that, and unless I'm missing anything, I don't feel inclined to have this.

Hopefully my vision above changes your mind ;)

Or.. maybe you have other ideas about the issues mentioned?

We intend to use the edited event to react to base branch changes - but
before this change, we also ran those jobs on simple edits like title or
description.

While this works for some of the quicker jobs, it will not be
sustainable for all evaluation-related jobs. But evaluation needs to be
re-triggered on a base branch change as well, thus this change.
When the base branch changes, we need to run full eval again, because
the changed output paths depend on the base branch.
@wolfgangwalther wolfgangwalther force-pushed the ci-pull-request-target-edited branch from 941a690 to 495d41d Compare January 13, 2025 19:54
@philiptaron
Copy link
Contributor

made all actual jobs be called by workflow_call only

I really like this idea. The selection logic being under workflow control seems like the only way to avoid fatigue over there being yet another check that I need to run locally prior to proposing a PR... and is directionally aligned with running CI locally, outside of GitHub, so we can replicate locally what it would do.

@wolfgangwalther wolfgangwalther marked this pull request as draft February 1, 2025 11:20
@wolfgangwalther
Copy link
Contributor Author

Marked as draft for now. I will come back to it, but will do other things first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: policy discussion 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants