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

Don't persist the run-summary.md file beyond its own run #503

Conversation

rtyley
Copy link
Contributor

@rtyley rtyley commented Jun 16, 2023

This was something we missed from #502 - because the run-summary.md file (introduced by scala-steward-org/scala-steward#3071) is saved to the Scala Steward workspace, and almost the entire workspace is persisted to cache by Scala Steward's GitHub Action, the report would be persisted until the next run of the GitHub Action.

Conceivably, if the next run went wrong somehow and didn't overwrite the old file, the old summary could get reported against the subsequent run, which would be bad.

The fix here is to delete the summary at the saveWorkspaceCache() step, which occurs after the summary has been transferred to the GITHUB_STEP_SUMMARY file by calling core.summary().

rtyley and others added 3 commits June 16, 2023 10:49
This was something we missed from
scala-steward-org#502 -
because the `run-summary.md` file is saved by
scala-steward-org/scala-steward#3071
to the Scala Steward workspace, and almost the entire workspace is
persisted to cache by Scala Steward's GitHub Action, the report would
be persisted until the _next_ run of the GitHub Action, and
concievably, if the next run went wrong somehow, the incorrect _old_
summary could get reported against that subsequent run, which would
be bad.

The fix here is to delete the summary at the `saveWorkspaceCache()`
step, which occurs after the summary has been transferred to the
`GITHUB_STEP_SUMMARY` file by calling `core.summary()`.
@github-actions
Copy link
Contributor

A snapshot release has been created as snapshots/503.

You can test it out with:

uses: scala-steward-org/scala-steward-action@snapshots/503

It will be automatically recreated on any change to this PR.

github-actions bot added a commit that referenced this pull request Jun 16, 2023
@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
core 100% 100% 0
modules 68% 87% 0
Summary 70% (464 / 665) 88% (76 / 86) 0

Copy link
Member

@alejandrohdezma alejandrohdezma left a comment

Choose a reason for hiding this comment

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

Great catch @rtyley! I fixed the failing lint & test so we can release this as soon as possible. Thank you very much!

@alejandrohdezma alejandrohdezma merged commit 916e71f into scala-steward-org:master Jun 16, 2023
2 checks passed
@fthomas
Copy link
Member

fthomas commented Jun 16, 2023

There is also some cleanup happening before every run in Scala Steward: https://github.com/scala-steward-org/scala-steward/blob/49b1a5f2abb80c8a4a01517827c873b580004fca/modules/core/src/main/scala/org/scalasteward/core/application/StewardAlg.scala#L95
Should we also delete it there?

@rtyley
Copy link
Contributor Author

rtyley commented Jun 16, 2023

There is also some cleanup happening before every run in Scala Steward
Should we also delete it there?

I think that makes sense, I'll raise a PR for that.

@alejandrohdezma
Copy link
Member

🤔 If we remove it there it won't be available on the action, right?

@fthomas
Copy link
Member

fthomas commented Jun 16, 2023

I think it should be since Scala Steward would only delete an old summary before it runs and the action picks up the current summary after a run has finished.

rtyley added a commit to rtyley/scala-steward that referenced this pull request Jun 16, 2023
To ensure that its workspace is clean, and that unintended files are not
held over from previous runs, Scala Steward already erases the `repos`
folder before starting its run. With new `run-summary.md` file
introduced by scala-steward-org#3071,
we again want to be careful that the summary file from a previous run
isn't picked up in a subsequent run.

scala-steward-org/scala-steward-action#503
addressed this for the particular concern of GitHub Actions, by ensuring
that the file wasn't persisted to cache, but @fthomas pointed out that
this additional point at the start of Scala Steward's code was also an
appropriate place for removing any run-specific files:

scala-steward-org/scala-steward-action#503 (comment)
rtyley added a commit to rtyley/scala-steward that referenced this pull request Jun 16, 2023
To ensure that its workspace is clean, and that unintended files are not
held over from previous runs, Scala Steward already erases the `repos`
folder before starting its run. With new `run-summary.md` file
introduced by scala-steward-org#3071,
we again want to be careful that the summary file from a previous run
isn't picked up in a subsequent run.

scala-steward-org/scala-steward-action#503
addressed this for the particular concern of GitHub Actions, by ensuring
that the file wasn't persisted to cache, but @fthomas pointed out that
this additional point at the start of Scala Steward's code was also an
appropriate place for removing any run-specific files:

scala-steward-org/scala-steward-action#503 (comment)
@alejandrohdezma
Copy link
Member

I think it should be since Scala Steward would only delete an old summary before it runs and the action picks up the current summary after a run has finished.

Oh, sorry, you're right, my brain read after instead of before 😂

@rtyley
Copy link
Contributor Author

rtyley commented Jun 16, 2023

I think that makes sense, I'll raise a PR for that.

PR raised for clearing-out run-specific files like run-summary.md with scala-steward-org/scala-steward#3088.

mzuehlke pushed a commit to scala-steward-org/scala-steward that referenced this pull request Jun 19, 2023
To ensure that its workspace is clean, and that unintended files are not
held over from previous runs, Scala Steward already erases the `repos`
folder before starting its run. With new `run-summary.md` file
introduced by #3071,
we again want to be careful that the summary file from a previous run
isn't picked up in a subsequent run.

scala-steward-org/scala-steward-action#503
addressed this for the particular concern of GitHub Actions, by ensuring
that the file wasn't persisted to cache, but @fthomas pointed out that
this additional point at the start of Scala Steward's code was also an
appropriate place for removing any run-specific files:

scala-steward-org/scala-steward-action#503 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants