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