spark-test commented on code in PR #60352:
URL: https://github.com/apache/spark/pull/60352#discussion_r4552446921
##########
.github/workflows/labeler.yml:
##########
@@ -22,73 +22,80 @@
# Manually added configured labels are removed on the next scan if they do not
# match the PR's changed files.
#
-# To label all open PRs once, regardless of their last update:
-# gh workflow run labeler.yml --repo apache/spark --ref master -f
backfill=true
-
+# Each run labels PRs updated since 10 minutes before the last successful run
+# was created, so failed or skipped runs only widen the next run's window. The
+# PRs are split into groups that are labeled by parallel jobs, keeping each job
+# well within ubuntu-slim's 15-minute job limit.
name: Label pull requests
on:
schedule:
- cron: "7-59/10 * * * *"
workflow_dispatch:
- inputs:
- backfill:
- description: Label all open PRs regardless of their last update
- type: boolean
- default: false
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
- queue: max
jobs:
- label:
- name: Label pull requests
+ list:
+ name: List pull requests
if: github.repository == 'apache/spark' && github.ref ==
'refs/heads/master'
- runs-on: ubuntu-latest
+ runs-on: ubuntu-slim
permissions:
actions: read
- contents: read
- pull-requests: write
+ pull-requests: read
+ outputs:
+ groups: ${{ steps.prs.outputs.groups }}
steps:
- - name: Checkout labeler configuration
- uses: actions/checkout@v7
- with:
- persist-credentials: false
- sparse-checkout: .github
- name: List PRs
id: prs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- BACKFILL: ${{ inputs.backfill }}
run: |
- if [[ "$BACKFILL" == "true" ]]; then
- filters=(-f state=open)
- echo "Listing all open PRs"
+ last_success=$(gh run list --repo "$GITHUB_REPOSITORY" \
+ --workflow labeler.yml --branch master --status success --limit 1 \
Review Comment:
**Nit (P3):** This query no longer passes `--event schedule`, so the newest
successful run of any event on master now sets where the next window starts.
The run history it reads carries over from the base branch's version of this
workflow, whose `backfill=true` dispatches list only open PRs; the base
branch's event filter kept those runs from setting the window. If such a
dispatch is the newest successful run when the first run after merge lists,
that run's window starts 10 minutes before the dispatch was created, so no run
lists a PR that was already closed by then and was last updated after the last
successful listing by update time. If its files changed since it was last
labeled, its labels stay stale, with no error, until it is next updated, which
for a merged PR may be never.
For example, suppose scheduled runs fail during an incident from 10:00,
after a successful listing at 09:57. At 12:00 a committer runs the documented
`gh workflow run labeler.yml --repo apache/spark --ref master -f
backfill=true`, which labels every open PR, and this PR merges at 12:05. The
12:07 scheduled run, the first of the new version, would anchor on the 12:00
dispatch and list only PRs updated since 11:50, so a PR that got a push
touching another area at 10:20 and was merged at 10:30 would never get that
area's label. On the base branch, the 12:07 run's window would have started at
09:47, 10 minutes before the last scheduled success started, and would have
covered that PR.
The gap can open only once, before a run of the new version succeeds and
becomes the anchor, and it holds PRs only after a stretch of failed scheduled
runs. Nothing in the stated problem needs manual runs to move the window,
though, and the PR gives no reason for counting them.
**Recommended change:** Pass `--event schedule` to the `gh run list` call in
the List PRs step again, next to `--workflow labeler.yml --branch master
--status success --limit 1`, keeping `--repo "$GITHUB_REPOSITORY"` and the
`createdAt` field. Update the header comment to say that each run labels PRs
updated since 10 minutes before the last successful scheduled run was created.
The base branch has this filter. The PR's first commit, 0b1d66e8aec (Reduce PR
labeler delays), removed it, and its message gives no reason.
**Why this works:** Every scheduled run, under the base branch's version or
this one, lists all PRs updated since its own window start, so a successful
scheduled run is always a safe anchor. Counting only scheduled runs keeps a run
that listed less, such as a backfill dispatch that listed only open PRs, from
setting where the next window starts. Manual dispatches still compute the same
anchor and list the same window as the next scheduled run would; when they
succeed, they just no longer move it.
**Scope:** Restore the schedule-event filter on the List PRs step's
run-history query, and update the header comment to name scheduled runs as the
window's anchor.
**Compatibility:** Manual dispatches still list the same incremental window
as scheduled runs. Re-running a scheduled run's failed jobs still reuses its
original listing, and because the next window is anchored on that run's
creation time, it still starts before that listing ran.
**Risks:** Manual dispatches no longer move the window, so after a
successful manual run, the next scheduled run lists and re-reads the PRs that
run covered. Their labels already match, so the extra cost is API reads and
runner time, with no label writes. Dropping `--event schedule` later lets
manual runs move the window again, and once a scheduled run with the filter has
succeeded, doing so no longer lets an old backfill dispatch set it. If
scheduled runs stopped while manual runs continued, each manual run would list
from the last successful scheduled run, and its window would keep growing until
a scheduled run succeeds.
**Constraints:** Manual dispatches must keep listing the same window as the
next scheduled run, as the PR description states. Keep `--repo
"$GITHUB_REPOSITORY"`, `--branch master`, `--status success`, `--limit 1`, and
the `createdAt` field, so the earlier fixes for repository resolution and for
re-runs of failed jobs stay in place.
**Exclusions:**
- Telling earlier backfill dispatches apart from other manual runs is out of
scope, because the run list does not expose the inputs a run was dispatched
with.
- How a run lists or labels PRs once its window start is chosen stays
unchanged.
**Success:** The List PRs step's `gh run list` call passes `--event
schedule` together with `--repo "$GITHUB_REPOSITORY"`, `--workflow
labeler.yml`, `--branch master`, `--status success` and `--limit 1`, and reads
`createdAt`. A successful manual dispatch, including a backfill dispatch made
under the base branch's version, never sets the window start. Each window
starts 10 minutes before the newest successful scheduled run was created, or 12
hours ago when there is none. The header comment names the last successful
scheduled run as the window's anchor.
**Verification:**
- **Regression:** Take a run history whose newest successful run is a manual
dispatch created after the newest successful scheduled run. The List PRs step
must start its window 10 minutes before the scheduled run was created, not
before the dispatch, so a closed PR updated between the two is listed.
- **Behavior:** When the newest successful run is a scheduled run, the List
PRs step starts its window 10 minutes before that run was created. When no
scheduled run has succeeded, it starts the window 12 hours ago.
- **Inspection:** The header comment says each run labels PRs updated since
10 minutes before the last successful scheduled run was created. The `gh run
list` call keeps its repository, workflow, branch, status, limit and
`createdAt` arguments alongside the schedule-event filter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]