mirror of https://github.com/vuejs/core.git
workflow: check ci status during release
This commit is contained in:
parent
a0a010ddc9
commit
b472965eba
|
@ -15,7 +15,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
const args = minimist(process.argv.slice(2))
|
const args = minimist(process.argv.slice(2))
|
||||||
const preId = args.preid || semver.prerelease(currentVersion)?.[0]
|
const preId = args.preid || semver.prerelease(currentVersion)?.[0]
|
||||||
const isDryRun = args.dry
|
const isDryRun = args.dry
|
||||||
const skipTests = args.skipTests
|
let skipTests = args.skipTests
|
||||||
const skipBuild = args.skipBuild
|
const skipBuild = args.skipBuild
|
||||||
const packages = fs
|
const packages = fs
|
||||||
.readdirSync(path.resolve(__dirname, '../packages'))
|
.readdirSync(path.resolve(__dirname, '../packages'))
|
||||||
|
@ -31,7 +31,6 @@ const versionIncrements = [
|
||||||
]
|
]
|
||||||
|
|
||||||
const inc = i => semver.inc(currentVersion, i, preId)
|
const inc = i => semver.inc(currentVersion, i, preId)
|
||||||
const bin = name => path.resolve(__dirname, '../node_modules/.bin/' + name)
|
|
||||||
const run = (bin, args, opts = {}) =>
|
const run = (bin, args, opts = {}) =>
|
||||||
execa(bin, args, { stdio: 'inherit', ...opts })
|
execa(bin, args, { stdio: 'inherit', ...opts })
|
||||||
const dryRun = (bin, args, opts = {}) =>
|
const dryRun = (bin, args, opts = {}) =>
|
||||||
|
@ -72,23 +71,52 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { yes } = await prompt({
|
const { yes: confirmRelease } = await prompt({
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'yes',
|
name: 'yes',
|
||||||
message: `Releasing v${targetVersion}. Confirm?`
|
message: `Releasing v${targetVersion}. Confirm?`
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!yes) {
|
if (!confirmRelease) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// run tests before release
|
step('Checking CI status for HEAD...')
|
||||||
|
let isCIPassed = true
|
||||||
|
try {
|
||||||
|
const { stdout: sha } = await execa('git', ['rev-parse', 'HEAD'])
|
||||||
|
const res = await fetch(
|
||||||
|
`https://api.github.com/repos/vuejs/core/actions/runs?head_sha=${sha}` +
|
||||||
|
`&status=success&exclude_pull_requests=true`
|
||||||
|
)
|
||||||
|
const data = await res.json()
|
||||||
|
isCIPassed = data.workflow_runs.length > 0
|
||||||
|
} catch (e) {
|
||||||
|
isCIPassed = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCIPassed) {
|
||||||
|
// @ts-ignore
|
||||||
|
const { yes: promptSkipTests } = await prompt({
|
||||||
|
type: 'confirm',
|
||||||
|
name: 'yes',
|
||||||
|
message: `CI for this commit passed. Skip local tests?`
|
||||||
|
})
|
||||||
|
if (promptSkipTests) {
|
||||||
|
skipTests = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!skipTests) {
|
||||||
step('\nRunning tests...')
|
step('\nRunning tests...')
|
||||||
if (!skipTests && !isDryRun) {
|
if (!isDryRun) {
|
||||||
await run(bin('jest'), ['--clearCache'])
|
await run('pnpm', ['test'])
|
||||||
await run('pnpm', ['test', '--bail'])
|
await run('pnpm', ['test-dts'])
|
||||||
} else {
|
} else {
|
||||||
console.log(`(skipped)`)
|
console.log(`Skipped (dry run)`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
step('Tests skipped.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// update all package versions and inter-dependencies
|
// update all package versions and inter-dependencies
|
||||||
|
|
Loading…
Reference in New Issue