Commit Graph

1698 Commits

Author SHA1 Message Date
Wolfgang Walther
3d505c0361 .github/workflows/README.md: one sentence per line 2025-06-29 21:14:34 +02:00
Wolfgang Walther
2fa1151e54 workflows/labels: label stale issues
By re-organizing the flow in `handle()` we can start labeling both
issues and pull requests, and only make the relevant API requests for
the PR-case.

At first glance, we might think that we only need to label the big batch
list of issues and not those recently updated: But that's wrong, for
recently updated issues it's important to label quickly, because the
stale label needs to be *removed*, too.
2025-06-27 12:09:41 +02:00
Wolfgang Walther
1818027916 workflows/labels: retry on transient API failures
Currently, the labels job fails a few times each day with network
failures. Retrying the requests should help.
2025-06-27 09:15:22 +02:00
Wolfgang Walther
3be9e2afc1 workflows/labels: label rebuilds on failed PR workflow
We already tried to fix this case earlier, but didn't account for all
cases: A scheduled workflow can also encounter a pull request with
failed PR workflow. This failure doesn't need to be in the Eval part, so
artifacts could *still* be available. To make sure PRs always get
rebuild labels, just ignore the status condition. Either the artifact is
there, or it is not.
2025-06-27 09:14:01 +02:00
Wolfgang Walther
4e9df2fc31 workflows/labels: slightly improve logging 2025-06-27 09:14:01 +02:00
Wolfgang Walther
10c63e5117 workflows/labels: fix processing the 100 oldest PRs
The `page` number is 1-based, but the remainder might very well be 0.
This lead to not looking at the 100 oldest PRs, ever.
2025-06-27 09:13:58 +02:00
Wolfgang Walther
1eeee2bb19 .github/labeler: label changes to nixpkgs release notes as "has changelog" (#420225) 2025-06-26 17:21:35 +00:00
Wolfgang Walther
de8f3e2cbf workflows/backport: korthout/backport-action: 3.2.0 -> 3.2.1
Release Notes:
https://github.com/korthout/backport-action/releases/tag/v3.2.1

This should many of the annoying, duplicated error messages that the
backport action comments.
2025-06-26 14:58:32 +02:00
Wolfgang Walther
5466bd2e91 .github/labeler: label changes to nixpkgs release notes as "has changelog"
Previously only the NixOS release notes were taken into account.
2025-06-26 14:55:54 +02:00
Wolfgang Walther
59ac9479e4 workflows/labels: fix merge conflict label
The previous implementation had two problems:
- When switching from /search to /pulls, we disabled the additional GET
on each single pull request - which causes no test merge commit creation
for all PRs. This means, merge conflicts will not actually be detected.
- By using `item` in the pull-request triggered case, this goes back to
`context.payload.pull_request`, which is the state *at the beginning* of
the workflow run. But this renders our "let's wait 3 minutes before
checking merge_commit_sha" logic void. While we wait for 3 minutes, we
still use the *old* value afterwards...

Just making the extra request every time simplifies the logic and solves
both problems.
2025-06-25 12:30:10 +02:00
Wolfgang Walther
c9257371dc workflows/labels: fix stale label date sorting
With the help of:
https://stackabuse.com/how-to-sort-an-array-by-date-in-javascript/
2025-06-25 09:44:33 +02:00
Wolfgang Walther
75362c6510 Reapply "workflows/labels: manage stale & merge conflict labels" (#419654) 2025-06-25 07:06:15 +00:00
Wolfgang Walther
579bfd48da workflows/labels: use /pulls endpoint instead of search for "all" pull requests
It's necessary to use a combination of different endpoints here, because
the /search endpoint only allows fetching the first 1000 items and will
fail with a higher page number (11+). On the flip side, the /pulls
endpoint doesn't allow counting the total number of results, so we can't
calculate the required page number with its response.

Putting both together should work, though.
2025-06-25 08:51:12 +02:00
Wolfgang Walther
ddf3480d49 workflows/labels: improve cleanup of reservoir timer
This should make sure that the timer is cleaned up, no matter what. This
didn't seem to be the case before, where it would still be stuck
sometimes, when throwing an error somewhere.
2025-06-25 08:51:07 +02:00
Wolfgang Walther
39dc87db4b workflows/labels: handle PR-creation-edge-case for merge conflict label
Explained very well by the code comment.
2025-06-25 08:51:03 +02:00
Wolfgang Walther
ed1fc4c6b3 workflows/labels: fix running in pull_request context
When running in a pull_request context, the labels job is part of the
currently running workflow - which will never have succeeded, yet.
Apparently it could be failed already, so in this case we take *any*
workflow run, no matter its state.
2025-06-24 21:00:11 +02:00
Wolfgang Walther
d5072dd344 workflows/labels: fix stale label
To set the stale label properly, we need to consider the right timeline
events only - and their respective relevant timestamps.
2025-06-24 21:00:06 +02:00
Wolfgang Walther
ea10312659 workflows: nix: 2.29.0 -> 2.29.1 2025-06-24 18:26:59 +02:00
Wolfgang Walther
0edbbfc8bb Reapply "workflows/labels: manage stale & merge conflict labels"
This reverts commit c366efa6e2.
2025-06-24 17:37:09 +02:00
Wolfgang Walther
c366efa6e2 Revert "workflows/labels: manage stale & merge conflict labels" 2025-06-24 14:00:20 +00:00
Wolfgang Walther
36e9fe9e7d workflows/labels: manage merge-conflict label for pull requests
The code comments describe much better what we do then a commit message
could ever do.
2025-06-24 14:46:59 +02:00
Wolfgang Walther
58dd9630c3 workflows/labels: manage stale label for pull requests
This manages the `2. status: stale` label for pull requests only (not
issues, yet) with the following conditions:
- The last event on the timeline of the Pull Request counts.
- Labeling and unlabeling of any kind are ignored.
- Older than 180 days are stale.
- Security labeled PRs are never stale.

To handle this label correctly, it's important to go through all pull
requests. Any approach to limit the list of PRs via search are not going
to work:
- Filtering by `updated` is not going to work, because it includes the
last time that *a label was set* on the PR. To actually find out whether
a PR is stale or not, the timeline of events needs to be looked at.
- Filtering by an existing stale label is not going to work either,
because such a label might have been added manually and thus breaking
the rules we set up here. Thus any existing label needs to be confirmed
as well.
2025-06-24 14:46:58 +02:00
Wolfgang Walther
63b9355ed8 workflows/labels: handle missing eval results gracefully
We keep working through the PR, even though we don't have any eval
results. This will allow actually managing labels for much older PRs as
well. Most importantly, it will allow merge-conflict and stale-labeling
next.
2025-06-24 14:46:57 +02:00
Wolfgang Walther
e55128a079 workflows/labels: run on every PR eventually
This replaces the manual dispatch trigger with a batched run through all
pull requests every day. This has the small benefit of not having to
worry about backfilling labeling after fixing bugs - and the much bigger
one in being able to handle merge-conflict and stale labels properly
later. For those, it's inevitable to eventually scan through all PRs.

At this stage, the vast majority of PRs will still be skipped, because
there won't be an eval run with artifact available. This will be
improved in the next step.

Technically, the workflow_dispatch trigger is kept to allow easily
testing this in forks, where the scheduled jobs are disabled. The
triggered job will behave similar to the scheduled job, though, and have
no special inputs.
2025-06-24 14:46:53 +02:00
Wolfgang Walther
d9d97fda59 workflows/labels: refactor to search instead of listing PRs
This doesn't provide much value in itself, yet, but is much more
flexible in the next step, when also looking at much older PRs.
2025-06-24 14:46:28 +02:00
Wolfgang Walther
8b5101554a workflows/labels: save an API request when running in pull_request context
We previously ran another list request in this case, but don't need to
anymore - we already have the `pull_request` context available.
2025-06-24 14:31:41 +02:00
Wolfgang Walther
f394b2741e workflows/labels: refactor moving cutoff downwards 2025-06-24 14:31:13 +02:00
Wolfgang Walther
042a2fd6d6 workflows/labels: refactor into handle() function
Separate commit for better diff.
2025-06-24 14:30:41 +02:00
Wolfgang Walther
24e7e47c91 workflows/labels: dynamically adjust reservoir to remaining rate limit
Instead of approximating how many requests we can still make and hoping
the best that concurrent jobs won't break the bank, we can just work
with the actual limits. By updating regularly, we make sure that
concurrent jobs are taken into account. We always keep a reserve of 1000
requests to make sure *any* non-labeling jobs using this app will always
succeed.

This will allow us to easily backfill labels across multiple days,
especially taking the increased rate limit for the app into account.
With this, we should get up to 11.5k requests per hour in.
2025-06-24 08:51:18 +02:00
Wolfgang Walther
acc1c0ae59 workflows/labels: run with app token
This gives us a much higher rate limit of 12.5k requests per hour. If
the app is not available, we fallback to the regular `github.token`.
This can happen when testing in forks without setting up an app.
2025-06-23 13:23:06 +02:00
Wolfgang Walther
767223d29d workflows/{check,reviewers}: don't run on staging-like PRs (#418496) 2025-06-23 10:53:34 +00:00
Wolfgang Walther
356bf98a32 workflows: log rate limits consistently
This will give us a better idea about:
- Which jobs use the most API calls and can possibly be made more
efficient.
- Which rate limits apply exactly to which tokens.
2025-06-22 22:08:42 +02:00
Wolfgang Walther
28f3b92403 workflows/labels: manage "first-time contribution" label
This is currently managed with yet another bot, but we don't need to -
this fits into our workflow nicely.
2025-06-22 18:27:47 +02:00
Wolfgang Walther
a3ce5970e0 workflows/{check,reviewers}: don't run on PRs from secondary development branches
It makes no sense to check cherry picks or request reviewers on PRs from
staging-next to master, the same on backbranches or for haskell-updates
into staging.
2025-06-22 14:21:06 +02:00
Wolfgang Walther
7763be5a80 workflows/pr: refactor base/head branch decision making
Some jobs purposefully only run on certain base or head branches. By
centralizing the logic, parts of it can easily be re-used later. Also,
this gives them an explicit name and thus makes them easier to
understand.
2025-06-22 14:21:03 +02:00
Wolfgang Walther
5b5b18c875 workflows/labels: manage labels with a single API call
Instead of deleting each label separately and then making another call
to add new labels, this replaces all labels at once, thus saving API
calls in some cases. Also, the labels are now managed in object-style
compared to the array-style before. This allows putting all the
knowledge about each label into a single place instead of in multiple
places. For example, the rebuild labels had to be special cased in the
workflow before - and the nix code to compare had to match that. Also,
the approval labels had to be considered in the `before` and `after`
phases.

The next commit shows how easy it is to add a new label now.
2025-06-22 14:09:04 +02:00
Wolfgang Walther
7c8177844b workflows/eval: don't fail without artifact from target branch (#418495) 2025-06-21 19:33:52 +00:00
Wolfgang Walther
966bc95a23 workflows/labels: various fixes (#418504) 2025-06-21 11:38:41 +00:00
Wolfgang Walther
d00d3190d6 workflows/labels: fix on older PRs
When we made the switch from eval.yml to pr.yml we adjusted the labels
job as well - but didn't take into account that we also need to deal
with old PRs at the same time.

Here, we fallback to another API request to get a run for eval.yml when
we can't find one for pr.yml.
2025-06-21 13:12:19 +02:00
Wolfgang Walther
155ea15a38 workflows/pr: run in pull_request context on changed labels.yml
When labels.yml is changed the new code is not tested in the PR
directly, yet, because we forgot to add labels.yml to the list of
pull_request files in pr.yml. This lead to one syntax error merged
already.
2025-06-21 13:08:46 +02:00
Wolfgang Walther
8e1f869261 workflows/labels: lower API calls reservoir to 500
First data shows, that we're unlikely to need more than 250 within an
hour of regular activity. Once this is empty, we'll need to wait until
the next hourly refill - thus, we'll rather set this a bit higher to be
on the safe side.

The hourly limit is at 5000 and we peaked around 3500, so far. We'll
certainly have to look into reducing API calls, but this should still
work out for now.
2025-06-21 13:08:41 +02:00
Wolfgang Walther
9581b0c55b workflows/labels: fix race condition with throttling
When we switched to a scheduled workflow, we also changed these lines to
take the labels directly from the pull request list we iterate over. At
the time it saved us an API request. Meanwhile, we have introduced
throttling to the workflow and this causes a potential race condition:

When the scheduled or manually triggered workflow is kicked off and
empties its reservoir of API requests it might be blocked to wait up
to.. an hour! If this happens, the labels taken from the pull request
list might already be outdated at the time the workflow continues. This
would cause some labels to be reset to their original state, which could
be wrong if, for example, another push has happened in the meantime.

This will have a much bigger impact after the next commit, where *all*
labels are set every time, thus the `before` part must be accurate.

Fetching the current labels right before managing them reduces this risk
significantly.
2025-06-21 13:08:38 +02:00
Wolfgang Walther
83ce9e7b44 workflows/eval: don't fail without artifact from target branch
This can only happen if the target branch's eval run failed and we're
trying to fix it. In this case, Eval should not fail, even though it
might not be able to do a comparison and add the correct rebuild labels.
But if we failed here, we wouldn't be able to merge the fix once we have
required status checks.
2025-06-20 21:19:44 +02:00
Wolfgang Walther
caf4ced100 workflows/pr: add required job
This job serves as a target for the "Required Status Checks" branch
protection rule.
2025-06-20 09:22:58 +02:00
Wolfgang Walther
9927d758e7 workflows/{labels,reviewers}: move from Eval to PR context
This allows *not* depending on those two jobs with the required status
checks in the next commit, which wouldn't really make sense. If labeling
or pinging maintainers fails for obscure reasons or because the GitHub
API is down, a PR might still pass all other tests and be
merge-eligible.
2025-06-20 09:22:53 +02:00
Wolfgang Walther
09ddb1a8a0 workflows: sync merge commits
This fixes a problem where each workflow would get their own merge
commit. This happens frequently when the target branch is merged into a
the same time, different workflows in the same run will run
get-merge-commit at different times and thus have different merge
commits.

Since the jobs don't really depend on each other, this doesn't cause
practical problems, yet. But it has already led to strange CI failures
in a still unmerged PR, which can be prevented from happening with this
clean approach.

And yes, this saves a few API calls on every run.
2025-06-20 09:22:48 +02:00
Wolfgang Walther
9422f30e47 workflows/{pr,push}: move prepare job from eval workflow
This is only a refactor at this stage, but split into a separate commit
for better review. It's the base for the next two commits.
2025-06-20 09:22:42 +02:00
Wolfgang Walther
69ab2f4347 workflows/eval: small improvements
Some naming improvements after we introduced the PR / Push workflows and
small refactors.
2025-06-20 09:22:39 +02:00
Wolfgang Walther
8ab44fec37 workflows/labels: fix pull_request event trigger
When the job is run with the pull_request trigger for validation of
changes to the workflow itself, we need to run everything that can be
run without privileges - but not more.

We tried to do so for the three actions/labeler steps, but failed to set
up the condition correctly. We also need to exit early for our
JavaScript based labeler, just before making the mutation requests.
2025-06-19 11:54:47 +02:00
Wolfgang Walther
d8332aa3b7 workflows/{pr,push}: init (#415006) 2025-06-18 12:16:55 +00:00