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
Fix the GitHub actions cron job #11256
Conversation
@@ -85,7 +85,7 @@ jobs: | |||
rm -rf ~/.ivy2/local | |||
sbt "${{needs.extra-vars.outputs.akka_version_opts}}" "${{needs.extra-vars.outputs.akka_http_version_opts}}" crossScalaVersions crossSbtVersions +publishLocal | |||
cache-path: ~/.ivy2/local/com.typesafe.play | |||
cache-key: play-published-local-jdk8-${{ github.sha }} | |||
cache-key: play-published-local-jdk8-${{ github.sha }}-${{ github.event_name != 'schedule' || github.run_id }} |
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.
So this is a bit of a hacky way to generate a unique cache key for scheduled jobs, but not for pull request jobs.
So when a pull request gets build the cache-key will be something like:
play-published-local-jdk8-55238a2b-true
That way the cache can be reused across multiple pull requests (remember, for pull requests we do not use akka snapshots, but stable versions. So if the pr base branch did not change between pull requests we are absolutely fine reusing the cache containing the local published Play artifacts)
For schedules jobs however we always want to create a new cache for each workflow run, since we don't know if the akka(-http) snapshot version changed between two nightly runs (so the cache is effectively only used by the scripted jobs after it got filled by the publish local step). The key will then look like:
play-published-local-jdk8-55238a2b-2238770949
I did test this expression here: https://github.com/mkurz/release-drafter-test/runs/6209442291?check_suite_focus=true#step:8:10 (you can have a look in the workflow file)
I can not see in the docs how to achieve that in another way, since we can't have if
conditions within expressions (also no elvis operator): https://docs.github.com/en/actions/learn-github-actions/expressions
If someone has a nicer way to do that, please let me know 😉
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.
As another variant, we can to use the Akka versions. Something like
cache-key: play-published-local-jdk8-${{ github.sha }}-${{ github.event_name != 'schedule' || github.run_id }} | |
cache-key: play-published-local-jdk8-${{ github.sha }}-${{needs.extra-vars.outputs.akka_version_opts}}-${{needs.extra-vars.outputs.akka_http_version_opts}} |
For PR's it will be play-published-local-jdk8-55238a2b--
and for sheduler play-published-local-jdk8-55238a2b-2.6.19+52-00c1da99-SNAPSHOT-10.1.15+4-8e825ed4-SNAPSHOT
.
PS: But I like your variant and don't see a matter to change it. Only one moment, that we should understand that run_id
will not change if we will re-run failed shedule action. (https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables)
A unique number for each workflow run within a repository. This number does not change if you re-run the workflow run. For example, 1658821493.
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.
Only one moment, that we should understand that run_id will not change if we will re-run failed shedule action.
Yes, but the akka version might also not have changed when you re-run the workflow, so it's similiar (if not the same in most cases). Also, when a job fails the post hook to fill the cache will not run anyway, so this should not be a problem at all.
All checks passed 👍 |
The problem:
publishLocal
. Because we are using akka snapshots, the published Play version will be something like2.8.1+1638-55238a2b-SNAPSHOT-akka-2.6.19+52-00c1da99-SNAPSHOT-akka-http-10.1.15+4-8e825ed4-SNAPSHOT
. Artifacts will be cached withplay-published-local-jdk8-${{ github.sha }}
. (github.sha
is the commit from the Play repo)play-published-local-jdk8-${{ github.sha }}
The scheduled jobs finished, nothing changed (and nothing will be changing) in the Play repository. But, because the akka team isn't lazy, new commits get pushed to akka (or akka-http)! So the next nightly looks like this:
play-published-local-jdk8-${{ github.sha }}
publishLocal
. Because of the new akka snapshot version the published Play version will change to2.8.1+1638-55238a2b-SNAPSHOT-akka-2.6.19+58-af1e7560-SNAPSHOT-akka-http-10.1.15+4-8e825ed4-SNAPSHOT
. These artifacts will not be cached anymore since there was a cache hit forplay-published-local-jdk8-${{ github.sha }}
already, because the Play commit-sha did not change. Since the GHA cache is immutable, the cache will not be updated.play-published-local-jdk8-${{ github.sha }}
. Since the cache for thegithub.sha
id was not updated, the artifacts build with the new akka snapshot version is missing.