Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7bfcaf9
chore: flutter symbol collector CLI tool
vaind Oct 11, 2023
d1313bd
renames
vaind Oct 12, 2023
7a0c73e
symbol collector CLI integration
vaind Oct 12, 2023
ac1c1c0
fixup getVersion()
vaind Oct 12, 2023
7218df6
collector upload
vaind Oct 12, 2023
d394181
collect platform info with symbol archive
vaind Oct 12, 2023
5e963aa
download and extract zip archives
vaind Oct 12, 2023
c4aa8a8
download via cli bin
vaind Oct 12, 2023
a7a80ea
upload via symbol-collector cli
vaind Oct 12, 2023
667c144
add symbol collector CI
vaind Oct 13, 2023
5390bcf
extract inner zip files
vaind Oct 13, 2023
2bc4ed7
test symbol collector in CI
vaind Oct 13, 2023
ed79ef4
fix tests
vaind Oct 13, 2023
ff91b35
chore: update changelog
vaind Oct 13, 2023
795e7a4
fix tests
vaind Oct 13, 2023
816ae3e
fix tests
vaind Oct 13, 2023
5170a46
upload android symbols
vaind Oct 13, 2023
caa9b62
fix duplicate upload
vaind Oct 13, 2023
4724c81
upload symbols for all of 3.13.*
vaind Oct 24, 2023
b55becb
cache previous symbol collector successful uploads
vaind Oct 24, 2023
cb298d6
fix artifacts
vaind Oct 24, 2023
57efb36
we need to use cache
vaind Oct 24, 2023
8d686cb
cron
vaind Oct 24, 2023
bdfcfdc
test
vaind Oct 24, 2023
cee0761
use artifacts
vaind Oct 24, 2023
611f636
run for all v3 flutter versions
vaind Oct 24, 2023
321198c
fixup changelog
vaind Oct 24, 2023
6834bc8
fixup changelog
vaind Oct 25, 2023
dfb8fee
refactor: move status cache to a separate file
vaind Oct 25, 2023
deca8fc
change artifact action to download from previous runs
vaind Oct 25, 2023
12f6033
fix status cache
vaind Oct 25, 2023
0dc96c3
fix status cache
vaind Oct 25, 2023
3875129
register symbol collector CLI updater
vaind Oct 25, 2023
6ba64f6
log status change
vaind Oct 25, 2023
d352c73
fix status caching
vaind Oct 25, 2023
6d163a6
fix
vaind Oct 25, 2023
b7e4719
process all flutter v3 subversions
vaind Oct 25, 2023
2edb9be
try to fix memory usage
vaind Oct 25, 2023
adf8f60
cleanup earlier
vaind Oct 25, 2023
6529c4b
roll back changes after figuring out the issue is with symbol collect…
vaind Oct 25, 2023
6f1fc8d
update symbol-collector to the latest version
vaind Oct 26, 2023
7b9fb06
rename .successful to .cache
vaind Oct 26, 2023
e7a20f3
don't use version in the status cache
vaind Oct 26, 2023
9461372
remove temp code
vaind Oct 26, 2023
986f954
run cron every hour
vaind Oct 26, 2023
9b74649
update symbol collector issue link
vaind Oct 27, 2023
5edbf3d
Merge branch 'main' into feat/flutter-symbol-upload
vaind Oct 30, 2023
0d8652b
minor fixes
vaind Oct 30, 2023
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
Prev Previous commit
Next Next commit
refactor: move status cache to a separate file
  • Loading branch information
vaind committed Oct 25, 2023
commit dfb8fee2a7a6b8b4539af28579e04c002dabccab
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import 'package:github/github.dart';
import 'package:logging/logging.dart';

const githubToken = String.fromEnvironment('GITHUB_TOKEN');
final source = FlutterSymbolSource(
githubAuth: githubToken.isEmpty
? Authentication.anonymous()
: Authentication.withToken(githubToken));
final githubAuth = githubToken.isEmpty
? Authentication.anonymous()
: Authentication.withToken(githubToken);
final source = FlutterSymbolSource(githubAuth: githubAuth);
final fs = LocalFileSystem();
final tempDir = fs.currentDirectory.childDirectory('.temp');
final successDir = fs.currentDirectory.childDirectory('.successful');
final stateCache = DirectoryStatusCache(fs.currentDirectory.childDirectory('.successful'));
late final SymbolCollectorCli collector;

void main(List<String> arguments) async {
Expand All @@ -26,7 +26,6 @@ void main(List<String> arguments) async {
final argVersion = args['version'] as String;

collector = await SymbolCollectorCli.setup(tempDir);
successDir.createSync(recursive: true);

// If a specific version was given, run just for this version.
if (argVersion.isNotEmpty &&
Expand Down Expand Up @@ -62,25 +61,22 @@ Future<void> processFlutterVerion(FlutterVersion version) async {

final archives = await source.listSymbolArchives(version);
final dir = tempDir.childDirectory(version.tagName);
final sdir = successDir.childDirectory(version.tagName.toLowerCase());
for (final archive in archives) {
// Later, we'll write create an empty file to mark this as successful.
final sFile = sdir.childFile(archive.path.toLowerCase());
if (sFile.existsSync()) {
final status = await stateCache.getStatus(archive);
if (status == SymbolArchiveStatus.success) {
Logger.root
.info('Skipping ${archive.path} - already processed successfully');
continue;
}

final archiveDir = dir.childDirectory(archive.platform.operatingSystem);
if (!await source.downloadAndExtractTo(archiveDir, archive.path)) {
continue;
}
if (!await collector.upload(archiveDir, archive.platform, version)) {
continue;
if (await source.downloadAndExtractTo(archiveDir, archive.path)) {
if (await collector.upload(archiveDir, archive.platform, version)) {
await stateCache.setStatus(archive, SymbolArchiveStatus.success);
continue;
}
}

sFile.createSync(recursive: true);
await stateCache.setStatus(archive, SymbolArchiveStatus.error);
}

if (bool.hasEnvironment('CI')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export 'src/flutter_symbol_source.dart';
export 'src/flutter_version.dart';
export 'src/symbol_collector_cli.dart';
export 'src/status_cache.dart';
56 changes: 56 additions & 0 deletions scripts/flutter_symbol_collector/lib/src/status_cache.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:file/file.dart';
import 'package:github/github.dart' as github;
import 'package:logging/logging.dart';

import 'symbol_archive.dart';

enum SymbolArchiveStatus {
/// The archive has been successfully processed.
success,

/// The archive has been processed but there was an error.
error,

/// The archive hasn't been processed yet
pending,
}

/// Stores and retrieves information about symbol processing status.
abstract class SymbolArchiveStatusCache {
Future<void> setStatus(SymbolArchive archive, SymbolArchiveStatus status);
Future<SymbolArchiveStatus> getStatus(SymbolArchive archive);
}

/// Stores information about symbol processing status in a local directory.
class DirectoryStatusCache implements SymbolArchiveStatusCache {
final Directory _dir;

DirectoryStatusCache(this._dir) {
_dir.createSync(recursive: true);
}

File _statusFile(SymbolArchive archive) =>
_dir.childFile(archive.path.toLowerCase());

@override
Future<SymbolArchiveStatus> getStatus(SymbolArchive archive) async {
final file = _statusFile(archive);
if (!await file.exists()) {
return SymbolArchiveStatus.pending;
}
return file.readAsString().then((value) {
switch (value) {
case 'success':
return SymbolArchiveStatus.success;
case 'error':
return SymbolArchiveStatus.error;
default:
throw StateError('Unknown status: $value');
}
});
}

@override
Future<void> setStatus(SymbolArchive archive, SymbolArchiveStatus status) =>
_statusFile(archive).writeAsString(status.toString());
}