@@ -17,46 +17,81 @@ writeTestingCSV();
1717
1818async function writeTestingCSV ( ) {
1919 let data = await listCommits ( ) ;
20- let prs = [ ] ;
20+
21+ let s2PRs = [ ] ;
22+ let racPRs = [ ] ;
23+ let v3PRs = [ ] ;
24+ let otherPRs = [ ] ;
25+
2126 for ( let d of data ) {
2227 let row = [ ] ;
2328
2429 // Get the PR Title from the commit
2530 let regex = / \( # ( \d + ) \) / g;
2631 let messages = d . commit . message . split ( '\n' ) ;
2732 let title = messages [ 0 ] ;
28- row . push ( title )
29-
33+ row . push ( title ) ;
3034
3135 // Get info about the PR using PR number
3236 if ( regex . test ( title ) ) {
3337 let num = title . match ( regex ) [ 0 ] . replace ( / [ \( \) # ] / g, '' ) ;
3438 let info = await getPR ( num ) ;
3539
36- // Get testing instructions if it exists
37- let content = info . data . body ;
38- const match = content . match ( / # # 📝 T e s t I n s t r u c t i o n s : \s * ( [ \s \S ] * ?) (? = # # | $ ) / ) ;
39- let testInstructions = '' ;
40- if ( match ) {
41- testInstructions = match [ 1 ] ;
42- testInstructions = testInstructions . replace ( / < ! - - [ \s \S ] * ?- - > / g, '' ) ;
43- testInstructions = testInstructions . trim ( ) ;
40+ // Check for "needs testing" label on the PR
41+ if ( isReadyForTesting ( info . data . labels ) ) {
42+ // Get testing instructions if it exists
43+ let content = info . data . body ;
44+ const match = content . match ( / # # 📝 T e s t I n s t r u c t i o n s : \s * ( [ \s \S ] * ?) (? = # # | $ ) / ) ;
45+ let testInstructions = '' ;
46+ if ( match ) {
47+ testInstructions = match [ 1 ] ;
48+ testInstructions = testInstructions . replace ( / < ! - - [ \s \S ] * ?- - > / g, '' ) ;
49+ testInstructions = testInstructions . trim ( ) ;
50+ testInstructions = escapeCSV ( testInstructions ) ;
51+ }
52+
53+ if ( testInstructions . length > 350 ) {
54+ row . push ( 'See PR for testing instructions' ) ;
55+ } else {
56+ row . push ( testInstructions ) ;
57+ }
58+ row . push ( info . data . html_url ) ;
59+
60+ if ( ( / \b s 2 \b / gi) . test ( title ) ) {
61+ s2PRs . push ( row ) ;
62+ } else if ( ( / \b r a c \b / gi) . test ( title ) ) {
63+ racPRs . push ( row ) ;
64+ } else if ( ( / \b v 3 \b / gi) . test ( title ) ) {
65+ v3PRs . push ( row ) ;
66+ } else {
67+ otherPRs . push ( row ) ;
68+ }
4469 }
45-
46- row . push ( escapeCSV ( testInstructions ) ) ;
47- row . push ( info . data . html_url )
4870 }
49- prs . push ( row ) ;
5071 }
5172
5273 let csvRows = '' ;
53- for ( let pr of prs ) {
54- csvRows += pr . join ( ) ;
55- csvRows += '\n'
74+ csvRows += 'V3 \n' ;
75+ for ( let v3 of v3PRs ) {
76+ csvRows += v3 . join ( ) + '\n' ;
77+ }
78+
79+ csvRows += '\nRainbow \n'
80+ for ( let s2 of s2PRs ) {
81+ csvRows += s2 . join ( ) + '\n' ;
82+ }
83+
84+ csvRows += '\nRAC \n'
85+ for ( let rac of racPRs ) {
86+ csvRows += rac . join ( ) + '\n' ;
5687 }
5788
58- fs . writeFileSync ( 'output.csv' , csvRows , 'utf-8' )
89+ csvRows += '\nOther \n'
90+ for ( let other of otherPRs ) {
91+ csvRows += other . join ( ) + '\n' ;
92+ }
5993
94+ fs . writeFileSync ( 'output.csv' , csvRows , 'utf-8' ) ;
6095}
6196
6297async function listCommits ( ) {
@@ -73,7 +108,7 @@ async function listCommits() {
73108 let endDate = new Date ( end ) . toISOString ( ) ;
74109
75110 if ( isNaN ( startDate ) || isNaN ( endDate ) ) {
76- console . error ( 'Please verify that your date is correctly formatted' )
111+ console . error ( 'Please verify that your date is correctly formatted' ) ;
77112 }
78113
79114 let res = await octokit . request ( `GET /repos/adobe/react-spectrum/commits?sha=main&since=${ startDate } &until=${ endDate } ` , {
@@ -82,7 +117,7 @@ async function listCommits() {
82117 headers : {
83118 'X-GitHub-Api-Version' : '2022-11-28'
84119 }
85- } )
120+ } ) ;
86121
87122 return res . data ;
88123}
@@ -95,9 +130,8 @@ async function getPR(num) {
95130 headers : {
96131 'X-GitHub-Api-Version' : '2022-11-28'
97132 }
98- } )
99-
100- return res
133+ } ) ;
134+ return res ;
101135}
102136
103137function escapeCSV ( value ) {
@@ -114,3 +148,17 @@ function escapeCSV(value) {
114148 // Wrap in quotes so commas/newlines don't break the cell
115149 return `"${ escaped } "` ;
116150}
151+
152+
153+ function isReadyForTesting ( labels ) {
154+ if ( labels . length === 0 ) {
155+ return false ;
156+ }
157+ for ( let label of labels ) {
158+ if ( label . name === 'needs testing' ) {
159+ return true ;
160+ }
161+ }
162+
163+ return false ;
164+ }
0 commit comments