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

Fix the GitHub actions cron job #11256

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Copy link
Member Author

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 😉

Copy link
Member

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

Suggested change
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.

Copy link
Member Author

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.


publish-local-jdk11:
name: Publish Local
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
scripted play-sbt-plugin/*1of3
"
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 }}

scripted-tests-2:
name: Scripted Tests (2 of 3)
Expand All @@ -199,7 +199,7 @@ jobs:
scripted play-sbt-plugin/*2of3
"
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 }}

scripted-tests-3:
name: Scripted Tests (3 of 3)
Expand All @@ -220,7 +220,7 @@ jobs:
scripted play-sbt-plugin/*3of3
"
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 }}

finish:
name: Finish
Expand Down