File tree Expand file tree Collapse file tree 6 files changed +185
-42
lines changed
Expand file tree Collapse file tree 6 files changed +185
-42
lines changed Original file line number Diff line number Diff line change 22
33const core = require ( '@actions/core' )
44
5- const { execSync } = require ( './common' )
5+ const { execSync, grpSt, grpEnd } = require ( './common' )
6+
7+ // group start time
8+ let msSt
69
710// clean inputs
811let apt = core . getInput ( 'apt-get' ) . replace ( / [ ^ a - z _ \d . - ] + / gi, '' ) . trim ( ) . toLowerCase ( )
@@ -16,28 +19,36 @@ export const run = async () => {
1619 let needUpgrade = true
1720
1821 if ( / \b _ u p d a t e _ \b / . test ( apt ) ) {
22+ msSt = grpSt ( 'apt-get update' )
1923 execSync ( `sudo apt-get ${ opts } -qy update` )
24+ grpEnd ( msSt )
2025 apt = apt . replace ( / \b _ u p d a t e _ \b / gi, '' ) . trim ( )
2126 needUpdate = false
2227 }
2328
2429 if ( / \b _ d i s t - u p g r a d e _ \b / . test ( apt ) ) {
30+ msSt = grpSt ( 'apt-get dist-upgrade' )
2531 if ( needUpdate ) { execSync ( 'sudo apt-get -qy update' ) }
2632 execSync ( `sudo apt-get ${ opts } -qy dist-upgrade` )
33+ grpEnd ( msSt )
2734 needUpgrade = false
2835 apt = apt . replace ( / \b _ d i s t - u p g r a d e _ \b / gi, '' ) . trim ( )
2936 }
3037
3138 if ( / \b _ u p g r a d e _ \b / . test ( apt ) ) {
3239 if ( needUpgrade ) {
40+ msSt = grpSt ( 'apt-get upgrade' )
3341 if ( needUpdate ) { execSync ( `sudo apt-get ${ opts } -qy update` ) }
3442 execSync ( `sudo apt-get ${ opts } -qy upgrade` )
43+ grpEnd ( msSt )
3544 }
3645 apt = apt . replace ( / \b _ u p g r a d e _ \b / gi, '' ) . trim ( )
3746 }
3847
3948 if ( apt !== '' ) {
49+ msSt = grpSt ( `apt-get ${ apt } ` )
4050 execSync ( `sudo apt-get ${ opts } -qy --no-install-recommends install ${ apt } ` )
51+ grpEnd ( msSt )
4152 }
4253 }
4354 } catch ( error ) {
Original file line number Diff line number Diff line change 22
33const core = require ( '@actions/core' )
44
5- const { execSync } = require ( './common' )
5+ const { execSync, grpSt, grpEnd } = require ( './common' )
6+
7+ // group start time
8+ let msSt
69
710// clean inputs
811let brew = core . getInput ( 'brew' ) . replace ( / [ ^ a - z _ \d . @ - ] + / gi, '' ) . trim ( ) . toLowerCase ( )
@@ -13,17 +16,26 @@ export const run = async () => {
1316 let needUpdate = true
1417
1518 if ( / \b _ u p d a t e _ \b / . test ( brew ) ) {
19+ msSt = grpSt ( 'brew update' )
1620 execSync ( 'brew update' )
21+ grpEnd ( msSt )
1722 needUpdate = false
1823 brew = brew . replace ( / \b _ u p d a t e _ \b / gi, '' ) . trim ( )
1924 }
2025
2126 if ( / \b _ u p g r a d e _ \b / . test ( brew ) ) {
27+ msSt = grpSt ( 'brew upgrade' )
2228 if ( needUpdate ) { execSync ( 'brew update' ) }
29+ execSync ( 'brew upgrade' )
30+ grpEnd ( msSt )
2331 brew = brew . replace ( / \b _ u p g r a d e _ \b / gi, '' ) . trim ( )
2432 }
2533
26- if ( brew !== '' ) { execSync ( `brew install ${ brew } ` ) }
34+ if ( brew !== '' ) {
35+ msSt = grpSt ( `brew install ${ brew } ` )
36+ execSync ( `brew install ${ brew } ` )
37+ grpEnd ( msSt )
38+ }
2739 }
2840 } catch ( error ) {
2941 core . setFailed ( error . message )
Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ const path = require('path')
66const core = require ( '@actions/core' )
77const httpc = require ( '@actions/http-client' )
88
9+ const { performance } = require ( 'perf_hooks' )
10+
11+ const yel = '\x1b[33m'
912const blu = '\x1b[94m' // eslint-disable-line no-unused-vars
10- const yel = '\x1b[33m' // eslint-disable-line no-unused-vars
11- const rst = '\x1b[0m' // eslint-disable-line no-unused-vars
13+ const rst = '\x1b[0m'
1214
1315export const download = async ( uri , dest ) => {
1416 // make sure the folder exists
@@ -75,4 +77,14 @@ export const execSyncQ = (cmd) => {
7577 console . log ( ' Done' )
7678}
7779
80+ export const grpSt = ( desc ) => {
81+ console . log ( `##[group]${ yel } ${ desc } ${ rst } ` )
82+ return performance . now ( )
83+ }
84+
85+ export const grpEnd = ( msSt ) => {
86+ const timeStr = ( ( performance . now ( ) - msSt ) / 1000 ) . toFixed ( 2 ) . padStart ( 6 )
87+ console . log ( `::[endgroup]\n time: ${ timeStr } s` )
88+ }
89+
7890export const getInput = ( name ) => core . getInput ( name ) . replace ( / [ ^ a - z _ \d . - ] + / gi, '' ) . trim ( ) . toLowerCase ( )
You can’t perform that action at this time.
0 commit comments