Skip to content

[eas-cli][build-tools][steps] Validate local composite functions referenced from workflow hooks; extract the shared loader into steps - #4064

Merged
sswrk merged 4 commits into
mainfrom
szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions
Aug 5, 2026
Merged

[eas-cli][build-tools][steps] Validate local composite functions referenced from workflow hooks; extract the shared loader into steps#4064
sswrk merged 4 commits into
mainfrom
szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions

Conversation

@sswrk

@sswrk sswrk commented Jul 23, 2026

Copy link
Copy Markdown
Member

Why

Workflow validation already checks local composite functions referenced from job steps, but hooks can also use uses: ./..... eas workflow:validate don't catch problems with composite functions in hooks.

This PR also includes an extraction of duplicated (eas-cli and build-tools) composite function loader to @expo/steps.

How

Validation of workflows in eas-cli now reads each job's hooks steps too, not just job.steps.

Removed a duplicate loader from eas-cli and build-tools, moved it to steps.

Test Plan

Added unit tests.

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

ENG-22387

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.42%. Comparing base (94f473b) to head (da1ec6a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4064      +/-   ##
==========================================
- Coverage   62.43%   62.42%   -0.00%     
==========================================
  Files        1009     1008       -1     
  Lines       45737    45712      -25     
  Branches     9622     9622              
==========================================
- Hits        28550    28530      -20     
+ Misses      15726    15721       -5     
  Partials     1461     1461              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from a32c830 to cc4a09e Compare July 23, 2026 16:17
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from cc4a09e to 9f8972c Compare July 23, 2026 17:06
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 9f8972c to 9a9c633 Compare July 24, 2026 11:43
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 9a9c633 to a4a94b7 Compare July 24, 2026 11:49
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from a4a94b7 to 3cb953a Compare July 24, 2026 12:33
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 3cb953a to bc5f0bb Compare July 24, 2026 13:02
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from bc5f0bb to bc5dee9 Compare July 24, 2026 14:12
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from bc5dee9 to 51157f3 Compare July 24, 2026 14:42
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 51157f3 to 6f6441f Compare July 24, 2026 15:00
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 6f6441f to e6a3b9a Compare July 24, 2026 15:18
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 2fa436b to ba6e97f Compare July 30, 2026 15:11
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from ba6e97f to eb63c1a Compare July 30, 2026 15:34
@sswrk

sswrk commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Also, moving an open discussion from the previous eas-cli PR in the stack: #4064

@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from eb63c1a to 5038af8 Compare July 30, 2026 15:44
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 5038af8 to c3e6849 Compare July 30, 2026 16:12
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch 2 times, most recently from 51c7e4c to a78602b Compare July 31, 2026 13:26
@sswrk sswrk changed the title [eas-cli] Validate local composite functions referenced from workflow hooks [eas-cli][build-tools][steps] Validate local composite functions referenced from workflow hooks; extract the shared loader into steps Jul 31, 2026
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 2c769a5 to f40e28c Compare July 31, 2026 14:46
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from f40e28c to d3a4b3a Compare July 31, 2026 17:05
@sswrk sswrk added the ai-review Commits pushed to PRs with this label be automatically reviewed. label Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

🤖 AI code review

Decision: Approve with comments

Overall PR risk: Medium. The change moves composite-function loading logic from eas-cli and build-tools into the shared @expo/steps package, and updates all call sites to new function names and option-object argument shapes. It also extends workflow validation to check job hooks, not just job steps. The affected surface is the composite-function resolution path used by build job runners and by eas workflow:validate, bounded but touched on every build that references local composite functions. One warning-level finding survived review: the new shared loader throws a bare Error instead of BuildConfigError, which causes StepsConfigParser to wrap an already-clear error message in a redundant, doubled message for the user. This is a message-quality regression, not a functional break, and the change is straightforward to revert if a problem appears.

🟡 Warning (1)

  • Loader throws bare Error instead of BuildConfigError, breaking StepsConfigParser message handlingpackages/steps/src/utils/localCompositeFunctions.ts:159 (quality) · id:17dbd9389c62
    Confidence: High — the trace through StepsConfigParser.ts shows the exact instanceof BuildConfigError branch this new code defeats.
    Impact if shipped: Medium — hook load failures for a missing or invalid composite function show a doubled, unclear error message instead of the clear message the code already built.
    Suggested remediation: Throw BuildConfigError (from ../errors) instead of bare Error in all four failure branches of loadLocalCompositeFunctionConfigAsync. This matches the pattern in this file and in CompositeFunctionExpander.ts.

    Evidence and reasoning

    Every other error in this file and package uses BuildConfigError for user config problems. Examples: parseLocalCompositeFunctionPath (line 28-31), collectLocalCompositeFunctionPathsFromSteps (line 188), and the near-identical "composite function does not exist" check in CompositeFunctionExpander.lookupCompositeFunction (packages/steps/src/CompositeFunctionExpander.ts:190-193).

    The new loadLocalCompositeFunctionConfigAsync throws plain Error for all four of its failure cases: read failure, YAML parse failure, zod validation failure, and "no such composite function exists".

    This is not just a style issue. StepsConfigParser.ts:305-324 calls this loader through extendCompositeFunctionCatalogFromStepsAsync. It checks err instanceof BuildConfigError. If true, it keeps the inner message as-is (line 314-317). If false, it wraps the message in a generic "Failed to load a local composite function referenced from ..." prefix (line 319-323). Because the new loader never throws BuildConfigError, every failure takes the generic-wrap branch. This includes the well-written "was referenced by a step but no such composite function exists" message. The user then sees a doubled message instead of the clean one already built.


This review is advisory — it never blocks a merge and never auto-approves.

@sswrk

sswrk commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Re. AI review:

Validation skips jobs with a custom project root

That's a deliberate skip. Validating it would need injecting the vcs client. Will change it if human reviewers advise doing so

Invalid function config uses the wrong error type

Not specific to this PR, worth considering as a follow up

Path text can inject terminal control characters

not specific to this PR, a general pattern

Validation loads composites from ignored hooks

It does hold up, but it was deliberate: we can only do static verification here, so that's the only way we can check those functions within workflow:validate. Will change it if human reviewers advise doing so.

@sswrk
sswrk marked this pull request as ready for review July 31, 2026 18:11
@sswrk
sswrk requested review from hSATAC and sjchmiela July 31, 2026 18:11
@github-actions

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
packages/eas-cli/** @douglowder

Generated by CodeMention

Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead.

@hSATAC hSATAC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left two comments.

Comment thread packages/eas-cli/src/commandUtils/workflow/compositeFunctions.ts
Comment thread packages/eas-cli/src/commandUtils/workflow/compositeFunctions.ts Outdated

@hSATAC hSATAC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good. 👍

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

✅ Thank you for adding the changelog entry!

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

Labels

ai-review Commits pushed to PRs with this label be automatically reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants