Skip to content

Commit f8d58bb

Browse files
Copilotpelikhan
andauthored
fix: align CJS error messages with main branch to fix CI test failures
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/f49e39ad-fc0f-44fc-a75c-4c451342b736 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 538df40 commit f8d58bb

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

actions/setup/js/check_workflow_timestamp_api.cjs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/// <reference types="@actions/github-script" />
33

44
/**
5-
* Check workflow lock file integrity using frontmatter hash validation.
5+
* Check for a stale workflow lock file using frontmatter hash comparison.
66
* This script verifies that the stored frontmatter hash in the lock file
7-
* matches the recomputed hash from the source .md file, regardless of
8-
* commit timestamps.
7+
* matches the recomputed hash from the source .md file, detecting cases where
8+
* the workflow was edited without recompiling the lock file. It does not
9+
* provide tamper protection — use code review to guard against intentional
10+
* modifications.
911
*
1012
* Supports both same-repo and cross-repo reusable workflow scenarios:
1113
* - Primary: GitHub API (uses GITHUB_WORKFLOW_REF to identify source repo)
@@ -33,7 +35,7 @@ async function main() {
3335
const workflowMdPath = `.github/workflows/${workflowBasename}.md`;
3436
const lockFilePath = `.github/workflows/${workflowFile}`;
3537

36-
core.info(`Checking workflow lock file integrity using frontmatter hash:`);
38+
core.info(`Checking for stale lock file using frontmatter hash:`);
3739
core.info(` Source: ${workflowMdPath}`);
3840
core.info(` Lock file: ${lockFilePath}`);
3941

@@ -203,11 +205,11 @@ async function main() {
203205
if (!hashComparison) {
204206
// Could not compute hash - be conservative and fail
205207
core.warning("Could not compare frontmatter hashes - assuming lock file is outdated");
206-
const warningMessage = `Lock file '${lockFilePath}' integrity check failed! Could not verify frontmatter hash for '${workflowMdPath}'. Run 'gh aw compile' to regenerate the lock file.`;
208+
const warningMessage = `Lock file '${lockFilePath}' is outdated or unverifiable! Could not verify frontmatter hash for '${workflowMdPath}'. Run 'gh aw compile' to regenerate the lock file.`;
207209

208210
let summary = core.summary
209211
.addRaw("### ⚠️ Workflow Lock File Warning\n\n")
210-
.addRaw("**WARNING**: Lock file integrity check failed. Could not verify frontmatter hash.\n\n")
212+
.addRaw("**WARNING**: Could not verify whether lock file is up to date. Frontmatter hash check failed.\n\n")
211213
.addRaw("**Files:**\n")
212214
.addRaw(`- Source: \`${workflowMdPath}\`\n`)
213215
.addRaw(`- Lock: \`${lockFilePath}\`\n\n`)

actions/setup/js/check_workflow_timestamp_api.test.cjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ jobs:
235235
await main();
236236

237237
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not compare frontmatter hashes"));
238-
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("integrity check failed"));
238+
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("outdated or unverifiable"));
239239
expect(mockCore.summary.addRaw).toHaveBeenCalled();
240240
expect(mockCore.summary.write).toHaveBeenCalled();
241241
});
@@ -246,7 +246,7 @@ jobs:
246246
await main();
247247

248248
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not compare frontmatter hashes"));
249-
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("integrity check failed"));
249+
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("outdated or unverifiable"));
250250
expect(mockCore.summary.addRaw).toHaveBeenCalled();
251251
expect(mockCore.summary.write).toHaveBeenCalled();
252252
});
@@ -348,7 +348,7 @@ engine: claude
348348

349349
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Unable to fetch lock file content"));
350350
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not compare frontmatter hashes"));
351-
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("integrity check failed"));
351+
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("outdated or unverifiable"));
352352
});
353353
});
354354

@@ -700,7 +700,7 @@ engine: copilot
700700
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Unable to fetch lock file content for hash comparison via API"));
701701
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("GITHUB_WORKSPACE not available"));
702702
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not compare frontmatter hashes"));
703-
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("integrity check failed"));
703+
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("outdated or unverifiable"));
704704
});
705705

706706
it("should fail when API fails and local lock file is missing", async () => {
@@ -712,7 +712,7 @@ engine: copilot
712712

713713
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Local lock file not found"));
714714
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not compare frontmatter hashes"));
715-
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("integrity check failed"));
715+
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("outdated or unverifiable"));
716716
});
717717

718718
it("should use API if available even in cross-repo scenario (API preferred over local files)", async () => {
@@ -785,7 +785,7 @@ engine: copilot
785785
// The path traversal is rejected before any file read
786786
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("escapes workspace"));
787787
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not compare frontmatter hashes"));
788-
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("integrity check failed"));
788+
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("outdated or unverifiable"));
789789
});
790790
});
791791

0 commit comments

Comments
 (0)