Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/test-wasm-golden.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,23 @@ function normalizeContainerPins(content) {
return content.replace(/@sha256:[0-9a-f]{64}/g, "");
}

// ── Normalize AWF --image-tag digest suffixes ─────────────────────────
// Strips ",name=sha256:<64 hex chars>" fragments appended to --image-tag values
// so output compares equal when runtime image digests are present in one path but not another.
// Mirrors normalizeOutput() in pkg/workflow/wasm_golden_test.go.
function normalizeAWFImageTagDigests(content) {
return content.replace(/,[a-z-]+=sha256:[0-9a-f]{64}/g, "");
Comment on lines +155 to +157
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The regex key pattern [,a-z-]+ may be too restrictive for AWF --image-tag keys (e.g., if they can include digits). If a key like foo2=sha256:... appears, it won’t be normalized and the original flakiness can persist. Consider broadening the key character class (e.g., include 0-9) to match all valid tag keys used by AWF.

Suggested change
// Mirrors normalizeOutput() in pkg/workflow/wasm_golden_test.go.
function normalizeAWFImageTagDigests(content) {
return content.replace(/,[a-z-]+=sha256:[0-9a-f]{64}/g, "");
// Accept lowercase letters, digits, and hyphens in tag keys so valid keys
// like "foo2" are normalized consistently.
// Mirrors normalizeOutput() in pkg/workflow/wasm_golden_test.go.
function normalizeAWFImageTagDigests(content) {
return content.replace(/,[a-z0-9-]+=sha256:[0-9a-f]{64}/g, "");

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

This replacement will strip any ,name=sha256:<digest> pattern anywhere in the rendered output, not just within AWF --image-tag arguments. To reduce the risk of accidentally normalizing unrelated content that happens to match the pattern, consider scoping the replacement to contexts that clearly indicate an --image-tag value (e.g., only within --image-tag arguments or the specific YAML field/line formats emitted by the generator).

Suggested change
return content.replace(/,[a-z-]+=sha256:[0-9a-f]{64}/g, "");
const imageTagDigestSuffix = /,[a-z-]+=sha256:[0-9a-f]{64}/g;
return content
.split("\n")
.map((line) => {
if (line.includes("--image-tag") || line.includes("image-tag:")) {
return line.replace(imageTagDigestSuffix, "");
}
return line;
})
.join("\n");

Copilot uses AI. Check for mistakes.
}

// ── Normalize output ──────────────────────────────────────────────────
// Applies all normalizations needed for stable golden comparison.
// Combines heredoc delimiter and container pin normalizations so that
// new normalization steps only need to be added in one place.
// Mirrors normalizeOutput() in pkg/workflow/wasm_golden_test.go.
function normalize(content) {
return normalizeContainerPins(normalizeHeredocDelimiters(content));
return normalizeAWFImageTagDigests(
normalizeContainerPins(normalizeHeredocDelimiters(content))
);
}

// ── Load golden file ─────────────────────────────────────────────────
Expand Down
Loading