surface airgap build failures#115
Conversation
ff2c828 to
f9253e5
Compare
| if (!body.releases || !Array.isArray(body.releases)) { | ||
| return null; | ||
| } | ||
| const release = body.releases.find((r: any) => r.sequence === releaseSequence); |
There was a problem hiding this comment.
does this return the first result? last result? random?
we should probably return the latest channelSequence that matches the release sequence
There was a problem hiding this comment.
Ah yes this does just return whichever match comes first in the array. Switching it to filter + reduce so we pick the highest channel sequence instead of relying on whatever find() happens to return first.
|
|
||
| core.setOutput("airgap-status", result.status); | ||
|
|
||
| if (result.status === "built") { |
There was a problem hiding this comment.
should there be a case for built_metadata too? no airgap url, but it is a successful completion
jdewinne
left a comment
There was a problem hiding this comment.
Also from another repo, make a github workflow that uses your modified action using your branch name bennyyang/sc-136443/wait-for-airgap-failures and add that in the description of the PR.
| error: body.airgapBuildError || "", | ||
| channelSequence: channelSequence | ||
| }; | ||
| } |
There was a problem hiding this comment.
This should go in the replicated-lib repo (if not already in it)
| export async function getAirgapStatusFromChannelReleases(api: VendorPortalApi, appId: string, channelId: string, releaseSequence: number): Promise<AirgapStatusResult | null> { | ||
| const http = await api.client(); | ||
| const uri = `${api.endpoint}/app/${appId}/channel/${channelId}/releases`; | ||
| const res = await http.get(uri); | ||
| if (res.message.statusCode !== 200) { | ||
| await res.readBody(); | ||
| throw new Error(`Failed to get channel releases: Server responded with ${res.message.statusCode}`); | ||
| } | ||
| const body = JSON.parse(await res.readBody()); | ||
| if (!body.releases || !Array.isArray(body.releases)) { | ||
| return null; | ||
| } | ||
| // A release can be promoted to the same channel multiple times — each | ||
| // promote produces a distinct channelSequence with its own airgap build. | ||
| // We want the most recent one (highest channelSequence) since the action | ||
| // just promoted, so its airgap build is the one we should follow. | ||
| const matching = body.releases.filter((r: any) => r.sequence === releaseSequence); | ||
| if (matching.length === 0) { | ||
| return null; | ||
| } | ||
| const release = matching.reduce((latest: any, r: any) => ((r.channelSequence ?? 0) > (latest.channelSequence ?? 0) ? r : latest)); | ||
| return { | ||
| status: release.airgapBuildStatus || "", | ||
| error: release.airgapBuildError || "", | ||
| channelSequence: release.channelSequence || 0 | ||
| }; |
There was a problem hiding this comment.
This should go in the replicated-lib repo (if not already in it)
| const uri = `${apiClient.endpoint}/app/${app.id}/channel/${resolvedChannel.id}/airgap/download-url?channelSequence=${result.channelSequence}`; | ||
| const res = await http.get(uri); | ||
| if (res.message.statusCode === 200) { | ||
| const body = JSON.parse(await res.readBody()); | ||
| core.setOutput("airgap-url", body.url); | ||
| } |
There was a problem hiding this comment.
Use replicated-lib.
Check https://github.com/replicatedhq/replicated-lib/blob/main/src/channels.ts#L128
And modify or add the lib vs doing everything within the action js.
Makes create-release fail the workflow when an airgap build ends in failed, failed_with_metadata, or cancelled (with the parsed error in setFailed), treats warn as a soft warning that stays green, and writes the outcome to the GitHub job summary.