@@ -152,6 +152,20 @@ async function findPullRequestUrlByBranch(owner, repo, branchName) {
152152 }
153153 }
154154
155+ /**
156+ * retrieves a list of active releases from a Google Sheets document.
157+ * Each sheet in the document represents a different release. Only sheets with visible
158+ * titles containing a semantic version and optionally a platform within parentheses
159+ * are considered. Each active release is identified by parsing the sheet's title
160+ * for semantic versioning and platform details.
161+ *
162+ * @param {string } documentId - The ID of the Google Sheets document to query.
163+ * @returns {Promise<Object[]> } A promise that resolves to an array of objects, each representing
164+ * an active release with properties for the document ID, semantic version, platform,
165+ * sheet ID, and the testing status.
166+ * @throws {Error } Throws an error if there is an issue retrieving data from the spreadsheet.
167+ *
168+ */
155169async function GetActiveReleases ( documentId ) {
156170 const authClient = await getGoogleAuth ( ) ;
157171
@@ -206,7 +220,7 @@ async function GetActiveReleases(documentId) {
206220 * @param {string } spreadsheetId - The ID of the Google Spreadsheet.
207221 * @param {string } sheetName - The name of the sheet within the spreadsheet.
208222 * @param {string } cellRange - The A1 notation of the range to read (e.g., 'A1', 'A1:B2').
209- * @returns {Promise<string[][] | undefined > } The data read from the specified range, or undefined if no data.
223+ * @returns {Promise<string[][]> } The data read from the specified range, or undefined if no data.
210224 */
211225async function readSheetData ( spreadsheetId , sheetName , cellRange ) {
212226 const authClient = await getGoogleAuth ( ) ;
@@ -228,10 +242,16 @@ async function readSheetData(spreadsheetId, sheetName, cellRange) {
228242}
229243
230244/**
231- * Determines the number of release blockers for a given release and team
232- * @param {* } release
233- * @param {* } team
234- * @returns
245+ * fetches the count and details of GitHub issues marked as release blockers
246+ * for a specific version and team. This function queries GitHub issues that are tagged with
247+ * specific labels related to the release version, team, and a "release-blocker" label.
248+ *
249+ * @param {Object } release - An object representing the release
250+ * @param {Object } team - An object representing the team
251+ * @returns {Promise<Object> } A promise that resolves to an object containing the count of open release-blocking issues,
252+ * a URL to view these issues on GitHub, and optionally an array of issue objects.
253+ * @throws {Error } Throws an error if the GitHub API call fails.
254+ *
235255 */
236256async function getReleaseBlockers ( release , team ) {
237257
@@ -265,10 +285,6 @@ async function getReleaseBlockers(release, team) {
265285 }
266286}
267287
268- function testOnly ( ) {
269- return process . env . TEST_ONLY === 'true' ;
270- }
271-
272288/**
273289 * Determine the Slack channel name to publish to based on the release
274290 * @param {* } release
@@ -305,7 +321,7 @@ async function fmtSlackHandle(team) {
305321
306322/**
307323 * Publishes the testing status for a release to the appropriate Slack channel
308- * @param {* } release
324+ * @param {Object } release represents a release
309325 */
310326async function publishReleaseTestingStatus ( release ) {
311327
@@ -317,14 +333,12 @@ async function publishReleaseTestingStatus(release) {
317333 console . log ( `Publishing testing status for release ${ release . SemanticVersion } on platform ${ release . Platform } to channel ${ channel } ` ) ;
318334
319335 //Determine notification counts for this release
320- //const notificationCount = await getNotificationCount(release);
321336 const testingDocumentLink = createSheetUrl ( release . DocumentId , release . sheetId ) ;
322337
323- // Format the Slack message
338+
324339 var header = `:blablablocker:* [${ fmtPlatform } ] - ${ release . SemanticVersion } Release Validation.*\n`
325340 + `_*Testing Plan and Progress Tracker Summary*_ (<https://docs.google.com/spreadsheets/d/${ release . DocumentId } /edit#gid=${ release . sheetId } |${ release . SemanticVersion } >):` ;
326341
327- // Construct the message
328342 var body = `*Teams Sign Off ${ release . SemanticVersion } Release on <${ releasePrUrl } |GH>:*\n`
329343
330344 const hasPendingSignoffs = teamResults . some ( team => team . status !== "Completed" ) ;
@@ -333,8 +347,9 @@ async function publishReleaseTestingStatus(release) {
333347
334348 for ( const team of teamResults ) {
335349 let slackHandlePart = await fmtSlackHandle ( team ) ;
350+ //Grab RCs for a specific team/release
336351 const releaseBlockers = await getReleaseBlockers ( release , team . team ) ;
337- //Accumulate the release blocker count
352+ //Accumulate the total release blocker count
338353 releaseBlockerCount += releaseBlockers . count ;
339354 let releaseBlockerParts = releaseBlockers . count > 0 ? ` - <${ releaseBlockers . url } |${ releaseBlockers . count } Release Blockers>` : '' ;
340355
@@ -351,7 +366,7 @@ async function publishReleaseTestingStatus(release) {
351366
352367
353368 try {
354- const response = await slackClient . chat . postMessage ( {
369+ await slackClient . chat . postMessage ( {
355370 channel : channel ,
356371 text : slackMessage ,
357372 unfurl_links : false ,
@@ -366,12 +381,21 @@ async function publishReleaseTestingStatus(release) {
366381 }
367382}
368383
369- async function publishReleasesTestingStatus ( activeReleases ) {
384+
385+ /**
386+ * publishes the testing status for a list of releases.
387+ *
388+ * @param {Object[] } releases - An array of release objects. Each release object should be suitable
389+ * for use with the `publishReleaseTestingStatus` function.
390+ * @throws {Error } Throws an error if the publishing process fails for one or more releases.
391+ *
392+ */
393+ async function publishReleasesTestingStatus ( releases ) {
370394
371395 console . log ( 'Publishing testing status for all active releases...' ) ;
372396
373397 try {
374- const promises = activeReleases . map ( release => publishReleaseTestingStatus ( release ) ) ;
398+ const promises = releases . map ( release => publishReleaseTestingStatus ( release ) ) ;
375399 await Promise . all ( promises ) ;
376400 } catch ( error ) {
377401 console . error ( 'An error occurred:' , error ) ;
@@ -409,12 +433,19 @@ async function main() {
409433 await publishReleasesTestingStatus ( filteredReleases ) ;
410434}
411435
412- function createSheetUrl ( documentId , sheetId ) {
413- return `https://docs.google.com/spreadsheets/d/${ documentId } /edit#gid=${ sheetId } ` ;
414- }
415-
436+ //Entrypoint
416437main ( ) ;
417438
439+
440+ // Helper functions
418441function formatTitle ( val ) {
419442 return String ( val ) . charAt ( 0 ) . toUpperCase ( ) + String ( val ) . slice ( 1 ) ;
420443}
444+
445+ function testOnly ( ) {
446+ return process . env . TEST_ONLY === 'true' ;
447+ }
448+
449+ function createSheetUrl ( documentId , sheetId ) {
450+ return `https://docs.google.com/spreadsheets/d/${ documentId } /edit#gid=${ sheetId } ` ;
451+ }
0 commit comments