Adapt for new structure of build results

This commit is contained in:
daz 2024-07-18 15:22:38 -06:00
parent 579a013225
commit 54f7dc55a5
No known key found for this signature in database
2 changed files with 22 additions and 2 deletions

View File

@ -8,6 +8,7 @@ export interface BuildResult {
get gradleVersion(): string get gradleVersion(): string
get gradleHomeDir(): string get gradleHomeDir(): string
get buildFailed(): boolean get buildFailed(): boolean
get configCacheHit(): boolean
get buildScanUri(): string get buildScanUri(): string
get buildScanFailed(): boolean get buildScanFailed(): boolean
} }
@ -32,7 +33,9 @@ export class BuildResults {
export function loadBuildResults(): BuildResults { export function loadBuildResults(): BuildResults {
const results = getUnprocessedResults().map(filePath => { const results = getUnprocessedResults().map(filePath => {
const content = fs.readFileSync(filePath, 'utf8') const content = fs.readFileSync(filePath, 'utf8')
return JSON.parse(content) as BuildResult const buildResult = JSON.parse(content) as BuildResult
addScanResults(filePath, buildResult)
return buildResult
}) })
return new BuildResults(results) return new BuildResults(results)
} }
@ -42,7 +45,7 @@ export function markBuildResultsProcessed(): void {
} }
function getUnprocessedResults(): string[] { function getUnprocessedResults(): string[] {
const buildResultsDir = path.resolve(process.env['RUNNER_TEMP']!, '.build-results') const buildResultsDir = path.resolve(process.env['RUNNER_TEMP']!, '.gradle-actions', 'build-results')
if (!fs.existsSync(buildResultsDir)) { if (!fs.existsSync(buildResultsDir)) {
return [] return []
} }
@ -57,6 +60,22 @@ function getUnprocessedResults(): string[] {
}) })
} }
function addScanResults(buildResultsFile: string, buildResult: BuildResult): void {
const buildScansDir = path.resolve(process.env['RUNNER_TEMP']!, '.gradle-actions', 'build-scans')
if (!fs.existsSync(buildScansDir)) {
return
}
const buildScanResults = path.resolve(buildScansDir, path.basename(buildResultsFile))
if (fs.existsSync(buildScanResults)) {
const content = fs.readFileSync(buildScanResults, 'utf8')
const scanResults = JSON.parse(content)
Object.assign(buildResult, scanResults)
}
return
}
function isProcessed(resultFile: string): boolean { function isProcessed(resultFile: string): boolean {
const markerFile = `${resultFile}.processed` const markerFile = `${resultFile}.processed`
return fs.existsSync(markerFile) return fs.existsSync(markerFile)

View File

@ -10,6 +10,7 @@ const successfulHelpBuild: BuildResult = {
gradleVersion: '8.0', gradleVersion: '8.0',
gradleHomeDir: '/opt/gradle', gradleHomeDir: '/opt/gradle',
buildFailed: false, buildFailed: false,
configCacheHit: false,
buildScanUri: 'https://scans.gradle.com/s/abc123', buildScanUri: 'https://scans.gradle.com/s/abc123',
buildScanFailed: false buildScanFailed: false
} }