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

cache-read-only=true for scheduled workflows on main branch #383

Closed
kkolman opened this issue Aug 3, 2022 · 6 comments
Closed

cache-read-only=true for scheduled workflows on main branch #383

kkolman opened this issue Aug 3, 2022 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@kkolman
Copy link

kkolman commented Aug 3, 2022

The default expression for cache-read-only value is:

${{ github.ref_name != github.event.repository.default_branch }}

But github.event.repository.default_branch is not set by GA on scheduled (cron) workflow runs.
Hence cache-read-only is resolved to true not writing to cache during scheduled runs on the main branch.
For CI configrations where workflows on main line are run via scheduling exclusively (no manual workflow runs happening) cache will never be written to.

I believe this behavior is worth documenting.

Unless there's a solid replacement to github.event.repository.default_branch for obtaining the default branch name (didnt find one in ga contexts).

@AndrzejPw
Copy link

@kkolman you are right - that's why I changed value of cache-read-only to:
${{ github.ref != 'refs/heads/develop' }}

And now scheduled runs at least try to write cache. The problem is they are failing with following error:
Save Gradle User Home failed in 'beforeSave': Error: ENOENT: no such file or directory, lstat '/Users/runner/.gradle/caches/7.4.2/kotlin-dsl/scripts/290aeeb3033fad5386fbca5f7db24fe3'

I think it may be related to scheduled workflow runs because when I tested action triggered by PR cache was written successfully.

@bigdaz
Copy link
Member

bigdaz commented Aug 16, 2022

Thanks for the reports. I think we should be able to detect when we are running with a scheduled trigger and avoid setting cache-read-only in this case.

However, I'm having trouble getting a scheduled workflow to execute: I added a ci-schedule.yml workflow and can run it manually via workflow_dispatch, but it never seems to run via the cron trigger. https://github.com/gradle/gradle-build-action/actions/workflows/ci-schedule.yml

Any ideas?

@AndrzejPw
Copy link

@bigdaz I see now it is being scheduled :). However, my error with Save Gradle User Home failed in 'beforeSave': Error: ENOENT: no such file or directory, lstat '/Users/runner/.gradle/caches/7.4.2/kotlin-dsl/scripts/290aeeb3033fad5386fbca5f7db24fe3 is not related with scheduled runs. I tested it again and now I have this error everytime cache-read-only is false.

@bigdaz
Copy link
Member

bigdaz commented Aug 16, 2022

@AndrzejPw Can you please raise a separate issue for your problem, since it appears unrelated to this reported issue? If you can provide a link to a failing build that would be great, otherwise the full stack trace would help.

@bigdaz bigdaz closed this as completed in e4e8267 Aug 16, 2022
@bigdaz bigdaz added this to the v2.2.3 milestone Aug 16, 2022
@bigdaz bigdaz added the bug Something isn't working label Aug 16, 2022
@AndrzejPw
Copy link

AndrzejPw commented Aug 18, 2022

Thank you - my bug with Save Gradle User Home does not appear anymore (maybe sth was wrong with github environment). If it happens again I will report it.

bigdaz added a commit that referenced this issue Aug 18, 2022
The fix for #383 introduced a bug that caused the post-action to fail when
attemping to resolve `cache-read-only` for scheduled jobs.
This has been fixed with an explicit (rather than implicit) check for 'event.repository != null'.

Fixes #409
@bigdaz
Copy link
Member

bigdaz commented Aug 18, 2022

@AndrzejPw FYI there was another report of the ENOENT: no such file or directory from an internal project that allowed me to reproduce, diagnose and fix this issue: #408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants