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
e76ad85e
Unverified
Commit
e76ad85e
authored
Jan 08, 2022
by
Greg Spencer
Committed by
GitHub
Jan 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Output Dart SDK version in published metadata (#96302)
parent
065c0fea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
27 deletions
+65
-27
prepare_package.dart
dev/bots/prepare_package.dart
+43
-21
prepare_package_test.dart
dev/bots/test/prepare_package_test.dart
+22
-6
No files found.
dev/bots/prepare_package.dart
View file @
e76ad85e
...
@@ -24,6 +24,8 @@ const String gsBase = 'gs://flutter_infra_release';
...
@@ -24,6 +24,8 @@ const String gsBase = 'gs://flutter_infra_release';
const
String
gsReleaseFolder
=
'
$gsBase$releaseFolder
'
;
const
String
gsReleaseFolder
=
'
$gsBase$releaseFolder
'
;
const
String
baseUrl
=
'https://storage.googleapis.com/flutter_infra_release'
;
const
String
baseUrl
=
'https://storage.googleapis.com/flutter_infra_release'
;
const
int
shortCacheSeconds
=
60
;
const
int
shortCacheSeconds
=
60
;
const
String
frameworkVersionTag
=
'frameworkVersionFromGit'
;
const
String
dartVersionTag
=
'dartSdkVersion'
;
/// Exception class for when a process fails to run, so we can catch
/// Exception class for when a process fails to run, so we can catch
/// it and provide something more readable than a stack trace.
/// it and provide something more readable than a stack trace.
...
@@ -251,7 +253,7 @@ class ArchiveCreator {
...
@@ -251,7 +253,7 @@ class ArchiveCreator {
final
HttpReader
httpReader
;
final
HttpReader
httpReader
;
late
File
_outputFile
;
late
File
_outputFile
;
late
String
_version
;
final
Map
<
String
,
String
>
_version
=
<
String
,
String
>{}
;
late
String
_flutter
;
late
String
_flutter
;
/// Get the name of the channel as a string.
/// Get the name of the channel as a string.
...
@@ -269,21 +271,24 @@ class ArchiveCreator {
...
@@ -269,21 +271,24 @@ class ArchiveCreator {
// unpacking it!) So, we use .zip for Mac, and the files are about
// unpacking it!) So, we use .zip for Mac, and the files are about
// 220MB larger than they need to be. :-(
// 220MB larger than they need to be. :-(
final
String
suffix
=
platform
.
isLinux
?
'tar.xz'
:
'zip'
;
final
String
suffix
=
platform
.
isLinux
?
'tar.xz'
:
'zip'
;
return
'flutter_
${os}
_
$
_version
-
$branchName
.
$suffix
'
;
return
'flutter_
${os}
_
$
{_version[frameworkVersionTag]}
-
$branchName
.
$suffix
'
;
}
}
/// Checks out the flutter repo and prepares it for other operations.
/// Checks out the flutter repo and prepares it for other operations.
///
///
/// Returns the version for this release, as obtained from the git tags.
/// Returns the version for this release as obtained from the git tags, and
Future
<
String
>
initializeRepo
()
async
{
/// the dart version as obtained from `flutter --version`.
Future
<
Map
<
String
,
String
>>
initializeRepo
()
async
{
await
_checkoutFlutter
();
await
_checkoutFlutter
();
_version
=
await
_getVersion
();
if
(
_version
.
isEmpty
)
{
_version
.
addAll
(
await
_getVersion
());
}
return
_version
;
return
_version
;
}
}
/// Performs all of the steps needed to create an archive.
/// Performs all of the steps needed to create an archive.
Future
<
File
>
createArchive
()
async
{
Future
<
File
>
createArchive
()
async
{
assert
(
_version
!=
null
,
'Must run initializeRepo before createArchive'
);
assert
(
_version
.
isNotEmpty
,
'Must run initializeRepo before createArchive'
);
_outputFile
=
File
(
path
.
join
(
outputDir
.
absolute
.
path
,
_archiveName
));
_outputFile
=
File
(
path
.
join
(
outputDir
.
absolute
.
path
,
_archiveName
));
await
_installMinGitIfNeeded
();
await
_installMinGitIfNeeded
();
await
_populateCaches
();
await
_populateCaches
();
...
@@ -328,8 +333,8 @@ class ArchiveCreator {
...
@@ -328,8 +333,8 @@ class ArchiveCreator {
}
}
}
}
/// Returns the version
number
of this release, according the to tags in the
/// Returns the version
map
of this release, according the to tags in the
/// repo.
/// repo
and the output of `flutter --version --machine`
.
///
///
/// This looks for the tag attached to [revision] and, if it doesn't find one,
/// This looks for the tag attached to [revision] and, if it doesn't find one,
/// git will give an error.
/// git will give an error.
...
@@ -337,10 +342,15 @@ class ArchiveCreator {
...
@@ -337,10 +342,15 @@ class ArchiveCreator {
/// If [strict] is true, the exact [revision] must be tagged to return the
/// If [strict] is true, the exact [revision] must be tagged to return the
/// version. If [strict] is not true, will look backwards in time starting at
/// version. If [strict] is not true, will look backwards in time starting at
/// [revision] to find the most recent version tag.
/// [revision] to find the most recent version tag.
Future
<
String
>
_getVersion
()
async
{
///
/// The version found as a git tag is added to the information given by
/// `flutter --version --machine` with the `frameworkVersionFromGit` tag, and
/// returned.
Future
<
Map
<
String
,
String
>>
_getVersion
()
async
{
String
gitVersion
;
if
(
strict
)
{
if
(
strict
)
{
try
{
try
{
return
_runGit
(<
String
>[
'describe'
,
'--tags'
,
'--exact-match'
,
revision
]);
gitVersion
=
await
_runGit
(<
String
>[
'describe'
,
'--tags'
,
'--exact-match'
,
revision
]);
}
on
PreparePackageException
catch
(
exception
)
{
}
on
PreparePackageException
catch
(
exception
)
{
throw
PreparePackageException
(
throw
PreparePackageException
(
'Git error when checking for a version tag attached to revision
$revision
.
\n
'
'Git error when checking for a version tag attached to revision
$revision
.
\n
'
...
@@ -349,8 +359,18 @@ class ArchiveCreator {
...
@@ -349,8 +359,18 @@ class ArchiveCreator {
);
);
}
}
}
else
{
}
else
{
return
_runGit
(<
String
>[
'describe'
,
'--tags'
,
'--abbrev=0'
,
revision
]);
gitVersion
=
await
_runGit
(<
String
>[
'describe'
,
'--tags'
,
'--abbrev=0'
,
revision
]);
}
}
// Run flutter command twice, once to make sure the flutter command is built
// and ready (and thus won't output any junk on stdout the second time), and
// once to capture theJSON output. The second run should be fast.
await
_runFlutter
(<
String
>[
'--version'
,
'--machine'
]);
final
String
versionJson
=
await
_runFlutter
(<
String
>[
'--version'
,
'--machine'
]);
final
Map
<
String
,
String
>
versionMap
=
<
String
,
String
>{};
final
Map
<
String
,
dynamic
>
result
=
json
.
decode
(
versionJson
)
as
Map
<
String
,
dynamic
>;
result
.
forEach
((
String
key
,
dynamic
value
)
=>
versionMap
[
key
]
=
value
.
toString
());
versionMap
[
frameworkVersionTag
]
=
gitVersion
;
return
versionMap
;
}
}
/// Clone the Flutter repo and make sure that the git environment is sane
/// Clone the Flutter repo and make sure that the git environment is sane
...
@@ -546,7 +566,7 @@ class ArchivePublisher {
...
@@ -546,7 +566,7 @@ class ArchivePublisher {
final
String
metadataGsPath
;
final
String
metadataGsPath
;
final
Branch
branch
;
final
Branch
branch
;
final
String
revision
;
final
String
revision
;
final
String
version
;
final
Map
<
String
,
String
>
version
;
final
Directory
tempDir
;
final
Directory
tempDir
;
final
File
outputFile
;
final
File
outputFile
;
final
ProcessRunner
_processRunner
;
final
ProcessRunner
_processRunner
;
...
@@ -601,7 +621,8 @@ class ArchivePublisher {
...
@@ -601,7 +621,8 @@ class ArchivePublisher {
final
Map
<
String
,
dynamic
>
newEntry
=
<
String
,
dynamic
>{};
final
Map
<
String
,
dynamic
>
newEntry
=
<
String
,
dynamic
>{};
newEntry
[
'hash'
]
=
revision
;
newEntry
[
'hash'
]
=
revision
;
newEntry
[
'channel'
]
=
branchName
;
newEntry
[
'channel'
]
=
branchName
;
newEntry
[
'version'
]
=
version
;
newEntry
[
'version'
]
=
version
[
frameworkVersionTag
];
newEntry
[
'dart_sdk_version'
]
=
version
[
dartVersionTag
];
newEntry
[
'release_date'
]
=
DateTime
.
now
().
toUtc
().
toIso8601String
();
newEntry
[
'release_date'
]
=
DateTime
.
now
().
toUtc
().
toIso8601String
();
newEntry
[
'archive'
]
=
destinationArchivePath
;
newEntry
[
'archive'
]
=
destinationArchivePath
;
newEntry
[
'sha256'
]
=
await
_getChecksum
(
outputFile
);
newEntry
[
'sha256'
]
=
await
_getChecksum
(
outputFile
);
...
@@ -630,24 +651,25 @@ class ArchivePublisher {
...
@@ -630,24 +651,25 @@ class ArchivePublisher {
path
.
join
(
tempDir
.
absolute
.
path
,
getMetadataFilename
(
platform
)),
path
.
join
(
tempDir
.
absolute
.
path
,
getMetadataFilename
(
platform
)),
);
);
await
_runGsUtil
(<
String
>[
'cp'
,
gsPath
,
metadataFile
.
absolute
.
path
]);
await
_runGsUtil
(<
String
>[
'cp'
,
gsPath
,
metadataFile
.
absolute
.
path
]);
Map
<
String
,
dynamic
>
jsonData
=
<
String
,
dynamic
>{};
if
(!
dryRun
)
{
if
(!
dryRun
)
{
final
String
currentMetadata
=
metadataFile
.
readAsStringSync
();
final
String
currentMetadata
=
metadataFile
.
readAsStringSync
();
if
(
currentMetadata
.
isEmpty
)
{
if
(
currentMetadata
.
isEmpty
)
{
throw
PreparePackageException
(
'Empty metadata received from server'
);
throw
PreparePackageException
(
'Empty metadata received from server'
);
}
}
Map
<
String
,
dynamic
>
jsonData
;
try
{
try
{
jsonData
=
json
.
decode
(
currentMetadata
)
as
Map
<
String
,
dynamic
>;
jsonData
=
json
.
decode
(
currentMetadata
)
as
Map
<
String
,
dynamic
>;
}
on
FormatException
catch
(
e
)
{
}
on
FormatException
catch
(
e
)
{
throw
PreparePackageException
(
'Unable to parse JSON metadata received from cloud:
$e
'
);
throw
PreparePackageException
(
'Unable to parse JSON metadata received from cloud:
$e
'
);
}
}
}
// Run _addRelease, even on a dry run, so we can inspect the metadata on a
// dry run. On a dry run, the only thing in the metadata file be the new
// release.
jsonData
=
await
_addRelease
(
jsonData
);
jsonData
=
await
_addRelease
(
jsonData
);
const
JsonEncoder
encoder
=
JsonEncoder
.
withIndent
(
' '
);
const
JsonEncoder
encoder
=
JsonEncoder
.
withIndent
(
' '
);
metadataFile
.
writeAsStringSync
(
encoder
.
convert
(
jsonData
));
metadataFile
.
writeAsStringSync
(
encoder
.
convert
(
jsonData
));
}
await
_cloudCopy
(
await
_cloudCopy
(
src:
metadataFile
.
absolute
.
path
,
src:
metadataFile
.
absolute
.
path
,
dest:
gsPath
,
dest:
gsPath
,
...
@@ -832,7 +854,7 @@ Future<void> main(List<String> rawArguments) async {
...
@@ -832,7 +854,7 @@ Future<void> main(List<String> rawArguments) async {
int
exitCode
=
0
;
int
exitCode
=
0
;
late
String
message
;
late
String
message
;
try
{
try
{
final
String
version
=
await
creator
.
initializeRepo
();
final
Map
<
String
,
String
>
version
=
await
creator
.
initializeRepo
();
final
File
outputFile
=
await
creator
.
createArchive
();
final
File
outputFile
=
await
creator
.
createArchive
();
if
(
parsedArguments
[
'publish'
]
as
bool
)
{
if
(
parsedArguments
[
'publish'
]
as
bool
)
{
final
ArchivePublisher
publisher
=
ArchivePublisher
(
final
ArchivePublisher
publisher
=
ArchivePublisher
(
...
...
dev/bots/test/prepare_package_test.dart
View file @
e76ad85e
...
@@ -7,7 +7,7 @@ import 'dart:io' hide Platform;
...
@@ -7,7 +7,7 @@ import 'dart:io' hide Platform;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'package:path/path.dart'
as
path
;
import
'package:path/path.dart'
as
path
;
import
'package:platform/platform.dart'
show
FakePlatform
;
import
'package:platform/platform.dart'
show
FakePlatform
,
Platform
;
import
'../../../packages/flutter_tools/test/src/fake_process_manager.dart'
;
import
'../../../packages/flutter_tools/test/src/fake_process_manager.dart'
;
import
'../prepare_package.dart'
;
import
'../prepare_package.dart'
;
...
@@ -34,7 +34,7 @@ void main() {
...
@@ -34,7 +34,7 @@ void main() {
)),
)),
);
);
});
});
for
(
final
String
platformName
in
<
String
>[
'macos'
,
'linux'
,
'windows'
])
{
for
(
final
String
platformName
in
<
String
>[
Platform
.
macOS
,
Platform
.
linux
,
Platform
.
windows
])
{
final
FakePlatform
platform
=
FakePlatform
(
final
FakePlatform
platform
=
FakePlatform
(
operatingSystem:
platformName
,
operatingSystem:
platformName
,
environment:
<
String
,
String
>{
environment:
<
String
,
String
>{
...
@@ -123,6 +123,10 @@ void main() {
...
@@ -123,6 +123,10 @@ void main() {
'git reset --hard
$testRef
'
:
null
,
'git reset --hard
$testRef
'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git describe --tags --exact-match
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'git describe --tags --exact-match
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'
$flutter
--version --machine'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
],
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
update-packages'
:
null
,
'
$flutter
update-packages'
:
null
,
...
@@ -152,6 +156,10 @@ void main() {
...
@@ -152,6 +156,10 @@ void main() {
'git reset --hard
$testRef
'
:
null
,
'git reset --hard
$testRef
'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git describe --tags --exact-match
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'git describe --tags --exact-match
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'
$flutter
--version --machine'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
],
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
update-packages'
:
null
,
'
$flutter
update-packages'
:
null
,
...
@@ -202,6 +210,10 @@ void main() {
...
@@ -202,6 +210,10 @@ void main() {
'git reset --hard
$testRef
'
:
null
,
'git reset --hard
$testRef
'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git describe --tags --abbrev=0
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'git describe --tags --abbrev=0
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'
$flutter
--version --machine'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
],
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
update-packages'
:
null
,
'
$flutter
update-packages'
:
null
,
...
@@ -244,6 +256,10 @@ void main() {
...
@@ -244,6 +256,10 @@ void main() {
'git reset --hard
$testRef
'
:
null
,
'git reset --hard
$testRef
'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git remote set-url origin https://github.com/flutter/flutter.git'
:
null
,
'git describe --tags --exact-match
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'git describe --tags --exact-match
$testRef
'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'v1.2.3'
,
''
)],
'
$flutter
--version --machine'
:
<
ProcessResult
>[
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
ProcessResult
(
0
,
0
,
'{"dartSdkVersion": "3.2.1"}'
,
''
),
],
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
if
(
platform
.
isWindows
)
'7za x
${path.join(tempDir.path, 'mingit.zip')}
'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
doctor'
:
null
,
'
$flutter
update-packages'
:
null
,
'
$flutter
update-packages'
:
null
,
...
@@ -362,7 +378,7 @@ void main() {
...
@@ -362,7 +378,7 @@ void main() {
tempDir
,
tempDir
,
testRef
,
testRef
,
Branch
.
stable
,
Branch
.
stable
,
'v1.2.3'
,
<
String
,
String
>{
'frameworkVersionFromGit'
:
'v1.2.3'
,
'dartSdkVersion'
:
'3.2.1'
}
,
outputFile
,
outputFile
,
false
,
false
,
processManager:
processManager
,
processManager:
processManager
,
...
@@ -458,7 +474,7 @@ void main() {
...
@@ -458,7 +474,7 @@ void main() {
tempDir
,
tempDir
,
testRef
,
testRef
,
Branch
.
stable
,
Branch
.
stable
,
'v1.2.3'
,
<
String
,
String
>{
'frameworkVersionFromGit'
:
'v1.2.3'
,
'dartSdkVersion'
:
'3.2.1'
}
,
outputFile
,
outputFile
,
false
,
false
,
processManager:
processManager
,
processManager:
processManager
,
...
@@ -482,7 +498,7 @@ void main() {
...
@@ -482,7 +498,7 @@ void main() {
tempDir
,
tempDir
,
testRef
,
testRef
,
Branch
.
stable
,
Branch
.
stable
,
'v1.2.3'
,
<
String
,
String
>{
'frameworkVersionFromGit'
:
'v1.2.3'
,
'dartSdkVersion'
:
'3.2.1'
}
,
outputFile
,
outputFile
,
false
,
false
,
processManager:
processManager
,
processManager:
processManager
,
...
@@ -504,7 +520,7 @@ void main() {
...
@@ -504,7 +520,7 @@ void main() {
tempDir
,
tempDir
,
testRef
,
testRef
,
Branch
.
stable
,
Branch
.
stable
,
'v1.2.3'
,
<
String
,
String
>{
'frameworkVersionFromGit'
:
'v1.2.3'
,
'dartSdkVersion'
:
'3.2.1'
}
,
outputFile
,
outputFile
,
false
,
false
,
processManager:
processManager
,
processManager:
processManager
,
...
...
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