Skip to content

Let a Hub Task's Hook Know Which Caller Runs It #3325

Open

Description

@ptr727

Problem

Two hub tasks run a caller-owned hook while passing it nothing about why it runs, so a caller whose hook needs to know has no clean route. Both surfaced while ESPHome-NonRoot adopted the reusable chain (ptr727/ESPHome-NonRoot#319, landed as ptr727/ESPHome-NonRoot#326).

1. check-upstream-version-task.yml cannot serve two callers in one repository

docs/reusable-workflows.md "Adopting the Type-Specific Tasks" says ESPHome-NonRoot's upstream-dependency watcher becomes a second caller of check-upstream-version-task.yml, with a hook emitting {"docker_base_packages": "<list>"}. The task always runs one fixed hook path, .github/actions/resolve-upstream, and passes the hook no input. In a repository whose version tracker already owns that hook, the hook cannot tell the watcher's call from the tracker's, so it cannot emit the right document for each. ESPHome-NonRoot therefore keeps check-upstream-dependency.yml as a repo-owned workflow, against the doc.

2. validate-task.yml gives the validate hook no inputs

A caller cannot pass the hook a change-gate result, so an expensive hook cannot be gated by its caller. ESPHome-NonRoot's compile test takes over 10 minutes, so its validate hook re-derives the triggering event and diffs the push itself to decide whether to run. That duplicates logic the caller already holds and that the hook can get wrong independently.

Options

  • Add a hook-path input to check-upstream-version-task.yml, defaulting to .github/actions/resolve-upstream, so a second caller names its own hook. Or add a free-form hook-input string passed through to the hook, so one hook can branch on it.
  • Add an optional hook-input (or a typed run-domain-check boolean) to validate-task.yml, passed to the validate hook, so a caller's existing change-gate decides.
  • Where neither is wanted, correct the "Adopting the Type-Specific Tasks" sentence so it no longer names a second caller the task cannot serve.

Done when

The adoption doc and the two tasks agree, and a downstream repository with two upstream-tracking needs, or an expensive domain check, can express them without re-deriving caller state inside a hook.

Found from ptr727/ESPHome-NonRoot. This issue reports findings and is not a pull request against the hub.

Activity

  1. ptr727 commented on Oct 22, 2026

    @ptr727
    OwnerAuthor

    An update on item 2 from ptr727/ESPHome-NonRoot#332, which moved that repository's CI to the hub's pull_request trigger. Its validate hook no longer diffs a push. It now fetches the test merge commit at depth 2 and diffs it against its first parent, which is the same base validate-task.yml's "Resolve prose base step" already resolves for the prose gate in the lint job. A validate-task.yml input carrying that resolved base, or the caller's paths-filter result, to the hook would remove the second copy.

  2. ptr727 commented on Nov 1, 2026

    @ptr727
    OwnerAuthor

    Decision needed (decision triage, 2026-11-01)

    Question: How should a caller's hook learn which caller is running it: an optional hook-input (or hook-path) on check-upstream-version-task.yml and a hook-input on validate-task.yml, or removing the claim in docs/reusable-workflows.md "Adopting the Type-Specific Tasks" that ESPHome-NonRoot's dependency watcher becomes a second caller?

    Options, recommended first:

    1. Add an optional hook-input string to both tasks (recommended): Passed only when non-empty (a guarded second step), so a hook declaring no such input is never handed one. One mechanism makes the doc's second-caller claim true and lets a caller hand its change-gate result or base to an expensive validate hook, so ESPHome-NonRoot can retire its repo-owned check-upstream-dependency.yml. No work in flight in the hub.
    2. Fix the doc only: Say a second caller's hook can branch on github.workflow_ref (the github context is the caller's). Cheapest, but ties the hook to a workflow filename and leaves item 2's duplicated base logic. No work in flight.
    3. Typed run-domain-check boolean on validate-task only, plus the doc fix: Solves item 2 and drops the second-caller claim, but cannot carry the resolved base the follow-up comment asks for. No work in flight.
    4. Add a hook-path input: Not workable as proposed: a step's uses: takes no expression, so the task would need a dispatcher over fixed paths. No work in flight.

    Evidence: check-upstream-version-task.yml:77-86 runs the fixed ./.github/actions/resolve-upstream with no with:, and none of its inputs reach the hook. docs/reusable-workflows.md:741 still claims a second instance with its own hook, and its Stage 5 item at :239 ("both trackers") is unchecked. validate-task.yml:823-828 runs the validate hook with no inputs. The maintainer's 2026-10-22 comment asks for the resolved base or paths-filter result, which validate-task.yml:543-554 computes in the lint job, not validate.

    Blocks: none

  3. added
    decision
    on Nov 1, 2026
  4. ptr727 commented on Nov 1, 2026

    @ptr727
    OwnerAuthor

    Maintainer answer (decision triage, 2026-11-01): Option 1: add an optional hook-input string to check-upstream-version-task.yml and validate-task.yml, passed to the hook only when non-empty. This is now work for the next burndown round.

  5. removed
    decision
    on Nov 1, 2026
  6. ptr727 commented on Nov 26, 2026

    @ptr727
    OwnerAuthor

    Released (2026-11-25): this group merged into develop as #4465 and its branch and worktree were cleaned up, so the claim holds no files.

    Backlog burndown claim (away run 2026-11-25, round 2, group D2): branch burndown/task-hook-input, issue #3325, per the maintainer's 2026-11-01 answer (option 1): an optional hook-input string on check-upstream-version-task.yml and validate-task.yml, passed to the caller's hook only when non-empty, so a caller passing nothing behaves as today.

    Predicted files:

    Not claimed: .github/actions/resolve-upstream/, .github/actions/validate/, .github/actions/validate-default/, spec/files.json, and WORKFLOW.md (held by the parked #4377 group).

    Any other group needing one of these files waits for this branch to merge.

    Extended (2026-11-25, orchestrator): .github/actions/resolve-upstream/action.yml and .github/actions/validate/action.yml, an optional hook-input declaration on each hub hook so actionlint accepts the new with: input. No other group holds them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions