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

Unable to find environment variable for $GITHUB_STEP_SUMMARY #319

Closed
tglaeser opened this issue Jun 8, 2022 · 10 comments · Fixed by #321
Closed

Unable to find environment variable for $GITHUB_STEP_SUMMARY #319

tglaeser opened this issue Jun 8, 2022 · 10 comments · Fixed by #321
Assignees
Labels
bug Something isn't working
Milestone

Comments

@tglaeser
Copy link

tglaeser commented Jun 8, 2022

After upgrading to version 2.2.0 the very last Gradle step of a job logs warning

Unhandled error in Gradle post-action - job will continue: Error: Unable to find environment variable for $GITHUB_STEP_SUMMARY. Check if your runtime environment supports job summaries.

With our CI job the first Gradle step executed is gradle clean and the output from the corresponding Post step is

Post job cleanup.
Stopping all Gradle daemons
Stopping Gradle daemons in /home/xxx/.gradle/wrapper/dists/gradle-7.4.2-bin/48ivgl02cpt2ed3fh9dbalvx8/gradle-7.4.2
/home/xxx/.gradle/wrapper/dists/gradle-7.4.2-bin/48ivgl02cpt2ed3fh9dbalvx8/gradle-7.4.2/bin/gradle --stop
No Gradle daemons are running.
In final post-action step, saving state and writing summary
Cache will not be saved: not restored in main action step.
Writing job summary
Warning: Unhandled error in Gradle post-action - job will continue: Error: Unable to find environment variable for $GITHUB_STEP_SUMMARY. Check if your runtime environment supports job summaries.
Error: Unable to find environment variable for $GITHUB_STEP_SUMMARY. Check if your runtime environment supports job summaries.
    at Summary.<anonymous> (/opt/actions-runner/_work/_actions/gradle/gradle-build-action/v2/dist/webpack:/gradle-build-action/node_modules/@actions/core/lib/summary.js:35:1)
    at Generator.next (<anonymous>)
    at /opt/actions-runner/_work/_actions/gradle/gradle-build-action/v2/dist/webpack:/gradle-build-action/node_modules/@actions/core/lib/summary.js:8:1
    at new Promise (<anonymous>)
    at __webpack_modules__.1327.__awaiter (/opt/actions-runner/_work/_actions/gradle/gradle-build-action/v2/dist/webpack:/gradle-build-action/node_modules/@actions/core/lib/summary.js:4:1)
    at Summary.filePath (/opt/actions-runner/_work/_actions/gradle/gradle-build-action/v2/dist/webpack:/gradle-build-action/node_modules/@actions/core/lib/summary.js:29:1)
    at Summary.<anonymous> (/opt/actions-runner/_work/_actions/gradle/gradle-build-action/v2/dist/webpack:/gradle-build-action/node_modules/@actions/core/lib/summary.js:75:1)
    at Generator.next (<anonymous>)
    at /opt/actions-runner/_work/_actions/gradle/gradle-build-action/v2/dist/webpack:/gradle-build-action/node_modules/@actions/core/lib/summary.js:8:1
    at new Promise (<anonymous>)

The warning was not logged with previous version 2.1.7.

@bigdaz
Copy link
Member

bigdaz commented Jun 8, 2022

Thanks for the report @tglaeser. Are you running actions on github.com, GitHub Enterprise, or some other platform?

This exception is being triggered by a call to a function in @actions/core:

If you're running using act, then see here for a workaround: nektos/act#1187

I presume you can workaround this issue by setting generate-job-summary: false in your action params: https://github.com/gradle/gradle-build-action/blob/main/action.yml#L56.

If you'd like to submit a PR to fix this, it would involve checking for the presence of GITHUB_STEP_SUMMARY environment variable and skipping the summary generation if it's not found.

@tglaeser
Copy link
Author

tglaeser commented Jun 8, 2022

We are using GitHub Enterprise. I suppose I could set generate-job-summary to false.

The wired thing though is, while our job consists of several steps using gradle/gradle-build-action,this is logged only for the Post step of the very first Gradle step.

@bigdaz
Copy link
Member

bigdaz commented Jun 9, 2022

Thanks again for the report. I'll try to find time to add a check for GITHUB_STEP_SUMMARY before attempting to write the summary. This will have the same effect as setting generate-job-summary: false.

We are using GitHub Enterprise. I suppose I could set generate-job-summary to false.

I'm surprised that GitHub released this new feature for github.com and not for GitHub Enterprise. Is there a newer version that might provide support?

The wired thing though is, while our job consists of several steps using gradle/gradle-build-action,this is logged only for the Post step of the very first Gradle step.

This is expected: we only generate a Job Summary in the post action of the first gradle-build-action step. For other steps you'll see a log message like this.

@tglaeser
Copy link
Author

tglaeser commented Jun 9, 2022

We are using GitHub Enterprise. I suppose I could set generate-job-summary to false.

I'm surprised that GitHub released this new feature for github.com and not for GitHub Enterprise. Is there a newer version that might provide support?

Yeah, GH Enterprise often lags behind the public GH features; go figure. We are currently on version 3.4.3, upgrading to a later version might help but is beyond our control.

@bigdaz bigdaz added the bug Something isn't working label Jun 9, 2022
@bigdaz bigdaz self-assigned this Jun 9, 2022
bigdaz added a commit that referenced this issue Jun 9, 2022
@bigdaz bigdaz added this to the v2.2.1 milestone Jun 9, 2022
@bigdaz
Copy link
Member

bigdaz commented Jun 9, 2022

I'll try to find time to add a check for GITHUB_STEP_SUMMARY before attempting to write the summary.

This is on the main branch and will be part of an upcoming patch release.

@bigdaz
Copy link
Member

bigdaz commented Jun 21, 2022

@tglaeser Could you please try the latest main release in your GitHub Enterprise environment?
I've pushed a few changes that should make the action function better on GitHub Enterprise.

  • Disable cache when feature is unavailable (introduced in GHES 3.5)
  • Write Job Summary to logs when feature is unavailable (not yet in GHES)

You should see a build result summary in your logs something like this: https://github.com/gradle/gradle-build-action/runs/6975943266?check_suite_focus=true#step:19:12

If you can confirm this is working for you, I'll release this as v2.2.2.

@tglaeser
Copy link
Author

Thanks. We are still on version 3.4.3 but will soon upgrade to version 3.5.1.

I tested with gradle/gradle-build-action@v2.2.1 and the above reported issues does not manifest itself anymore.

If after upgrading GHES an issues surfaces again, I'll report back again. Thanks.

@bigdaz
Copy link
Member

bigdaz commented Jun 21, 2022

Thanks. There are 2 improvements currently on the main branch that haven't been released:

  • Job Summary content written to the logs so build scan links are still available. (The same behaviour can be seen by setting generate-job-summary: false).
  • We detect when the GitHub Actions cache is unavailable and report this.

It would be great to have this verified on GHES 3.4.3, but I'm pretty confident it will work. To test this you'd just use gradle/gradle-build-action@main for the workflow.

@tglaeser
Copy link
Author

Running with gradle/gradle-build-action@main on GHES version 3.4.3 produced the following post job logging. Is that what you were looking for?

2022-06-23T18:33:53.3743340Z Post job cleanup.
2022-06-23T18:33:53.5714761Z Gradle setup post-action only performed for first gradle-build-action step in workflow.
2022-06-23T18:33:53.5885589Z Post job cleanup.
2022-06-23T18:33:53.7924030Z Gradle setup post-action only performed for first gradle-build-action step in workflow.
2022-06-23T18:33:53.8136505Z Post job cleanup.
2022-06-23T18:33:54.0134880Z Gradle setup post-action only performed for first gradle-build-action step in workflow.
2022-06-23T18:33:54.0351320Z Post job cleanup.
2022-06-23T18:33:54.2479509Z Gradle setup post-action only performed for first gradle-build-action step in workflow.
2022-06-23T18:33:54.2698225Z Post job cleanup.
2022-06-23T18:33:54.4702962Z In final post-action step, saving state and writing summary
2022-06-23T18:33:54.4714783Z Cache is disabled: will not save state for later builds.
2022-06-23T18:33:54.4720836Z ============================
2022-06-23T18:33:54.4722020Z Gradle Builds
2022-06-23T18:33:54.4723939Z ----------------------------
2022-06-23T18:33:54.4726446Z Root Project | Requested Tasks | Gradle Version | Build Outcome | Build Scan™
2022-06-23T18:33:54.4728951Z ----------------------------
2022-06-23T18:33:54.4731067Z foo-bar | clean | 7.4.2 | SUCCESS | null
2022-06-23T18:33:54.4733703Z foo-bar | assemble dependencyReport | 7.4.2 | SUCCESS | null
2022-06-23T18:33:54.4736297Z foo-bar | check | 7.4.2 | SUCCESS | null
2022-06-23T18:33:54.4739387Z foo-bar | testWebApplicationHeadless | 7.4.2 | SUCCESS | null
2022-06-23T18:33:54.4742683Z foo-bar | setup integrationTest cleanup | 7.4.2 | SUCCESS | null
2022-06-23T18:33:54.4744845Z ============================
2022-06-23T18:33:54.4749870Z ##[group]Caching for gradle-build-action was not available - expand for details
2022-06-23T18:33:54.4752076Z Entries Restored: 0 (0 Mb)
2022-06-23T18:33:54.4753451Z Entries Saved   : 0 (0 Mb)
2022-06-23T18:33:54.4754836Z Cache Entry Details
2022-06-23T18:33:54.4755692Z 
2022-06-23T18:33:54.4758435Z ##[endgroup]
2022-06-23T18:33:54.4959907Z Post job cleanup.
2022-06-23T18:33:54.7214918Z Post job cleanup.
2022-06-23T18:33:54.8741123Z Cleaning up orphan processes

@bigdaz
Copy link
Member

bigdaz commented Jun 24, 2022

Yes, thanks for verifying. If you had build scans enabled, then the build scan links should appear as well.
When you upgrade to GHES 3.5 you should start to see Gradle User Home caching, and this will also be reported.

I think this is an adequate fallback for GHES until the Job Summary functionality is available.

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

Successfully merging a pull request may close this issue.

2 participants