@@ -1983,92 +1983,92 @@ module.exports = require("child_process");
1983
1983
/***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
1984
1984
1985
1985
"use strict" ;
1986
-
1987
- var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
1988
- if ( k2 === undefined ) k2 = k ;
1989
- Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
1990
- } ) : ( function ( o , m , k , k2 ) {
1991
- if ( k2 === undefined ) k2 = k ;
1992
- o [ k2 ] = m [ k ] ;
1993
- } ) ) ;
1994
- var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
1995
- Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
1996
- } ) : function ( o , v ) {
1997
- o [ "default" ] = v ;
1998
- } ) ;
1999
- var __importStar = ( this && this . __importStar ) || function ( mod ) {
2000
- if ( mod && mod . __esModule ) return mod ;
2001
- var result = { } ;
2002
- if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
2003
- __setModuleDefault ( result , mod ) ;
2004
- return result ;
2005
- } ;
2006
- var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
2007
- function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
2008
- return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
2009
- function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
2010
- function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
2011
- function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
2012
- step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
2013
- } ) ;
2014
- } ;
2015
- var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
2016
- return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
2017
- } ;
2018
- Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
2019
- const core = __importStar ( __webpack_require__ ( 470 ) ) ;
2020
- const github = __importStar ( __webpack_require__ ( 469 ) ) ;
2021
- const child_process_1 = __webpack_require__ ( 129 ) ;
2022
- const fs_1 = __importDefault ( __webpack_require__ ( 747 ) ) ;
2023
- const DiffChecker_1 = __webpack_require__ ( 563 ) ;
2024
- function run ( ) {
2025
- var _a , _b ;
2026
- return __awaiter ( this , void 0 , void 0 , function * ( ) {
2027
- try {
2028
- const repoName = github . context . repo . repo ;
2029
- const repoOwner = github . context . repo . owner ;
2030
- const githubToken = core . getInput ( 'accessToken' ) ;
2031
- const fullCoverage = JSON . parse ( core . getInput ( 'fullCoverageDiff' ) ) ;
2032
- const commandToRun = 'npx jest --coverage --coverageReporters="json-summary" --coverageDirectory="./"' ;
2033
- const githubClient = github . getOctokit ( githubToken ) ;
2034
- const prNumber = github . context . issue . number ;
2035
- const branchNameBase = ( _a = github . context . payload . pull_request ) === null || _a === void 0 ? void 0 : _a . base . ref ;
2036
- const branchNameHead = ( _b = github . context . payload . pull_request ) === null || _b === void 0 ? void 0 : _b . head . ref ;
2037
- child_process_1 . execSync ( commandToRun ) ;
2038
- const codeCoverageNew = ( JSON . parse ( fs_1 . default . readFileSync ( 'coverage-summary.json' ) . toString ( ) ) ) ;
2039
- child_process_1 . execSync ( '/usr/bin/git fetch' ) ;
2040
- child_process_1 . execSync ( '/usr/bin/git stash' ) ;
2041
- child_process_1 . execSync ( `/usr/bin/git checkout --progress --force ${ branchNameBase } ` ) ;
2042
- child_process_1 . execSync ( commandToRun ) ;
2043
- const codeCoverageOld = ( JSON . parse ( fs_1 . default . readFileSync ( 'coverage-summary.json' ) . toString ( ) ) ) ;
2044
- const currentDirectory = child_process_1 . execSync ( 'pwd' )
2045
- . toString ( )
2046
- . trim ( ) ;
2047
- const diffChecker = new DiffChecker_1 . DiffChecker ( codeCoverageNew , codeCoverageOld ) ;
2048
- let messageToPost = `Code coverage diff between base branch:${ branchNameBase } and head branch: ${ branchNameHead } \n` ;
2049
- const coverageDetails = diffChecker . getCoverageDetails ( ! fullCoverage , `${ currentDirectory } /` ) ;
2050
- if ( coverageDetails . length === 0 ) {
2051
- messageToPost =
2052
- 'No changes to code coverage between the base branch and the head branch' ;
2053
- }
2054
- else {
2055
- messageToPost +=
2056
- 'File | % Stmts | % Branch | % Funcs | % Lines \n -----|---------|----------|---------|------ \n' ;
2057
- messageToPost += coverageDetails . join ( '\n' ) ;
2058
- }
2059
- yield githubClient . issues . createComment ( {
2060
- repo : repoName ,
2061
- owner : repoOwner ,
2062
- body : messageToPost ,
2063
- issue_number : prNumber
2064
- } ) ;
2065
- }
2066
- catch ( error ) {
2067
- core . setFailed ( error ) ;
2068
- }
2069
- } ) ;
2070
- }
2071
- run ( ) ;
1986
+
1987
+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
1988
+ if ( k2 === undefined ) k2 = k ;
1989
+ Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
1990
+ } ) : ( function ( o , m , k , k2 ) {
1991
+ if ( k2 === undefined ) k2 = k ;
1992
+ o [ k2 ] = m [ k ] ;
1993
+ } ) ) ;
1994
+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
1995
+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
1996
+ } ) : function ( o , v ) {
1997
+ o [ "default" ] = v ;
1998
+ } ) ;
1999
+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
2000
+ if ( mod && mod . __esModule ) return mod ;
2001
+ var result = { } ;
2002
+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
2003
+ __setModuleDefault ( result , mod ) ;
2004
+ return result ;
2005
+ } ;
2006
+ var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
2007
+ function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
2008
+ return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
2009
+ function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
2010
+ function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
2011
+ function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
2012
+ step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
2013
+ } ) ;
2014
+ } ;
2015
+ var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
2016
+ return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
2017
+ } ;
2018
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
2019
+ const core = __importStar ( __webpack_require__ ( 470 ) ) ;
2020
+ const github = __importStar ( __webpack_require__ ( 469 ) ) ;
2021
+ const child_process_1 = __webpack_require__ ( 129 ) ;
2022
+ const fs_1 = __importDefault ( __webpack_require__ ( 747 ) ) ;
2023
+ const DiffChecker_1 = __webpack_require__ ( 563 ) ;
2024
+ function run ( ) {
2025
+ var _a , _b ;
2026
+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
2027
+ try {
2028
+ const repoName = github . context . repo . repo ;
2029
+ const repoOwner = github . context . repo . owner ;
2030
+ const githubToken = core . getInput ( 'accessToken' ) ;
2031
+ const fullCoverage = JSON . parse ( core . getInput ( 'fullCoverageDiff' ) ) ;
2032
+ const commandToRun = core . getInput ( 'runCommand' ) ;
2033
+ const githubClient = github . getOctokit ( githubToken ) ;
2034
+ const prNumber = github . context . issue . number ;
2035
+ const branchNameBase = ( _a = github . context . payload . pull_request ) === null || _a === void 0 ? void 0 : _a . base . ref ;
2036
+ const branchNameHead = ( _b = github . context . payload . pull_request ) === null || _b === void 0 ? void 0 : _b . head . ref ;
2037
+ child_process_1 . execSync ( commandToRun ) ;
2038
+ const codeCoverageNew = ( JSON . parse ( fs_1 . default . readFileSync ( 'coverage-summary.json' ) . toString ( ) ) ) ;
2039
+ child_process_1 . execSync ( '/usr/bin/git fetch' ) ;
2040
+ child_process_1 . execSync ( '/usr/bin/git stash' ) ;
2041
+ child_process_1 . execSync ( `/usr/bin/git checkout --progress --force ${ branchNameBase } ` ) ;
2042
+ child_process_1 . execSync ( commandToRun ) ;
2043
+ const codeCoverageOld = ( JSON . parse ( fs_1 . default . readFileSync ( 'coverage-summary.json' ) . toString ( ) ) ) ;
2044
+ const currentDirectory = child_process_1 . execSync ( 'pwd' )
2045
+ . toString ( )
2046
+ . trim ( ) ;
2047
+ const diffChecker = new DiffChecker_1 . DiffChecker ( codeCoverageNew , codeCoverageOld ) ;
2048
+ let messageToPost = `Code coverage diff between base branch:${ branchNameBase } and head branch: ${ branchNameHead } \n` ;
2049
+ const coverageDetails = diffChecker . getCoverageDetails ( ! fullCoverage , `${ currentDirectory } /` ) ;
2050
+ if ( coverageDetails . length === 0 ) {
2051
+ messageToPost =
2052
+ 'No changes to code coverage between the base branch and the head branch' ;
2053
+ }
2054
+ else {
2055
+ messageToPost +=
2056
+ 'File | % Stmts | % Branch | % Funcs | % Lines \n -----|---------|----------|---------|------ \n' ;
2057
+ messageToPost += coverageDetails . join ( '\n' ) ;
2058
+ }
2059
+ yield githubClient . issues . createComment ( {
2060
+ repo : repoName ,
2061
+ owner : repoOwner ,
2062
+ body : messageToPost ,
2063
+ issue_number : prNumber
2064
+ } ) ;
2065
+ }
2066
+ catch ( error ) {
2067
+ core . setFailed ( error ) ;
2068
+ }
2069
+ } ) ;
2070
+ }
2071
+ run ( ) ;
2072
2072
2073
2073
2074
2074
/***/ } ) ,
@@ -6661,93 +6661,93 @@ module.exports = isPlainObject;
6661
6661
/***/ ( function ( __unusedmodule , exports ) {
6662
6662
6663
6663
"use strict" ;
6664
-
6665
- Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
6666
- exports . DiffChecker = void 0 ;
6667
- class DiffChecker {
6668
- constructor ( coverageReportNew , coverageReportOld ) {
6669
- this . diffCoverageReport = { } ;
6670
- const reportNewKeys = Object . keys ( coverageReportNew ) ;
6671
- for ( const key of reportNewKeys ) {
6672
- this . diffCoverageReport [ key ] = {
6673
- branches : {
6674
- newPct : this . getPercentage ( coverageReportNew [ key ] . branches )
6675
- } ,
6676
- statements : {
6677
- newPct : this . getPercentage ( coverageReportNew [ key ] . statements )
6678
- } ,
6679
- lines : {
6680
- newPct : this . getPercentage ( coverageReportNew [ key ] . lines )
6681
- } ,
6682
- functions : {
6683
- newPct : this . getPercentage ( coverageReportNew [ key ] . functions )
6684
- }
6685
- } ;
6686
- }
6687
- const reportOldKeys = Object . keys ( coverageReportOld ) ;
6688
- for ( const key of reportOldKeys ) {
6689
- if ( this . diffCoverageReport [ key ] ) {
6690
- this . diffCoverageReport [ key ] . statements . oldPct = this . getPercentage ( coverageReportOld [ key ] . statements ) ;
6691
- this . diffCoverageReport [ key ] . branches . oldPct = this . getPercentage ( coverageReportOld [ key ] . branches ) ;
6692
- this . diffCoverageReport [ key ] . functions . oldPct = this . getPercentage ( coverageReportOld [ key ] . functions ) ;
6693
- this . diffCoverageReport [ key ] . lines . oldPct = this . getPercentage ( coverageReportOld [ key ] . lines ) ;
6694
- }
6695
- else {
6696
- this . diffCoverageReport [ key ] = {
6697
- branches : {
6698
- oldPct : this . getPercentage ( coverageReportOld [ key ] . branches )
6699
- } ,
6700
- statements : {
6701
- oldPct : this . getPercentage ( coverageReportOld [ key ] . statements )
6702
- } ,
6703
- lines : {
6704
- oldPct : this . getPercentage ( coverageReportOld [ key ] . lines )
6705
- } ,
6706
- functions : {
6707
- oldPct : this . getPercentage ( coverageReportOld [ key ] . functions )
6708
- }
6709
- } ;
6710
- }
6711
- }
6712
- }
6713
- getCoverageDetails ( diffOnly , currentDirectory ) {
6714
- const keys = Object . keys ( this . diffCoverageReport ) ;
6715
- const returnStrings = [ ] ;
6716
- for ( const key of keys ) {
6717
- if ( this . compareCoverageValues ( this . diffCoverageReport [ key ] ) !== 0 ) {
6718
- returnStrings . push ( this . createDiffLine ( key . replace ( currentDirectory , '' ) , this . diffCoverageReport [ key ] ) ) ;
6719
- }
6720
- else {
6721
- if ( ! diffOnly ) {
6722
- returnStrings . push ( `${ key . replace ( currentDirectory , '' ) } | ${ this . diffCoverageReport [ key ] . statements . newPct } | ${ this . diffCoverageReport [ key ] . branches . newPct } | ${ this . diffCoverageReport [ key ] . functions . newPct } | ${ this . diffCoverageReport [ key ] . lines . newPct } ` ) ;
6723
- }
6724
- }
6725
- }
6726
- return returnStrings ;
6727
- }
6728
- createDiffLine ( name , diffFileCoverageData ) {
6729
- if ( ! diffFileCoverageData . branches . oldPct ) {
6730
- return `**${ name } ** | **${ diffFileCoverageData . statements . newPct } ** | **${ diffFileCoverageData . branches . newPct } ** | **${ diffFileCoverageData . functions . newPct } ** | **${ diffFileCoverageData . lines . newPct } **` ;
6731
- }
6732
- else if ( ! diffFileCoverageData . branches . newPct ) {
6733
- return `~~${ name } ~~ | ~~${ diffFileCoverageData . statements . oldPct } ~~ | ~~${ diffFileCoverageData . branches . oldPct } ~~ | ~~${ diffFileCoverageData . functions . oldPct } ~~ | ~~${ diffFileCoverageData . lines . oldPct } ~~` ;
6734
- }
6735
- return `${ name } | ~~${ diffFileCoverageData . statements . oldPct } ~~ **${ diffFileCoverageData . statements . newPct } ** | ~~${ diffFileCoverageData . branches . oldPct } ~~ **${ diffFileCoverageData . branches . newPct } ** | ~~${ diffFileCoverageData . functions . oldPct } ~~ **${ diffFileCoverageData . functions . newPct } ** | ~~${ diffFileCoverageData . lines . oldPct } ~~ **${ diffFileCoverageData . lines . newPct } **` ;
6736
- }
6737
- compareCoverageValues ( diffCoverageData ) {
6738
- const keys = Object . keys ( diffCoverageData ) ;
6739
- for ( const key of keys ) {
6740
- if ( diffCoverageData [ key ] . oldPct !== diffCoverageData [ key ] . newPct ) {
6741
- return 1 ;
6742
- }
6743
- }
6744
- return 0 ;
6745
- }
6746
- getPercentage ( coverageData ) {
6747
- return coverageData . pct ;
6748
- }
6749
- }
6750
- exports . DiffChecker = DiffChecker ;
6664
+
6665
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
6666
+ exports . DiffChecker = void 0 ;
6667
+ class DiffChecker {
6668
+ constructor ( coverageReportNew , coverageReportOld ) {
6669
+ this . diffCoverageReport = { } ;
6670
+ const reportNewKeys = Object . keys ( coverageReportNew ) ;
6671
+ for ( const key of reportNewKeys ) {
6672
+ this . diffCoverageReport [ key ] = {
6673
+ branches : {
6674
+ newPct : this . getPercentage ( coverageReportNew [ key ] . branches )
6675
+ } ,
6676
+ statements : {
6677
+ newPct : this . getPercentage ( coverageReportNew [ key ] . statements )
6678
+ } ,
6679
+ lines : {
6680
+ newPct : this . getPercentage ( coverageReportNew [ key ] . lines )
6681
+ } ,
6682
+ functions : {
6683
+ newPct : this . getPercentage ( coverageReportNew [ key ] . functions )
6684
+ }
6685
+ } ;
6686
+ }
6687
+ const reportOldKeys = Object . keys ( coverageReportOld ) ;
6688
+ for ( const key of reportOldKeys ) {
6689
+ if ( this . diffCoverageReport [ key ] ) {
6690
+ this . diffCoverageReport [ key ] . statements . oldPct = this . getPercentage ( coverageReportOld [ key ] . statements ) ;
6691
+ this . diffCoverageReport [ key ] . branches . oldPct = this . getPercentage ( coverageReportOld [ key ] . branches ) ;
6692
+ this . diffCoverageReport [ key ] . functions . oldPct = this . getPercentage ( coverageReportOld [ key ] . functions ) ;
6693
+ this . diffCoverageReport [ key ] . lines . oldPct = this . getPercentage ( coverageReportOld [ key ] . lines ) ;
6694
+ }
6695
+ else {
6696
+ this . diffCoverageReport [ key ] = {
6697
+ branches : {
6698
+ oldPct : this . getPercentage ( coverageReportOld [ key ] . branches )
6699
+ } ,
6700
+ statements : {
6701
+ oldPct : this . getPercentage ( coverageReportOld [ key ] . statements )
6702
+ } ,
6703
+ lines : {
6704
+ oldPct : this . getPercentage ( coverageReportOld [ key ] . lines )
6705
+ } ,
6706
+ functions : {
6707
+ oldPct : this . getPercentage ( coverageReportOld [ key ] . functions )
6708
+ }
6709
+ } ;
6710
+ }
6711
+ }
6712
+ }
6713
+ getCoverageDetails ( diffOnly , currentDirectory ) {
6714
+ const keys = Object . keys ( this . diffCoverageReport ) ;
6715
+ const returnStrings = [ ] ;
6716
+ for ( const key of keys ) {
6717
+ if ( this . compareCoverageValues ( this . diffCoverageReport [ key ] ) !== 0 ) {
6718
+ returnStrings . push ( this . createDiffLine ( key . replace ( currentDirectory , '' ) , this . diffCoverageReport [ key ] ) ) ;
6719
+ }
6720
+ else {
6721
+ if ( ! diffOnly ) {
6722
+ returnStrings . push ( `${ key . replace ( currentDirectory , '' ) } | ${ this . diffCoverageReport [ key ] . statements . newPct } | ${ this . diffCoverageReport [ key ] . branches . newPct } | ${ this . diffCoverageReport [ key ] . functions . newPct } | ${ this . diffCoverageReport [ key ] . lines . newPct } ` ) ;
6723
+ }
6724
+ }
6725
+ }
6726
+ return returnStrings ;
6727
+ }
6728
+ createDiffLine ( name , diffFileCoverageData ) {
6729
+ if ( ! diffFileCoverageData . branches . oldPct ) {
6730
+ return `**${ name } ** | **${ diffFileCoverageData . statements . newPct } ** | **${ diffFileCoverageData . branches . newPct } ** | **${ diffFileCoverageData . functions . newPct } ** | **${ diffFileCoverageData . lines . newPct } **` ;
6731
+ }
6732
+ else if ( ! diffFileCoverageData . branches . newPct ) {
6733
+ return `~~${ name } ~~ | ~~${ diffFileCoverageData . statements . oldPct } ~~ | ~~${ diffFileCoverageData . branches . oldPct } ~~ | ~~${ diffFileCoverageData . functions . oldPct } ~~ | ~~${ diffFileCoverageData . lines . oldPct } ~~` ;
6734
+ }
6735
+ return `${ name } | ~~${ diffFileCoverageData . statements . oldPct } ~~ **${ diffFileCoverageData . statements . newPct } ** | ~~${ diffFileCoverageData . branches . oldPct } ~~ **${ diffFileCoverageData . branches . newPct } ** | ~~${ diffFileCoverageData . functions . oldPct } ~~ **${ diffFileCoverageData . functions . newPct } ** | ~~${ diffFileCoverageData . lines . oldPct } ~~ **${ diffFileCoverageData . lines . newPct } **` ;
6736
+ }
6737
+ compareCoverageValues ( diffCoverageData ) {
6738
+ const keys = Object . keys ( diffCoverageData ) ;
6739
+ for ( const key of keys ) {
6740
+ if ( diffCoverageData [ key ] . oldPct !== diffCoverageData [ key ] . newPct ) {
6741
+ return 1 ;
6742
+ }
6743
+ }
6744
+ return 0 ;
6745
+ }
6746
+ getPercentage ( coverageData ) {
6747
+ return coverageData . pct ;
6748
+ }
6749
+ }
6750
+ exports . DiffChecker = DiffChecker ;
6751
6751
6752
6752
6753
6753
/***/ } ) ,
0 commit comments