@@ -21,99 +21,93 @@ export async function run(
2121 getOctokit = github . getOctokit ,
2222 git = simpleGit ( )
2323) : Promise < void > {
24- try {
25- const inputs = parseInputs ( )
26- const options = createOptions ( inputs )
24+ const inputs = parseInputs ( )
25+ const options = createOptions ( inputs )
2726
28- const [ nodeMajorString ] = (
29- process . version . startsWith ( 'v' )
30- ? process . version . slice ( 1 )
31- : process . version
32- ) . split ( '.' )
33- const majorVersion = parseInt ( nodeMajorString , 10 )
34- const isUnsupportedVersion = majorVersion < 20
27+ if ( options . debug ) {
28+ core . info (
29+ `${ LOG_PREFIX } Debug in actions in enabled, setting CP_VERBOSE env variable to true`
30+ )
31+ process . env [ 'CP_VERBOSE' ] = 'true'
32+ }
3533
36- if ( isUnsupportedVersion ) {
37- core . warning (
38- `${ LOG_PREFIX } Internal runner is using unsupported NodeJS version ${ process . version } `
39- )
40- } else if ( options . debug ) {
41- core . info (
42- `${ LOG_PREFIX } Internal runner is using NodeJS version ${ process . version } `
43- )
44- }
34+ const [ nodeMajorString ] = (
35+ process . version . startsWith ( 'v' ) ? process . version . slice ( 1 ) : process . version
36+ ) . split ( '.' )
37+ const majorVersion = parseInt ( nodeMajorString , 10 )
38+ const isUnsupportedVersion = majorVersion < 20
4539
46- const refs = parseGitRefs ( )
47- const api = new GitHubApiClient ( inputs . token , refs , artifact , getOctokit )
40+ if ( isUnsupportedVersion ) {
41+ core . warning (
42+ `${ LOG_PREFIX } Internal runner is using unsupported NodeJS version ${ process . version } `
43+ )
44+ } else if ( options . debug ) {
45+ core . info (
46+ `${ LOG_PREFIX } Internal runner is using NodeJS version ${ process . version } `
47+ )
48+ }
4849
49- const result = await runInCI ( refs , api , options , git )
50+ const refs = parseGitRefs ( )
51+ const api = new GitHubApiClient ( inputs . token , refs , artifact , getOctokit )
5052
51- if ( result . commentId != null ) {
52- core . setOutput ( 'comment-id' , result . commentId )
53- core . info ( `Commented on PR #${ github . context . issue . number } ` )
54- }
53+ const result = await runInCI ( refs , api , options , git )
5554
56- const diffFiles =
57- result . mode === 'standalone'
58- ? Object . values ( result . files . diff ?? { } )
59- : result . diffPath
60- ? [ result . diffPath ]
61- : [ ]
62- if ( diffFiles . length > 0 ) {
63- await uploadArtifact (
64- artifact ,
65- createDiffArtifactName ( ) ,
66- diffFiles ,
67- inputs
68- )
69- }
55+ if ( result . commentId != null ) {
56+ core . setOutput ( 'comment-id' , result . commentId )
57+ core . info ( `Commented on PR #${ github . context . issue . number } ` )
58+ }
59+
60+ const diffFiles =
61+ result . mode === 'standalone'
62+ ? Object . values ( result . files . diff ?? { } )
63+ : result . diffPath
64+ ? [ result . diffPath ]
65+ : [ ]
66+
67+ if ( diffFiles . length > 0 ) {
68+ await uploadArtifact ( artifact , createDiffArtifactName ( ) , diffFiles , inputs )
69+ }
7070
71- if ( result . mode === 'standalone' ) {
72- const id = await uploadArtifact (
71+ if ( result . mode === 'standalone' ) {
72+ const id = await uploadArtifact (
73+ artifact ,
74+ createReportArtifactName ( ) ,
75+ Object . values ( result . files . report ) ,
76+ inputs
77+ )
78+ core . setOutput ( 'artifact-id' , id )
79+ } else {
80+ for ( const project of result . projects ) {
81+ await uploadArtifact (
7382 artifact ,
74- createReportArtifactName ( ) ,
75- Object . values ( result . files . report ) ,
83+ createReportArtifactName ( project . name ) ,
84+ Object . values ( project . files . report ) ,
7685 inputs
7786 )
78- core . setOutput ( 'artifact-id' , id )
79- } else {
80- for ( const project of result . projects ) {
87+ if ( project . files . diff ) {
8188 await uploadArtifact (
8289 artifact ,
83- createReportArtifactName ( project . name ) ,
84- Object . values ( project . files . report ) ,
90+ createDiffArtifactName ( project . name ) ,
91+ Object . values ( project . files . diff ) ,
8592 inputs
8693 )
87- if ( project . files . diff ) {
88- await uploadArtifact (
89- artifact ,
90- createDiffArtifactName ( project . name ) ,
91- Object . values ( project . files . diff ) ,
92- inputs
93- )
94- }
9594 }
9695 }
96+ }
9797
98- if ( inputs . annotations ) {
99- const issues =
100- result . mode === 'standalone'
101- ? ( result . newIssues ?? [ ] )
102- : result . projects . flatMap ( project => project . newIssues ?? [ ] )
103- if ( issues . length > 0 ) {
104- core . info (
105- `Found ${ issues . length } new issues, creating GitHub annotations`
106- )
107- createAnnotationsFromIssues ( issues )
108- } else {
109- core . info ( 'No new issues found, skipping GitHub annotations' )
110- }
98+ if ( inputs . annotations ) {
99+ const issues =
100+ result . mode === 'standalone'
101+ ? ( result . newIssues ?? [ ] )
102+ : result . projects . flatMap ( project => project . newIssues ?? [ ] )
103+ if ( issues . length > 0 ) {
104+ core . info (
105+ `Found ${ issues . length } new issues, creating GitHub annotations`
106+ )
107+ createAnnotationsFromIssues ( issues )
108+ } else {
109+ core . info ( 'No new issues found, skipping GitHub annotations' )
111110 }
112- } catch ( error ) {
113- const errorMessage = error instanceof Error ? error . message : `${ error } `
114- core . error ( errorMessage )
115- core . setFailed ( errorMessage )
116- return
117111 }
118112
119113 core . info ( `${ LOG_PREFIX } Finished running successfully` )
0 commit comments