@@ -15,7 +15,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
1515const args = minimist ( process . argv . slice ( 2 ) )
1616const preId = args . preid || semver . prerelease ( currentVersion ) ?. [ 0 ]
1717const isDryRun = args . dry
18- const skipTests = args . skipTests
18+ let skipTests = args . skipTests
1919const skipBuild = args . skipBuild
2020const packages = fs
2121 . readdirSync ( path . resolve ( __dirname , '../packages' ) )
@@ -31,7 +31,6 @@ const versionIncrements = [
3131]
3232
3333const inc = i => semver . inc ( currentVersion , i , preId )
34- const bin = name => path . resolve ( __dirname , '../node_modules/.bin/' + name )
3534const run = ( bin , args , opts = { } ) =>
3635 execa ( bin , args , { stdio : 'inherit' , ...opts } )
3736const dryRun = ( bin , args , opts = { } ) =>
@@ -72,23 +71,52 @@ async function main() {
7271 }
7372
7473 // @ts -ignore
75- const { yes } = await prompt ( {
74+ const { yes : confirmRelease } = await prompt ( {
7675 type : 'confirm' ,
7776 name : 'yes' ,
7877 message : `Releasing v${ targetVersion } . Confirm?`
7978 } )
8079
81- if ( ! yes ) {
80+ if ( ! confirmRelease ) {
8281 return
8382 }
8483
85- // run tests before release
86- step ( '\nRunning tests...' )
87- if ( ! skipTests && ! isDryRun ) {
88- await run ( bin ( 'jest' ) , [ '--clearCache' ] )
89- await run ( 'pnpm' , [ 'test' , '--bail' ] )
84+ step ( 'Checking CI status for HEAD...' )
85+ let isCIPassed = true
86+ try {
87+ const { stdout : sha } = await execa ( 'git' , [ 'rev-parse' , 'HEAD' ] )
88+ const res = await fetch (
89+ `https://api.github.com/repos/vuejs/core/actions/runs?head_sha=${ sha } ` +
90+ `&status=success&exclude_pull_requests=true`
91+ )
92+ const data = await res . json ( )
93+ isCIPassed = data . workflow_runs . length > 0
94+ } catch ( e ) {
95+ isCIPassed = false
96+ }
97+
98+ if ( isCIPassed ) {
99+ // @ts -ignore
100+ const { yes : promptSkipTests } = await prompt ( {
101+ type : 'confirm' ,
102+ name : 'yes' ,
103+ message : `CI for this commit passed. Skip local tests?`
104+ } )
105+ if ( promptSkipTests ) {
106+ skipTests = true
107+ }
108+ }
109+
110+ if ( ! skipTests ) {
111+ step ( '\nRunning tests...' )
112+ if ( ! isDryRun ) {
113+ await run ( 'pnpm' , [ 'test' ] )
114+ await run ( 'pnpm' , [ 'test-dts' ] )
115+ } else {
116+ console . log ( `Skipped (dry run)` )
117+ }
90118 } else {
91- console . log ( `( skipped)` )
119+ step ( 'Tests skipped.' )
92120 }
93121
94122 // update all package versions and inter-dependencies
0 commit comments