forked from flutter/cocoon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'flutter:main' into main
- Loading branch information
Showing
20 changed files
with
712 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"targets":[{"name":"Linux Cocoon","properties":{"add_recipes_cq":"true"},"runIf":[".ci.yaml","analyze/**","app_dart/**","auto_submit/**","cipd_packages/**","cloud_build/**","dashboard/**","dev/**","licenses/**","packages/**","test_utilities/**","tooling/**","CI_YAML.md"],"recipe":"cocoon/cocoon"},{"name":"Linux device_doctor","properties":{"script":"cipd_packages/device_doctor/tool/build.sh","cipd_name":"flutter/device_doctor/linux-amd64"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac device_doctor","properties":{"script":"cipd_packages/device_doctor/tool/build.sh","cipd_name":"flutter/device_doctor/mac-amd64","device_type":"none"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac_arm64 device_doctor","properties":{"script":"cipd_packages/device_doctor/tool/build.sh","cipd_name":"flutter/device_doctor/mac-arm64","device_type":"none"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Windows device_doctor","properties":{"script":"cipd_packages\\device_doctor\\tool\\build.bat","cipd_name":"flutter/device_doctor/windows-amd64"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Linux doxygen","properties":{"script":"cipd_packages/doxygen/tool/build.sh","cipd_name":"flutter/doxygen/linux-amd64","dependencies":"[\n {\"dependency\": \"cmake\", \"version\": \"build_id:8787856497187628321\"}\n]"},"runIf":["cipd_packages/doxygen/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac codesign","properties":{"script":"cipd_packages/codesign/tool/build.sh","cipd_name":"flutter/codesign/mac-amd64","device_type":"none"},"runIf":["cipd_packages/codesign/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac_arm64 codesign","properties":{"script":"cipd_packages/codesign/tool/build.sh","cipd_name":"flutter/codesign/mac-arm64","device_type":"none"},"runIf":["cipd_packages/codesign/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac ruby","timeout":60,"properties":{"script":"cipd_packages/ruby/tools/build.sh","cipd_name":"flutter/ruby/mac-amd64","device_os":"iOS","contexts":"[\n \"osx_sdk_devicelab\"\n]","$flutter/osx_sdk":"{\n \"sdk_version\": \"14e300c\"\n}"},"runIf":["cipd_packages/ruby/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac_arm64 ruby","timeout":60,"properties":{"script":"cipd_packages/ruby/tools/build.sh","cipd_name":"flutter/ruby/mac-arm64","device_os":"iOS","contexts":"[\n \"osx_sdk_devicelab\"\n]","$flutter/osx_sdk":"{\n \"sdk_version\": \"14e300c\"\n}"},"runIf":["cipd_packages/ruby/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Linux ci_yaml roller","properties":{"backfill":"false"},"runIf":[".ci.yaml"],"recipe":"infra/ci_yaml"}],"enabledBranches":["main"],"platformProperties":{"linux":{"properties":{"os":"Linux","device_type":"none"}},"mac":{"properties":{"os":"Mac-12|Mac-13","cpu":"x86"}},"mac_arm64":{"properties":{"os":"Mac-12|Mac-13","cpu":"arm64"}},"windows":{"properties":{"os":"Windows","device_type":"none"}}}} | ||
{"targets":[{"name":"Linux Cocoon","properties":{"add_recipes_cq":"true"},"runIf":[".ci.yaml","analyze/**","app_dart/**","auto_submit/**","cipd_packages/**","cloud_build/**","dashboard/**","dev/**","licenses/**","packages/**","test_utilities/**","tooling/**","CI_YAML.md"],"recipe":"cocoon/cocoon"},{"name":"Linux device_doctor","properties":{"script":"cipd_packages/device_doctor/tool/build.sh","cipd_name":"flutter/device_doctor/linux-amd64"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac device_doctor","properties":{"script":"cipd_packages/device_doctor/tool/build.sh","cipd_name":"flutter/device_doctor/mac-amd64","device_type":"none"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac_arm64 device_doctor","properties":{"script":"cipd_packages/device_doctor/tool/build.sh","cipd_name":"flutter/device_doctor/mac-arm64","device_type":"none"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Windows device_doctor","properties":{"script":"cipd_packages\\device_doctor\\tool\\build.bat","cipd_name":"flutter/device_doctor/windows-amd64"},"runIf":["cipd_packages/device_doctor/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Linux doxygen","properties":{"script":"cipd_packages/doxygen/tool/build.sh","cipd_name":"flutter/doxygen/linux-amd64","dependencies":"[\n {\"dependency\": \"cmake\", \"version\": \"build_id:8787856497187628321\"}\n]"},"runIf":["cipd_packages/doxygen/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac codesign","properties":{"script":"cipd_packages/codesign/tool/build.sh","cipd_name":"flutter/codesign/mac-amd64","device_type":"none"},"runIf":["cipd_packages/codesign/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac_arm64 codesign","properties":{"script":"cipd_packages/codesign/tool/build.sh","cipd_name":"flutter/codesign/mac-arm64","device_type":"none"},"runIf":["cipd_packages/codesign/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac ruby","timeout":60,"properties":{"script":"cipd_packages/ruby/tools/build.sh","cipd_name":"flutter/ruby/mac-amd64","device_os":"iOS","contexts":"[\n \"osx_sdk_devicelab\"\n]","$flutter/osx_sdk":"{\n \"sdk_version\": \"14e300c\"\n}"},"runIf":["cipd_packages/ruby/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Mac_arm64 ruby","timeout":60,"properties":{"script":"cipd_packages/ruby/tools/build.sh","cipd_name":"flutter/ruby/mac-arm64","device_os":"iOS","contexts":"[\n \"osx_sdk_devicelab\"\n]","$flutter/osx_sdk":"{\n \"sdk_version\": \"14e300c\"\n}"},"runIf":["cipd_packages/ruby/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Linux ktlint","timeout":60,"properties":{"script":"cipd_packages/ktlint/tools/build.sh","cipd_name":"flutter/ktlint/linux-amd64"},"runIf":["cipd_packages/ktlint/**",".ci.yaml"],"recipe":"cocoon/cipd"},{"name":"Linux ci_yaml roller","properties":{"backfill":"false"},"runIf":[".ci.yaml"],"recipe":"infra/ci_yaml"}],"enabledBranches":["main"],"platformProperties":{"linux":{"properties":{"os":"Linux","device_type":"none"}},"mac":{"properties":{"os":"Mac-12|Mac-13","cpu":"x86"}},"mac_arm64":{"properties":{"os":"Mac-12|Mac-13","cpu":"arm64"}},"windows":{"properties":{"os":"Windows","device_type":"none"}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright 2019 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:cocoon_service/cocoon_service.dart'; | ||
import 'package:github/github.dart'; | ||
import 'package:googleapis/firestore/v1.dart' hide Status; | ||
|
||
import '../../service/firestore.dart'; | ||
import '../appengine/github_build_status_update.dart'; | ||
|
||
const String kGithubBuildStatusCollectionId = 'githubBuildStatuses'; | ||
const String kGithubBuildStatusPrNumberField = 'prNumber'; | ||
const String kGithubBuildStatusRepositoryField = 'repository'; | ||
const String kGithubBuildStatusHeadField = 'head'; | ||
const String kGithubBuildStatusStatusField = 'status'; | ||
const String kGithubBuildStatusUpdateTimeMillisField = 'updateTimeMillis'; | ||
const String kGithubBuildStatusUpdatesField = 'updates'; | ||
|
||
/// Class that represents an update having been posted to a GitHub PR on the | ||
/// status of the Flutter build. | ||
class GithubBuildStatus extends Document { | ||
/// Lookup [GithubBuildStatus] from Firestore. | ||
/// | ||
/// `documentName` follows `/projects/{project}/databases/{database}/documents/{document_path}` | ||
static Future<GithubBuildStatus> fromFirestore({ | ||
required FirestoreService firestoreService, | ||
required String documentName, | ||
}) async { | ||
final Document document = await firestoreService.getDocument(documentName); | ||
return GithubBuildStatus.fromDocument(githubBuildStatus: document); | ||
} | ||
|
||
/// Create [GithubBuildStatus] from a GithubBuildStatus Document. | ||
static GithubBuildStatus fromDocument({ | ||
required Document githubBuildStatus, | ||
}) { | ||
return GithubBuildStatus() | ||
..fields = githubBuildStatus.fields! | ||
..name = githubBuildStatus.name!; | ||
} | ||
|
||
static const String statusSuccess = 'success'; | ||
|
||
static const String statusFailure = 'failure'; | ||
|
||
int? get prNumber => int.parse(fields![kGithubBuildStatusPrNumberField]!.integerValue!); | ||
|
||
/// A serializable form of [slug]. | ||
/// | ||
/// This will be of the form `<org>/<repo>`. e.g. `flutter/flutter`. | ||
String? get repository => fields![kGithubBuildStatusRepositoryField]!.stringValue!; | ||
|
||
/// [RepositorySlug] of where this commit exists. | ||
RepositorySlug get slug => RepositorySlug.full(repository!); | ||
|
||
String? get head => fields![kGithubBuildStatusHeadField]!.stringValue!; | ||
|
||
String? get status => fields![kGithubBuildStatusStatusField]!.stringValue!; | ||
|
||
/// The last time when the status is updated for the PR. | ||
int? get updateTimeMillis => int.parse(fields![kGithubBuildStatusUpdateTimeMillisField]!.integerValue!); | ||
|
||
int? get updates => int.parse(fields![kGithubBuildStatusUpdatesField]!.integerValue!); | ||
|
||
@override | ||
String toString() { | ||
final StringBuffer buf = StringBuffer() | ||
..write('$runtimeType(') | ||
..write(', $kGithubBuildStatusRepositoryField: $repository') | ||
..write(', $kGithubBuildStatusPrNumberField: $prNumber') | ||
..write(', $kGithubBuildStatusHeadField: $head') | ||
..write(', $kGithubBuildStatusStatusField: $status') | ||
..write(', $kGithubBuildStatusUpdatesField: $updates') | ||
..write(', $kGithubBuildStatusUpdateTimeMillisField: $updateTimeMillis') | ||
..write(')'); | ||
return buf.toString(); | ||
} | ||
} | ||
|
||
/// Generates GithubGoldStatus document based on datastore GithubGoldStatusUpdate data model. | ||
GithubBuildStatus githubBuildStatusToDocument(GithubBuildStatusUpdate githubBuildStatus) { | ||
return GithubBuildStatus.fromDocument( | ||
githubBuildStatus: Document( | ||
name: '$kDatabase/documents/$kGithubBuildStatusCollectionId/${githubBuildStatus.head}_${githubBuildStatus.pr}', | ||
fields: <String, Value>{ | ||
kGithubBuildStatusUpdateTimeMillisField: Value(stringValue: githubBuildStatus.updateTimeMillis.toString()), | ||
kGithubBuildStatusHeadField: Value(stringValue: githubBuildStatus.head), | ||
kGithubBuildStatusPrNumberField: Value(integerValue: githubBuildStatus.pr.toString()), | ||
kGithubBuildStatusRepositoryField: Value(stringValue: githubBuildStatus.repository), | ||
kGithubBuildStatusStatusField: Value(stringValue: githubBuildStatus.status), | ||
kGithubBuildStatusUpdatesField: Value(integerValue: githubBuildStatus.updates.toString()), | ||
}, | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app_dart/test/model/firestore/github_build_status_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2019 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:cocoon_service/src/model/appengine/github_build_status_update.dart'; | ||
import 'package:cocoon_service/src/model/firestore/github_build_status.dart'; | ||
import 'package:cocoon_service/src/service/firestore.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../src/utilities/entity_generators.dart'; | ||
import '../../src/utilities/mocks.dart'; | ||
|
||
void main() { | ||
group('GithubBuildStatus.fromFirestore', () { | ||
late MockFirestoreService mockFirestoreService; | ||
|
||
setUp(() { | ||
mockFirestoreService = MockFirestoreService(); | ||
}); | ||
|
||
test('generates githubBuildStatus correctly', () async { | ||
final GithubBuildStatus githubBuildStatus = generateFirestoreGithubBuildStatus(1); | ||
when( | ||
mockFirestoreService.getDocument( | ||
captureAny, | ||
), | ||
).thenAnswer((Invocation invocation) { | ||
return Future<GithubBuildStatus>.value( | ||
githubBuildStatus, | ||
); | ||
}); | ||
final GithubBuildStatus resultedGithubBuildStatus = await GithubBuildStatus.fromFirestore( | ||
firestoreService: mockFirestoreService, | ||
documentName: 'test', | ||
); | ||
expect(resultedGithubBuildStatus.name, githubBuildStatus.name); | ||
expect(resultedGithubBuildStatus.fields, githubBuildStatus.fields); | ||
}); | ||
}); | ||
|
||
group('Creates github gold status document', () { | ||
test('from data model', () async { | ||
final GithubBuildStatusUpdate githubBuildStatusUpdate = GithubBuildStatusUpdate( | ||
head: 'sha', | ||
pr: 1, | ||
status: GithubBuildStatusUpdate.statusSuccess, | ||
updates: 2, | ||
repository: '', | ||
); | ||
final GithubBuildStatus githubBuildStatusDocument = githubBuildStatusToDocument(githubBuildStatusUpdate); | ||
expect( | ||
githubBuildStatusDocument.name, | ||
'$kDatabase/documents/$kGithubBuildStatusCollectionId/${githubBuildStatusUpdate.head}_${githubBuildStatusUpdate.pr}', | ||
); | ||
expect(githubBuildStatusDocument.fields![kGithubBuildStatusHeadField]!.stringValue, githubBuildStatusUpdate.head); | ||
expect( | ||
githubBuildStatusDocument.fields![kGithubBuildStatusPrNumberField]!.integerValue, | ||
githubBuildStatusUpdate.pr.toString(), | ||
); | ||
expect( | ||
githubBuildStatusDocument.fields![kGithubBuildStatusStatusField]!.stringValue, | ||
githubBuildStatusUpdate.status, | ||
); | ||
expect( | ||
githubBuildStatusDocument.fields![kGithubBuildStatusUpdatesField]!.integerValue, | ||
githubBuildStatusUpdate.updates.toString(), | ||
); | ||
expect(githubBuildStatusDocument.fields![kGithubBuildStatusRepositoryField]!.stringValue, ''); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.