Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save workspace cache when run failed #631

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
54 changes: 28 additions & 26 deletions src/action/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,41 @@ async function run(): Promise<void> {
? `org.scala-steward:scala-steward-core_2.13:${inputs.steward.version.value}`
: 'scala-steward'

await coursier.launch(app, [
argument('--workspace', workspace.workspace),
argument('--repos-file', workspace.repos_md),
argument('--git-ask-pass', workspace.askpass_sh),
argument('--git-author-email', inputs.commits.author.email ?? user.email()),
argument('--git-author-name', inputs.commits.author.name ?? user.name()),
argument('--forge-login', user.login()),
argument('--env-var', nonEmpty('"SBT_OPTS=-Xmx2048m -Xss8m -XX:MaxMetaspaceSize=512m"')),
argument('--process-timeout', inputs.steward.timeout),
argument('--forge-api-host', inputs.github.apiUrl),
argument('--ignore-opts-files', inputs.steward.ignoreOptsFiles),
argument('--sign-commits', inputs.commits.sign.enabled),
argument('--git-author-signing-key', inputs.commits.sign.key),
argument('--cache-ttl', inputs.steward.cacheTtl),
argument('--max-buffer-size', inputs.steward.maxBufferSize),
argument('--scalafix-migrations', inputs.migrations.scalafix),
argument('--artifact-migrations', inputs.migrations.artifacts),
argument('--repo-config', inputs.steward.defaultConfiguration),
argument('--github-app-id', inputs.github.app && !inputs.github.app.authOnly ? inputs.github.app.id : undefined),
argument('--github-app-key-file', inputs.github.app && !inputs.github.app.authOnly ? workspace.app_pem : undefined),
'--do-not-fork',
'--disable-sandbox',
inputs.steward.extraArgs?.value.split(' ') ?? [],
], inputs.steward.extraJars)
try {
await coursier.launch(app, [
argument('--workspace', workspace.workspace),
argument('--repos-file', workspace.repos_md),
argument('--git-ask-pass', workspace.askpass_sh),
argument('--git-author-email', inputs.commits.author.email ?? user.email()),
argument('--git-author-name', inputs.commits.author.name ?? user.name()),
argument('--forge-login', user.login()),
argument('--env-var', nonEmpty('"SBT_OPTS=-Xmx2048m -Xss8m -XX:MaxMetaspaceSize=512m"')),
argument('--process-timeout', inputs.steward.timeout),
argument('--forge-api-host', inputs.github.apiUrl),
argument('--ignore-opts-files', inputs.steward.ignoreOptsFiles),
argument('--sign-commits', inputs.commits.sign.enabled),
argument('--git-author-signing-key', inputs.commits.sign.key),
argument('--cache-ttl', inputs.steward.cacheTtl),
argument('--max-buffer-size', inputs.steward.maxBufferSize),
argument('--scalafix-migrations', inputs.migrations.scalafix),
argument('--artifact-migrations', inputs.migrations.artifacts),
argument('--repo-config', inputs.steward.defaultConfiguration),
argument('--github-app-id', inputs.github.app && !inputs.github.app.authOnly ? inputs.github.app.id : undefined),
argument('--github-app-key-file', inputs.github.app && !inputs.github.app.authOnly ? workspace.app_pem : undefined),
'--do-not-fork',
'--disable-sandbox',
inputs.steward.extraArgs?.value.split(' ') ?? [],
], inputs.steward.extraJars)
} 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()
Comment on lines +79 to -86
Copy link
Contributor

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:

} catch (error: unknown) {
core.setFailed(` ✕ ${(error as Error).message}`)
}
Expand Down