Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ceab1248
Unverified
Commit
ceab1248
authored
Dec 11, 2019
by
Kate Lovett
Committed by
GitHub
Dec 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use FlutterLocalFileComparator when user permission denied on Cirrus (#46688)
parent
36e599eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
4 deletions
+100
-4
flutter_goldens.dart
packages/flutter_goldens/lib/flutter_goldens.dart
+14
-3
flutter_goldens_test.dart
packages/flutter_goldens/test/flutter_goldens_test.dart
+86
-1
No files found.
packages/flutter_goldens/lib/flutter_goldens.dart
View file @
ceab1248
...
@@ -268,6 +268,10 @@ class FlutterSkiaGoldFileComparator extends FlutterGoldenFileComparator {
...
@@ -268,6 +268,10 @@ class FlutterSkiaGoldFileComparator extends FlutterGoldenFileComparator {
/// * [FlutterLocalFileComparator], another
/// * [FlutterLocalFileComparator], another
/// [FlutterGoldenFileComparator] that tests golden images locally on your
/// [FlutterGoldenFileComparator] that tests golden images locally on your
/// current machine.
/// current machine.
// TODO(Piinks): Better handling for first-time contributors that cannot decrypt
// the service account is needed. Gold has a new feature `goldctl imgtest check`
// that could work. There is also the previous implementation that did not use
// goldctl for this edge case. https://github.com/flutter/flutter/issues/46687
class
FlutterPreSubmitFileComparator
extends
FlutterGoldenFileComparator
{
class
FlutterPreSubmitFileComparator
extends
FlutterGoldenFileComparator
{
/// Creates a [FlutterPreSubmitFileComparator] that will test golden file
/// Creates a [FlutterPreSubmitFileComparator] that will test golden file
/// images against baselines requested from Flutter Gold.
/// images against baselines requested from Flutter Gold.
...
@@ -324,9 +328,12 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
...
@@ -324,9 +328,12 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
/// performed as pre-submit tests with Skia Gold.
/// performed as pre-submit tests with Skia Gold.
static
bool
isAvailableForEnvironment
(
Platform
platform
)
{
static
bool
isAvailableForEnvironment
(
Platform
platform
)
{
final
String
cirrusPR
=
platform
.
environment
[
'CIRRUS_PR'
]
??
''
;
final
String
cirrusPR
=
platform
.
environment
[
'CIRRUS_PR'
]
??
''
;
final
bool
hasWritePermission
=
platform
.
environment
[
'CIRRUS_USER_PERMISSION'
]
==
'admin'
||
platform
.
environment
[
'CIRRUS_USER_PERMISSION'
]
==
'write'
;
return
platform
.
environment
.
containsKey
(
'CIRRUS_CI'
)
return
platform
.
environment
.
containsKey
(
'CIRRUS_CI'
)
&&
cirrusPR
.
isNotEmpty
&&
cirrusPR
.
isNotEmpty
&&
platform
.
environment
.
containsKey
(
'GOLD_SERVICE_ACCOUNT'
);
&&
platform
.
environment
.
containsKey
(
'GOLD_SERVICE_ACCOUNT'
)
&&
hasWritePermission
;
}
}
}
}
...
@@ -392,8 +399,12 @@ class FlutterSkippingGoldenFileComparator extends FlutterGoldenFileComparator {
...
@@ -392,8 +399,12 @@ class FlutterSkippingGoldenFileComparator extends FlutterGoldenFileComparator {
/// Decides based on the current environment whether this comparator should be
/// Decides based on the current environment whether this comparator should be
/// used.
/// used.
static
bool
isAvailableForEnvironment
(
Platform
platform
)
{
static
bool
isAvailableForEnvironment
(
Platform
platform
)
{
return
platform
.
environment
.
containsKey
(
'SWARMING_TASK_ID'
)
return
(
platform
.
environment
.
containsKey
(
'SWARMING_TASK_ID'
)
||
platform
.
environment
.
containsKey
(
'CIRRUS_CI'
);
||
platform
.
environment
.
containsKey
(
'CIRRUS_CI'
))
// A service account means that this is a Gold shard. At this point, it
// means we don't have permission to use the account, so we will pass
// through to the [FlutterLocalFileComparator].
&&
!
platform
.
environment
.
containsKey
(
'GOLD_SERVICE_ACCOUNT'
);
}
}
}
}
...
...
packages/flutter_goldens/test/flutter_goldens_test.dart
View file @
ceab1248
...
@@ -399,6 +399,7 @@ void main() {
...
@@ -399,6 +399,7 @@ void main() {
'CIRRUS_CI'
:
'true'
,
'CIRRUS_CI'
:
'true'
,
'CIRRUS_PR'
:
'1234'
,
'CIRRUS_PR'
:
'1234'
,
'GOLD_SERVICE_ACCOUNT'
:
'service account...'
,
'GOLD_SERVICE_ACCOUNT'
:
'service account...'
,
'CIRRUS_USER_PERMISSION'
:
'write'
,
},
},
operatingSystem:
'macos'
operatingSystem:
'macos'
);
);
...
@@ -451,6 +452,74 @@ void main() {
...
@@ -451,6 +452,74 @@ void main() {
isFalse
,
isFalse
,
);
);
});
});
test
(
'returns true - admin privileges'
,
()
{
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'CIRRUS_CI'
:
'true'
,
'CIRRUS_PR'
:
'1234'
,
'GOLD_SERVICE_ACCOUNT'
:
'service account...'
,
'CIRRUS_USER_PERMISSION'
:
'admin'
,
},
operatingSystem:
'macos'
);
expect
(
FlutterPreSubmitFileComparator
.
isAvailableForEnvironment
(
platform
),
isTrue
,
);
});
test
(
'returns true - write privileges'
,
()
{
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'CIRRUS_CI'
:
'true'
,
'CIRRUS_PR'
:
'1234'
,
'GOLD_SERVICE_ACCOUNT'
:
'service account...'
,
'CIRRUS_USER_PERMISSION'
:
'write'
,
},
operatingSystem:
'macos'
);
expect
(
FlutterPreSubmitFileComparator
.
isAvailableForEnvironment
(
platform
),
isTrue
,
);
});
test
(
'returns false - read privileges'
,
()
{
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'CIRRUS_CI'
:
'true'
,
'CIRRUS_PR'
:
'1234'
,
'GOLD_SERVICE_ACCOUNT'
:
'service account...'
,
'CIRRUS_USER_PERMISSION'
:
'read'
,
},
operatingSystem:
'macos'
);
expect
(
FlutterPreSubmitFileComparator
.
isAvailableForEnvironment
(
platform
),
isFalse
,
);
});
test
(
'returns false - no privileges'
,
()
{
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'CIRRUS_CI'
:
'true'
,
'CIRRUS_PR'
:
'1234'
,
'GOLD_SERVICE_ACCOUNT'
:
'service account...'
,
'CIRRUS_USER_PERMISSION'
:
'none'
,
},
operatingSystem:
'macos'
);
expect
(
FlutterPreSubmitFileComparator
.
isAvailableForEnvironment
(
platform
),
isFalse
,
);
});
});
});
});
});
...
@@ -483,10 +552,26 @@ void main() {
...
@@ -483,10 +552,26 @@ void main() {
isTrue
,
isTrue
,
);
);
});
});
test
(
'returns false'
,
()
{
test
(
'returns false - no CI'
,
()
{
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
},
operatingSystem:
'macos'
);
expect
(
FlutterSkippingGoldenFileComparator
.
isAvailableForEnvironment
(
platform
),
isFalse
,
);
});
test
(
'returns false - permission pass through'
,
()
{
platform
=
FakePlatform
(
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'FLUTTER_ROOT'
:
_kFlutterRoot
,
'CIRRUS_CI'
:
'yep'
,
'GOLD_SERVICE_ACCOUNT'
:
'This is a Gold shard!'
,
},
},
operatingSystem:
'macos'
operatingSystem:
'macos'
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment