2020-06-13 07:44:30 -04:00
|
|
|
import * as exec from '@actions/exec'
|
2020-06-15 06:59:55 -04:00
|
|
|
import * as cacheDependencies from './cache-dependencies'
|
2020-06-15 09:58:20 -04:00
|
|
|
import * as cacheConfiguration from './cache-configuration'
|
2019-09-21 10:01:53 -04:00
|
|
|
|
2020-06-13 07:44:30 -04:00
|
|
|
export async function execute(
|
|
|
|
executable: string,
|
|
|
|
root: string,
|
|
|
|
argv: string[]
|
|
|
|
): Promise<BuildResult> {
|
2020-06-15 06:59:55 -04:00
|
|
|
await cacheDependencies.restoreCachedDependencies(root)
|
2020-06-15 09:58:20 -04:00
|
|
|
await cacheConfiguration.restoreCachedConfiguration(root)
|
2020-06-15 06:59:55 -04:00
|
|
|
|
2020-06-13 07:44:30 -04:00
|
|
|
let publishing = false
|
|
|
|
let buildScanUrl: string | undefined
|
2019-09-21 10:01:53 -04:00
|
|
|
|
2019-09-23 06:11:18 -04:00
|
|
|
const status: number = await exec.exec(executable, argv, {
|
2019-09-21 10:01:53 -04:00
|
|
|
cwd: root,
|
2019-09-23 06:11:18 -04:00
|
|
|
ignoreReturnCode: true,
|
2019-09-21 10:01:53 -04:00
|
|
|
listeners: {
|
|
|
|
stdline: (line: string) => {
|
2020-06-13 07:44:30 -04:00
|
|
|
if (line.startsWith('Publishing build scan...')) {
|
|
|
|
publishing = true
|
2019-09-21 10:01:53 -04:00
|
|
|
}
|
2020-06-13 07:54:27 -04:00
|
|
|
if (publishing && line.length === 0) {
|
2019-09-21 10:01:53 -04:00
|
|
|
publishing = false
|
|
|
|
}
|
2020-06-13 07:44:30 -04:00
|
|
|
if (publishing && line.startsWith('http')) {
|
|
|
|
buildScanUrl = line.trim()
|
2019-09-21 10:01:53 -04:00
|
|
|
publishing = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-13 07:44:30 -04:00
|
|
|
})
|
2019-09-21 10:01:53 -04:00
|
|
|
|
2020-06-13 07:44:30 -04:00
|
|
|
return new BuildResultImpl(status, buildScanUrl)
|
2019-09-21 10:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface BuildResult {
|
2019-09-23 06:11:18 -04:00
|
|
|
readonly status: number
|
|
|
|
readonly buildScanUrl?: string
|
2019-09-21 10:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class BuildResultImpl implements BuildResult {
|
2020-06-13 07:44:30 -04:00
|
|
|
constructor(readonly status: number, readonly buildScanUrl?: string) {}
|
2019-09-21 10:01:53 -04:00
|
|
|
}
|