@@ -84,24 +84,27 @@ var collectNightlyTestStatusCmd = &cobra.Command{
8484 tc := teamcity .NewClient (env ["TEAMCITY_TOKEN" ])
8585 gcs := cloudstorage .NewClient ()
8686
87- now := time .Now ()
88-
8987 loc , err := time .LoadLocation ("America/Los_Angeles" )
9088 if err != nil {
9189 return fmt .Errorf ("Error loading location: %s" , err )
9290 }
93- date := now .In (loc )
91+
92+ now := time .Now ().In (loc )
93+ year , month , day := now .Date ()
94+
9495 customDate := args [0 ]
9596 // check if a specific date is provided
9697 if customDate != "" {
9798 parsedDate , err := time .Parse ("2006-01-02" , customDate ) // input format YYYY-MM-DD
98- // Set the time to 7pm PT
99- date = time .Date (parsedDate .Year (), parsedDate .Month (), parsedDate .Day (), 19 , 0 , 0 , 0 , loc )
10099 if err != nil {
101100 return fmt .Errorf ("invalid input time format: %w" , err )
102101 }
102+ year , month , day = parsedDate .Date ()
103103 }
104104
105+ // Set the time to 7pm PT
106+ date = time .Date (year , month , day , 19 , 0 , 0 , 0 , loc )
107+
105108 return execCollectNightlyTestStatus (date , tc , gcs )
106109 },
107110}
@@ -134,10 +137,31 @@ func execCollectNightlyTestStatus(now time.Time, tc TeamcityClient, gcs Cloudsto
134137}
135138
136139func createTestReport (pVersion provider.Version , tc TeamcityClient , gcs CloudstorageClient , formattedStartCut , formattedFinishCut , date string ) error {
140+
141+ // Check Queued Builds
142+ queuedBuilds , err := tc .GetBuilds ("queued" , pVersion .TeamCityNightlyProjectName (), formattedFinishCut , formattedStartCut )
143+ if err != nil {
144+ return fmt .Errorf ("failed to get queued builds: %w" , err )
145+ }
146+ if len (queuedBuilds .Builds ) > 0 {
147+ fmt .Printf ("Test unfinished: there are still %d builds queued.\n " , len (queuedBuilds .Builds ))
148+ return
149+ }
150+
151+ // Check Running Builds
152+ runningBuilds , err = tc .GetBuilds ("running" , pVersion .TeamCityNightlyProjectName (), formattedFinishCut , formattedStartCut )
153+ if err != nil {
154+ return fmt .Errorf ("failed to get running builds: %w" , err )
155+ }
156+ if len (runningBuilds .Builds ) > 0 {
157+ fmt .Printf ("Test unfinished: there are still %d builds queued.\n " , len (runningBuilds .Builds ))
158+ return
159+ }
160+
137161 // Get all service test builds
138- builds , err : = tc .GetBuilds (pVersion .TeamCityNightlyProjectName (), formattedFinishCut , formattedStartCut )
162+ builds , err = tc .GetBuilds (pVersion .TeamCityNightlyProjectName (), formattedFinishCut , formattedStartCut )
139163 if err != nil {
140- return err
164+ return fmt . Errorf ( "failed to get finished builds: %w" , err )
141165 }
142166
143167 var testInfoList []TestInfo
0 commit comments