Skip to content

[eas-build-job] Accept legacy command/path custom function shape in function.yml - #4095

Draft
sswrk wants to merge 1 commit into
szymonswierk/eng-22387-eas-cli-validate-hook-composite-functionsfrom
szymonswierk/eng-25402-eas-build-job-legacy-function-shape
Draft

[eas-build-job] Accept legacy command/path custom function shape in function.yml#4095
sswrk wants to merge 1 commit into
szymonswierk/eng-22387-eas-cli-validate-hook-composite-functionsfrom
szymonswierk/eng-25402-eas-build-job-legacy-function-shape

Conversation

@sswrk

@sswrk sswrk commented Jul 27, 2026

Copy link
Copy Markdown
Member

Why

First step toward grandfathering the older custom build functions into .eas/functions.

EAS Workflows can call reusable local functions defined in .eas/functions/<name>/function.yml, but until now such a file could only describe a composite function (a named group of steps). The older custom build functions from .eas/build configs (docs) are defined differently: a single shell command or a path to a prebuilt JS module. The body of such a function should work as a function.yml verbatim, so that moving one into .eas/functions is a copy-paste. Suggested in the review of the composite functions stack (#3928).

How

Widens the function.yml contract in @expo/eas-build-job, the single source of truth for its shape. A file now declares either runs.steps (a composite function) or command/path (a single-step function); the two shapes are mutually exclusive and mixing them produces a clear error.

  • Adds LegacyFunctionConfigZ / LegacyFunctionConfig for the single-step shape: name, description, inputs (same shape as composite inputs, so the legacy YAML copies over verbatim), array-form outputs, command, path, shell, supported_platforms.
  • Adds LocalFunctionConfigZ, the union both loaders will parse with. It sniffs the shape and delegates to one branch rather than unioning two strict objects, which keeps errors precise: a bare union reports every branch's failures for a single typo. Sub-schema issues are re-emitted with their paths intact, so the existing z.prettifyError formatting keeps working.
  • Adds the isLegacyFunctionConfig guard, plus command/path/shell/supported_platforms as z.never().optional() on the composite schema (the StepZ narrowing pattern) so the union discriminates in TypeScript.

No runtime behavior changes yet. The CompositeFunctionCatalog widening lands in the next PR, together with the @expo/steps code that handles both shapes, so that every commit in the stack typechecks on its own.

Test Plan

cd packages/eas-build-job && yarn test src/__tests__/compositeFunction.test.ts

Unit tests cover both shapes, the conflict cases (runs + command, runs + path, both command and path, neither) with exact error messages, cross-shape outputs rejection, unknown supported_platforms values, non-mapping input, unknown keys, and that prettified errors still point at the offending field.

@linear-code

linear-code Bot commented Jul 27, 2026

Copy link
Copy Markdown

ENG-25402

sswrk commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

@sswrk sswrk added the no changelog PR that doesn't require a changelog entry label Jul 27, 2026
@sswrk
sswrk force-pushed the szymonswierk/eng-25402-eas-build-job-legacy-function-shape branch from e893fae to 3b018d6 Compare July 28, 2026 09:04
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch 2 times, most recently from 01ffc9f to dac0ac2 Compare July 28, 2026 12:58
@sswrk
sswrk force-pushed the szymonswierk/eng-25402-eas-build-job-legacy-function-shape branch from 3b018d6 to 891ef23 Compare July 28, 2026 12:58
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from dac0ac2 to ec45af1 Compare July 28, 2026 13:11
@sswrk
sswrk force-pushed the szymonswierk/eng-25402-eas-build-job-legacy-function-shape branch from 891ef23 to 27f53d7 Compare July 28, 2026 13:11
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from ec45af1 to 0ca9abb Compare July 28, 2026 15:30
@sswrk
sswrk force-pushed the szymonswierk/eng-25402-eas-build-job-legacy-function-shape branch from 27f53d7 to e8d69a0 Compare July 28, 2026 15:30
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from 0ca9abb to e71d330 Compare July 29, 2026 09:01
@sswrk
sswrk force-pushed the szymonswierk/eng-25402-eas-build-job-legacy-function-shape branch from e8d69a0 to 702bea2 Compare July 29, 2026 09:01
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from e71d330 to c99eeea Compare July 29, 2026 09:28
@sswrk
sswrk force-pushed the szymonswierk/eng-25402-eas-build-job-legacy-function-shape branch from 702bea2 to 961f32c Compare July 29, 2026 09:28
@sswrk
sswrk force-pushed the szymonswierk/eng-25402-eas-build-job-legacy-function-shape branch from 961f32c to 9d5f159 Compare July 29, 2026 13:40
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-eas-cli-validate-hook-composite-functions branch from c99eeea to 34605fd Compare July 29, 2026 13:40
@github-actions

Copy link
Copy Markdown

⏩ The changelog entry check has been skipped since the "no changelog" label is present.

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

Labels

no changelog PR that doesn't require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant