mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 14:26:19 +08:00
Merge pull request #282 from gradle/dd/summary
Use GHA Job Summary to summarize Gradle build results
This commit is contained in:
commit
c21b4ec861
12
.github/workflows/failure-cases.yml
vendored
12
.github/workflows/failure-cases.yml
vendored
@ -8,6 +8,18 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
failing-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Test build failure
|
||||||
|
uses: ./
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||||
|
arguments: not-a-valid-task
|
||||||
|
|
||||||
wrapper-missing:
|
wrapper-missing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
16
dist/main/index.js
vendored
16
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -264,22 +264,20 @@ if (isTopLevelBuild) {
|
|||||||
|
|
||||||
def registerCallbacks(buildScanExtension, rootProjectName) {
|
def registerCallbacks(buildScanExtension, rootProjectName) {
|
||||||
buildScanExtension.with {
|
buildScanExtension.with {
|
||||||
def scanFile = new File("gradle-build-scan.txt")
|
|
||||||
def buildFailed = false
|
def buildFailed = false
|
||||||
|
|
||||||
buildFinished { result ->
|
buildFinished { result ->
|
||||||
buildFailed = (result.failure != null)
|
buildFailed = (result.failure != null)
|
||||||
}
|
}
|
||||||
|
|
||||||
buildScanPublished { buildScan ->
|
buildScanPublished { buildScan ->
|
||||||
scanFile.text = buildScan.buildScanUri
|
|
||||||
|
|
||||||
// Send commands directly to GitHub Actions via STDOUT.
|
// Send commands directly to GitHub Actions via STDOUT.
|
||||||
def gradleCommand = rootProjectName + " " + gradle.startParameter.taskNames.join(" ")
|
def gradleCommand = rootProjectName + " " + gradle.startParameter.taskNames.join(" ")
|
||||||
|
|
||||||
|
def githubSummaryFile = new File(System.getenv("GITHUB_STEP_SUMMARY"))
|
||||||
if (buildFailed) {
|
if (buildFailed) {
|
||||||
println("::warning ::Gradle build '\${gradleCommand}' FAILED - \${buildScan.buildScanUri}")
|
githubSummaryFile << "❌ Gradle Build \`\${gradleCommand}\` [![Gradle Enterprise Build Scan](https://img.shields.io/badge/Gradle%20Enterprise%20Build%20Scan%E2%84%A2-FAILED-red?logo=Gradle)](\${buildScan.buildScanUri})"
|
||||||
} else {
|
} else {
|
||||||
println("::notice ::Gradle build '\${gradleCommand}' - \${buildScan.buildScanUri}")
|
githubSummaryFile << "✅ Gradle Build \`\${gradleCommand}\` [![Gradle Enterprise Build Scan](https://img.shields.io/badge/Gradle%20Enterprise%20Build%20Scan%E2%84%A2-SUCCESS-brightgreen?logo=Gradle)](\${buildScan.buildScanUri})"
|
||||||
}
|
}
|
||||||
println("::set-output name=build-scan-url::\${buildScan.buildScanUri}")
|
println("::set-output name=build-scan-url::\${buildScan.buildScanUri}")
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
|
||||||
import * as gradlew from './gradlew'
|
import * as gradlew from './gradlew'
|
||||||
|
|
||||||
export async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> {
|
export async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> {
|
||||||
let buildScanUrl: string | undefined
|
|
||||||
|
|
||||||
const buildScanFile = path.resolve(root, 'gradle-build-scan.txt')
|
|
||||||
if (fs.existsSync(buildScanFile)) {
|
|
||||||
fs.unlinkSync(buildScanFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the provided executable, or look for a Gradle wrapper script to run
|
// Use the provided executable, or look for a Gradle wrapper script to run
|
||||||
const toExecute = executable ?? gradlew.locateGradleWrapperScript(root)
|
const toExecute = executable ?? gradlew.locateGradleWrapperScript(root)
|
||||||
verifyIsExecutableScript(toExecute)
|
verifyIsExecutableScript(toExecute)
|
||||||
@ -20,16 +12,8 @@ export async function executeGradleBuild(executable: string | undefined, root: s
|
|||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
})
|
})
|
||||||
|
|
||||||
if (fs.existsSync(buildScanFile)) {
|
|
||||||
buildScanUrl = fs.readFileSync(buildScanFile, 'utf-8')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status !== 0) {
|
if (status !== 0) {
|
||||||
if (buildScanUrl) {
|
core.setFailed(`Gradle build failed: see console output for details`)
|
||||||
core.setFailed(`Gradle build failed: ${buildScanUrl}`)
|
|
||||||
} else {
|
|
||||||
core.setFailed(`Gradle build failed: process exited with status ${status}`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user