Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app_dart/lib/src/request_handlers/get_presubmit_jobs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ final class GetPresubmitJobs extends PublicApiRequestHandler {
creationTime: job.creationTime,
startTime: job.startTime,
endTime: job.endTime,
status: job.status.value,
status: job.status,
summary: job.summary,
buildNumber: job.buildNumber,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void main() {
expect(jobs.length, 1);
expect(jobs[0].attemptNumber, 1);
expect(jobs[0].jobName, 'linux');
expect(jobs[0].status, 'Succeeded');
expect(jobs[0].status, TaskStatus.succeeded);
expect(jobs[0].buildNumber, 456);
});

Expand Down
4 changes: 2 additions & 2 deletions dashboard/lib/state/presubmit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ class PresubmitState extends ChangeNotifier {
this.repo = repo;
changed = true;
}
if (pr != this.pr) {
if (this.pr != pr) {
this.pr = pr;
changed = true;
_availableSummaries = [];
_lastFetchedPr = null;
clearFilters();
}
if (sha != this.sha) {
if (this.sha != sha) {
this.sha = sha;
changed = true;
_guardResponse = null;
Expand Down
38 changes: 29 additions & 9 deletions dashboard/lib/views/presubmit_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import '../widgets/task_box.dart';

/// A detailed monitoring view for a specific Pull Request (PR) or commit SHA.
///
/// This view displays CI job statuses and execution logs.
/// This view displays CI job statuses and execution details.
final class PreSubmitView extends StatefulWidget {
const PreSubmitView({
super.key,
Expand Down Expand Up @@ -284,9 +284,11 @@ class _PreSubmitViewState extends State<PreSubmitView> {
child:
(selectedJob == null || guardResponse == null)
? const Center(
child: Text('Select a job to view logs'),
child: Text(
'Select a job to view execution details.',
),
)
: const _LogViewerPane(),
: const _JobDetailsViewerPane(),
),
],
),
Expand All @@ -300,14 +302,14 @@ class _PreSubmitViewState extends State<PreSubmitView> {
}
}

class _LogViewerPane extends StatefulWidget {
const _LogViewerPane();
class _JobDetailsViewerPane extends StatefulWidget {
const _JobDetailsViewerPane();

@override
State<_LogViewerPane> createState() => _LogViewerPaneState();
State<_JobDetailsViewerPane> createState() => _JobDetailsViewerPaneState();
}

class _LogViewerPaneState extends State<_LogViewerPane> {
class _JobDetailsViewerPaneState extends State<_JobDetailsViewerPane> {
int _selectedAttemptIndex = 0;

@override
Expand Down Expand Up @@ -434,7 +436,7 @@ class _LogViewerPaneState extends State<_LogViewerPane> {
child: Row(
children: [
Text(
'Execution Log',
'Execution Details',
style: TextStyle(fontWeight: FontWeight.w600),
),
Spacer(),
Expand All @@ -457,7 +459,7 @@ class _LogViewerPaneState extends State<_LogViewerPane> {
width: double.infinity,
child: SingleChildScrollView(
child: Text(
selectedJob.summary ?? 'No log summary available',
selectedJob.summary ?? _getDefaultJobDetails(selectedJob),
style: const TextStyle(
fontFamily: 'monospace',
fontSize: 13,
Expand Down Expand Up @@ -512,6 +514,24 @@ class _LogViewerPaneState extends State<_LogViewerPane> {
},
);
}

String _getDefaultJobDetails(PresubmitJobResponse job) {
return switch (job.status) {
.succeeded =>
'${job.jobName} executed successfully.\nClick "View more details on LUCI UI" button bellow for more details.',
.failed =>
'${job.jobName} failed.\nClick "View more details on LUCI UI" button bellow for more details.',
.infraFailure =>
'Infrastructure failed during execution of ${job.jobName}.\nClick "View more details on LUCI UI" button bellow for more details.',
.skipped => '${job.jobName} is skipped.',
.neutral => '${job.jobName} is disabled.',
.cancelled => '${job.jobName} is cancelled.',
.inProgress =>
'${job.jobName} is in progress.\nClick "View more details on LUCI UI" button bellow to see execution details.',
.waitingForBackfill =>
'${job.jobName} is not yet scheduled for execution.\n"View more details on LUCI UI" button will become enabled once the job is scheduled.',
};
}
}

class _JobsSidebar extends StatefulWidget {
Expand Down
6 changes: 3 additions & 3 deletions dashboard/test/integration/get_presubmit_checks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void main() {

final result = response.data!.first;
expect(result.jobName, 'linux android_2');
expect(result.status, 'Succeeded');
expect(result.status, TaskStatus.succeeded);
expect(result.attemptNumber, 1);
expect(result.buildNumber, 1337);
expect(result.summary, 'Build succeeded');
Expand Down Expand Up @@ -107,10 +107,10 @@ void main() {
// `orderMap: const { PresubmitJob.fieldAttemptNumber: kQueryOrderDescending }`

expect(response.data![0].attemptNumber, 2);
expect(response.data![0].status, 'Succeeded');
expect(response.data![0].status, TaskStatus.succeeded);

expect(response.data![1].attemptNumber, 1);
expect(response.data![1].status, 'Failed');
expect(response.data![1].status, TaskStatus.failed);
});
});
}
4 changes: 2 additions & 2 deletions dashboard/test/logic/presubmit_guard_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void main() {
'attempt_number': 1,
'job_name': 'Linux Device Doctor',
'creation_time': 1620134239000,
'status': 'Succeeded',
'status': '${TaskStatus.succeeded}',
'summary': 'Check passed',
};

Expand All @@ -52,7 +52,7 @@ void main() {
expect(response.attemptNumber, 1);
expect(response.jobName, 'Linux Device Doctor');
expect(response.creationTime, 1620134239000);
expect(response.status, 'Succeeded');
expect(response.status, TaskStatus.succeeded);
expect(response.summary, 'Check passed');
});
});
Expand Down
5 changes: 4 additions & 1 deletion dashboard/test/state/presubmit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:cocoon_common/guard_status.dart';
import 'package:cocoon_common/rpc_model.dart';
import 'package:cocoon_common/task_status.dart';
import 'package:flutter_dashboard/service/cocoon.dart';
import 'package:flutter_dashboard/state/presubmit.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down Expand Up @@ -159,7 +160,7 @@ void main() {
attemptNumber: 1,
jobName: 'check1',
creationTime: 0,
status: 'Succeeded',
status: TaskStatus.succeeded,
),
];
const guardResponse = PresubmitGuardResponse(
Expand Down Expand Up @@ -395,6 +396,8 @@ void main() {

presubmitState.update(pr: '123', sha: null);

await Future<void>.delayed(Duration.zero);

verify(
mockCocoonService.fetchPresubmitGuardSummaries(
pr: '123',
Expand Down
6 changes: 3 additions & 3 deletions dashboard/test/views/presubmit_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ void main() {
attemptNumber: 1,
jobName: 'Mac mac_host_engine 1',
creationTime: 0,
status: 'Succeeded',
status: TaskStatus.succeeded,
summary: 'All tests passed (452/452)',
),
PresubmitJobResponse(
attemptNumber: 2,
jobName: 'Mac mac_host_engine 1',
creationTime: 0,
status: 'Failed',
status: TaskStatus.failed,
summary: 'Test failed: Unit Tests',
),
]),
Expand Down Expand Up @@ -415,7 +415,7 @@ void main() {
attemptNumber: 1,
jobName: 'Mac mac_host_engine',
creationTime: 0,
status: 'Succeeded',
status: TaskStatus.succeeded,
summary: 'Live log content',
),
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

import '../../task_status.dart';
import 'base.dart';

part 'presubmit_job_response.g.dart';
Expand Down Expand Up @@ -54,7 +55,7 @@ final class PresubmitJobResponse extends Model {
final int? endTime;

/// The status of the job.
final String status;
final TaskStatus status;

/// A brief summary of the job result or link to logs.
final String? summary;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

import 'package:cocoon_common/rpc_model.dart';
import 'package:cocoon_common/task_status.dart';
import 'package:test/test.dart';

void main() {
Expand All @@ -12,7 +13,7 @@ void main() {
'attempt_number': 1,
'job_name': 'linux',
'creation_time': 1000,
'status': 'succeeded',
'status': '${TaskStatus.succeeded}',
'build_number': 456,
};

Expand All @@ -28,7 +29,7 @@ void main() {
'attempt_number': 1,
'job_name': 'linux',
'creation_time': 1000,
'status': 'succeeded',
'status': '${TaskStatus.succeeded}',
};

final response = PresubmitJobResponse.fromJson(json);
Expand Down
Loading