-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Save workspace cache when run failed #631
Save workspace cache when run failed #631
Conversation
A snapshot release has been created as You can test it out with: uses: scala-steward-org/scala-steward-action@snapshots/631 It will be automatically recreated on any change to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change makes sense to me.
Thanks! |
Scala Steward's GitHub Action Job Summary, which details success or failure of each repo in the Scala Steward run, was added with scala-steward-org/scala-steward#3071 in June 2023, followed up by scala-steward-org/scala-steward#3088, which ensured that old `run-summary.md` files couldn't persist in the workspace cache (where they might become misleading), by purging them before the cache was saved. Unfortunately scala-steward-org#631 (released with v2.67.0 in September 2024) unintentionally broke the outputting of the Job Summary, because it moved the `saveWorkspaceCache()` call (which among other things deletes the `run-summary.md` file) to a point _before_ the `run-summary.md` file was read and output to the GitHub Action Job Summary. We can see this in these two successive runs of the Guardian's Scala Steward workflow: * Run 6002 (using scala-steward-action@v2.65.0) successfully output the scala-steward summary: https://github.com/guardian/scala-steward-public-repos/actions/runs/11591772739 https://github.com/guardian/scala-steward-public-repos/actions/runs/11591772739/job/32272232470#step:7:4512 * Run 6003 (using scala-steward-action@v2.70.0) silently omitted to output the summary: https://github.com/guardian/scala-steward-public-repos/actions/runs/11592668893 https://github.com/guardian/scala-steward-public-repos/actions/runs/11592668893/job/32275051343#step:7:35 The fix is just to move the code writing the run-summary earlier, to _before_ the new `finally` block introduced by scala-steward-org#631 which executes `saveWorkspaceCache()`. I've also renamed the method to make its actions a little clearer: * OLD: `workspace.saveWorkspaceCache()` * NEW: `workspace.purgeTempFilesAndSaveCache()`
} finally { | ||
await workspace.saveWorkspaceCache() | ||
} | ||
|
||
if (files.existsSync(workspace.runSummary_md)) { | ||
logger.info(`✓ Run Summary file: ${workspace.runSummary_md}`) | ||
|
||
const summaryMarkdown = files.readFileSync(workspace.runSummary_md, 'utf8') | ||
await core.summary.addRaw(summaryMarkdown).write() | ||
} | ||
|
||
await workspace.saveWorkspaceCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, small problem here! The saveWorkspaceCache()
method deletes temporary files (like run-summary.md
) before saving the cache, and moving saveWorkspaceCache()
to before the run-summary processing-code unfortunately means that the run-summary.md
is deleted before it's even read..!
See this PR for the fix:
Fixes #632
Cache from previously failed attempts is restored
And then it's also saved if current attempt fails