thebrowsercompany / swift-build

Swift toolchain builds by The Browser Company
351 stars 10 forks source link

[gha][binary sizes] Use the input context to read the toolchain_version #150

Closed kendalharland closed 2 months ago

kendalharland commented 2 months ago

This workflow is failing to run when new swift toolchain releases are created because toolchain_version is resolved to the branch name ("main") after the initial context job, rather than the newly released swift toolchain version. The bug is in the callee (release-swift-toolchain-binary-sizes.yml) rather than the caller (workflow-run-release-swift-toolchain-binary-sizes.yml), which is correctly looking up and passing the toolchain version along in its workflow invocation.

This is happening because the callee reads the toolchain_version input using github.event.inputs which is empty if the caller is triggered by a workflow_run event which has no inputs: The caller's github.event.inputs is always forwarded to the callee for workflow_run event triggers.

This was not caught during testing because in presubmit we trigger the caller using pull_request rather than workflow_run, and we look for a hard-coded test toolchain version since no latest version is available. This change switches the callee to use the input context which always has the correct value regardless of whether the triggering event is workflow_call (whereby we inherit github.event from the caller) or workflow_dispatch (whereby the inputs are passed directly to the workflow by the user).