Commit Graph

84 Commits

Author SHA1 Message Date
dependabot[bot]
36c667d9f4 build(deps): bump actions/github-script from 7.0.1 to 8.0.0
Bumps [actions/github-script](https://github.com/actions/github-script) from 7.0.1 to 8.0.0.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](60a0d83039...ed597411d8)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit 4ea8216576)
2025-09-08 12:36:31 +00:00
dependabot[bot]
0fbe222634 build(deps): bump actions/labeler from 5.0.0 to 6.0.1
Bumps [actions/labeler](https://github.com/actions/labeler) from 5.0.0 to 6.0.1.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](8558fd7429...634933edcd)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit d64ece988b)
2025-09-08 12:33:13 +00:00
dependabot[bot]
150ba26d2b build(deps): bump actions/create-github-app-token from 2.1.0 to 2.1.1
Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/actions/create-github-app-token/releases)
- [Commits](0f859bf9e6...a8d6161485)

---
updated-dependencies:
- dependency-name: actions/create-github-app-token
  dependency-version: 2.1.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit c1853d5ea1)
2025-08-26 12:08:31 +00:00
Wolfgang Walther
0ec83b71dd workflows/labels: prevent error on token creation for Test workflow
This only happens when the label workflow runs in pull_request context
*and* from within nixpkgs (not a fork). This is the case for dependabot
updates.

(cherry picked from commit 979687958f)
2025-08-26 11:59:48 +00:00
dependabot[bot]
8a03e71552 build(deps): bump actions/create-github-app-token from 2.0.6 to 2.1.0
Bumps [actions/create-github-app-token](https://github.com/actions/create-github-app-token) from 2.0.6 to 2.1.0.
- [Release notes](https://github.com/actions/create-github-app-token/releases)
- [Commits](df432ceedc...0f859bf9e6)

---
updated-dependencies:
- dependency-name: actions/create-github-app-token
  dependency-version: 2.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit d1d2650cba)
2025-08-11 17:45:44 +02:00
dependabot[bot]
c3969b49ee build(deps): bump actions/checkout from 4.2.2 to 5.0.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.2 to 5.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](11bd71901b...08c6903cd8)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit 593aee095f)
2025-08-11 17:45:44 +02:00
Wolfgang Walther
6f32a5f04e ci/github-script: default to commonjs
Since all github-scripts need to be written in commonjs, we now default
to it by not setting package.json. Support from editors for .js files is
slightly better than .cjs. To still allow using module imports in the
test runner script, we trick node into loading the script itself as a
module again via `--import ./run`.

(cherry picked from commit d11eba1e1d)
2025-07-15 12:57:57 +00:00
Wolfgang Walther
d202219502 ci/github-script: move from ci/labels
This just moves things around to use less specific naming - `labels` is
only *one* script that can potentially be run locally while still being
written in github-script. Later, we can add more.

(cherry picked from commit 6f6c625026)
2025-07-15 12:57:57 +00:00
Wolfgang Walther
d27bd954e6 ci/labels: run in dry mode locally
To avoid mistakes when developing and testing against the upstream repo.

(cherry picked from commit dd8357185a)
2025-07-09 07:07:33 +00:00
Wolfgang Walther
79af7b5419 ci/labels: init from workflows/labels
Moves the labels job into a separate ci/ subfolder to run it locally.
This eases debugging *a lot*.

(cherry picked from commit 89ee8975ab)
2025-07-09 07:07:29 +00:00
Wolfgang Walther
6f570b6fb8 workflows/labels: small refactor
To avoid having a diff when moving the file in the next commit.

(cherry picked from commit e90c62d5ab)
2025-07-09 07:07:29 +00:00
Wolfgang Walther
1e97b82fea workflows/labels: manage "needs: reviewer" label
This label allows finding pull requests which have no reviewer
requested, yet.

(cherry picked from commit 7900a1618f)
2025-07-04 12:35:01 +00:00
Wolfgang Walther
013a07e85c workflows/labels: paginate with cursor
Pagination via cursor is required above 10k items. To do so, we store
the current cursor as an artifact and read it back in in the next
scheduled run.

(cherry picked from commit 06a88df620)
2025-07-03 11:08:04 +00:00
Wolfgang Walther
fb77037d03 Reapply "workflows/labels: label stale issues"
This reverts commit c18e94361e.

(cherry picked from commit 23a32c9445)
2025-07-03 11:08:04 +00:00
Wolfgang Walther
96ad003d2d 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.

(cherry picked from commit 1818027916)
2025-06-27 10:09:58 +00:00
Wolfgang Walther
4faa36a97d 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.

(cherry picked from commit 3be9e2afc1)
2025-06-27 10:09:58 +00:00
Wolfgang Walther
ad1cfc34f3 workflows/labels: slightly improve logging
(cherry picked from commit 4e9df2fc31)
2025-06-27 10:09:58 +00:00
Wolfgang Walther
28ef24b4c2 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.

(cherry picked from commit 10c63e5117)
2025-06-27 10:09:58 +00:00
Wolfgang Walther
cc2830d4a8 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.

(cherry picked from commit 59ac9479e4)
2025-06-25 13:02:44 +02:00
Wolfgang Walther
cb7dd7f255 workflows/labels: fix stale label date sorting
With the help of:
https://stackabuse.com/how-to-sort-an-array-by-date-in-javascript/

(cherry picked from commit c9257371dc)
2025-06-25 12:37:49 +02:00
Wolfgang Walther
2d017eece8 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.

(cherry picked from commit 579bfd48da)
2025-06-25 07:07:20 +00:00
Wolfgang Walther
16a3962fa7 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.

(cherry picked from commit ddf3480d49)
2025-06-25 07:07:20 +00:00
Wolfgang Walther
e803fd6d97 workflows/labels: handle PR-creation-edge-case for merge conflict label
Explained very well by the code comment.

(cherry picked from commit 39dc87db4b)
2025-06-25 07:07:19 +00:00
Wolfgang Walther
3460ac2fbb 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.

(cherry picked from commit ed1fc4c6b3)
2025-06-25 07:07:19 +00:00
Wolfgang Walther
770aadc506 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.

(cherry picked from commit d5072dd344)
2025-06-25 07:07:19 +00:00
Wolfgang Walther
295a031e24 Reapply "workflows/labels: manage stale & merge conflict labels"
This reverts commit c366efa6e2.

(cherry picked from commit 0edbbfc8bb)
2025-06-25 07:07:19 +00:00
Wolfgang Walther
1e6f27590c 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.

(cherry picked from commit 24e7e47c91)
2025-06-24 07:03:15 +00:00
Wolfgang Walther
c37036b248 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.

(cherry picked from commit acc1c0ae59)
2025-06-24 07:03:15 +00:00
Wolfgang Walther
9a42b59630 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.

(cherry picked from commit 7763be5a80)
2025-06-23 10:54:39 +00:00
Wolfgang Walther
5db160cb07 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.

(cherry picked from commit 356bf98a32)
2025-06-23 06:41:07 +00:00
Wolfgang Walther
29cc462120 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.

(cherry picked from commit 28f3b92403)
2025-06-22 16:37:36 +00:00
Wolfgang Walther
6346ef5210 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.

(cherry picked from commit 5b5b18c875)
2025-06-22 16:37:36 +00:00
Wolfgang Walther
8e0587dd8f 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.

(cherry picked from commit d00d3190d6)
2025-06-21 11:39:31 +00:00
Wolfgang Walther
78399a24b4 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.

(cherry picked from commit 8e1f869261)
2025-06-21 11:39:30 +00:00
Wolfgang Walther
21584659f5 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.

(cherry picked from commit 9581b0c55b)
2025-06-21 11:39:30 +00:00
Wolfgang Walther
b42a5dc87e 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.

(cherry picked from commit 8ab44fec37)
2025-06-19 16:57:19 +00:00
Wolfgang Walther
e87d0742be workflows/eval: use consistent naming with the other 3 PR workflows
The overall idea is to use names short enough to fit into the status
checks list without shortening. This change mostly happened in the
commits before, here we just follow the same pattern for the remaining
workflows.

(cherry picked from commit c08b86e962)
2025-06-18 12:17:58 +00:00
Wolfgang Walther
9eb06853d9 workflows/{pr,push}: init
Those two workflows bundle all the main jobs in two event-specific
wrapper workflows. This enables us to do two things later on:
- Synchronize the merge commits between most of the jobs run in a PR.
- Create a single "required" job to be targeted by GitHub's "required
status checks to pass" feature.

(cherry picked from commit 959eed1f2a)
2025-06-18 12:17:58 +00:00
Matt Sturgeon
e3f742f97c workflows/labels: handle null reviewer
Review user can be null when the user has deleted their account since
posting the review.

Fixes #417627

(cherry picked from commit 2116e927da)
2025-06-17 20:27:04 +00:00
Wolfgang Walther
ed6c5a21b6 workflows/labels: add simple stats
To ease debugging rate-limiting issues.

(cherry picked from commit 4fe9129b78)
2025-06-17 13:57:21 +00:00
Wolfgang Walther
7d50d6a984 workflows/labels: improve logging for skipped PRs
Conditions that cause a PR to be skipped are now marked clearly in the
log output.

(cherry picked from commit f3b67f4eb5)
2025-06-17 13:57:21 +00:00
Wolfgang Walther
3f9e119795 workflows/labels: add bottleneck for throttling
This should prevent us from hitting API rate limits, even when we run
huge manual jobs. It just takes a bit longer.

(cherry picked from commit 114b4fcf48)
2025-06-17 13:57:21 +00:00
Wolfgang Walther
92359b8348 workflows/labels: log current API rate_limits
This will give us a little bit better insight into how close we're
running to the limits.

(cherry picked from commit 0e88d8a24d)
2025-06-17 13:57:20 +00:00
Wolfgang Walther
1f7f64b47b workflows/labels: run every 10 minutes
This will give us much quicker approval labeling, but still need much
less resources than before, when we ran on every PR comment.

(cherry picked from commit 656b53b0dd)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
f7518d076e workflows/labels: disable scheduled runs in forks
This can still be manually dispatched for testing in forks, but it's
entirely useless to keep running it on schedule.

Also removing the "skip treewide" condition, which was a left-over and
removed everywhere else already. We don't want to skip any jobs,
especially not when considering required status checks.

(cherry picked from commit 075dc097a3)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
bc401b0a78 workflows/labels: fix approved-by-maintainer label
Due to a type mismatch, maintainer approvals were never counted as such.
The API returns integers for the user IDs, but the JSON file has strings
as object keys.

(cherry picked from commit 25a0ee0817)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
6fa32c3bdc workflows/labels: skip old PRs without the right artifacts
We don't need to handle the differently named artifacts in a special
way, because they have been expired anyway. But, we must handle the case
to not cause the job to fail.

(cherry picked from commit 5343c50acd)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
53139a242f workflows/labels: improve logging
Printing the URL to the PR in the logs allows clicking on it directly in
the GitHub runner logs for easy reference.

(cherry picked from commit 022bbfd663)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
5cdc540002 workflows/labels: add more error context
The original error is kept, but the PR number is printed as well. Makes
debugging much easier.

(cherry picked from commit 97130d08e1)
2025-06-16 17:08:27 +02:00
Wolfgang Walther
af2c8fa08f workflows/labels: save artifacts per PR
Previously, the artifacts of different PRs would overwrite each other,
thus leading to odd JSON parsing errors.

(cherry picked from commit 7efbed4cd7)
2025-06-16 17:08:27 +02:00