Unverified Commit 63bcd47c authored by Daz DeBoer's avatar Daz DeBoer
Browse files

Allow Job Summary generation to be disabled

parent 306a7e4b
Loading
Loading
Loading
Loading
+5 −2
Changes for action.yml: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ inputs:
      By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches.
    required: false
    default: ${{ github.ref_name != github.event.repository.default_branch }}
  # e.g. Use the following setting to only write cache entries from your 'main' branch
  #     cache-read-only: ${{ github.ref_name != 'main' }}

  cache-write-only:
    description: |
@@ -55,6 +53,11 @@ inputs:
    description: Path to the Gradle executable
    required: false

  generate-job-summary:
    description: When 'false', no Job Summary will be generated for the Job.
    required: false
    default: true

  # EXPERIMENTAL & INTERNAL ACTION INPUTS
  # The following action properties allow fine-grained tweaking of the action caching behaviour.
  # These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
+7 −1
Changes for src/setup-gradle.ts: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -11,6 +11,11 @@ import {BuildResult, loadBuildResults, writeJobSummary} from './job-summary'
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
const CACHE_LISTENER = 'CACHE_LISTENER'
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'

function generateJobSummary(): boolean {
    return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER)
}

export async function setup(buildRootDirectory: string): Promise<void> {
    const gradleUserHome = await determineGradleUserHome(buildRootDirectory)
@@ -35,7 +40,6 @@ export async function setup(buildRootDirectory: string): Promise<void> {
}

export async function complete(): Promise<void> {
    core.info('Inside setupGradle.complete()')
    if (!core.getState(GRADLE_SETUP_VAR)) {
        core.info('Gradle setup post-action only performed for first gradle-build-action step in workflow.')
        return
@@ -52,8 +56,10 @@ export async function complete(): Promise<void> {
    const gradleUserHome = core.getState(GRADLE_USER_HOME)
    await caches.save(gradleUserHome, cacheListener)

    if (generateJobSummary()) {
        writeJobSummary(buildResults, cacheListener)
    }
}

async function determineGradleUserHome(rootDir: string): Promise<string> {
    const customGradleUserHome = process.env['GRADLE_USER_HOME']