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
symbol collector CLI integration
  • Loading branch information
vaind committed Oct 25, 2023
commit 7a0c73ebf41e2809638dcadc5839185506820889
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import 'dart:io';

import 'package:archive/archive.dart';
import 'package:archive/archive_io.dart';
import 'package:file/file.dart';
import 'package:http/http.dart' as http;
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
import 'package:posix/posix.dart' as posix;

class SymbolCollectorCli {
late final Logger _log = Logger.root;
late bool _isExecutable;

// https://github.com/getsentry/symbol-collector/releases
@visibleForTesting
static const version = '1.12.0';

@visibleForTesting
late final String cli;

@visibleForTesting
static Platform platform = LocalPlatform();

SymbolCollectorCli._();

// Downloads the CLI to the given temporary directory and prepares it for use.
static Future<SymbolCollectorCli> setup(Directory tempDir) async {
late final String platformIdentifier;
final executableName = 'symbol-collector';

if (platform.isLinux) {
platformIdentifier = 'linux-x64';
} else if (platform.isMacOS) {
platformIdentifier = 'osx-x64';
} else {
throw UnsupportedError(
'Cannot run symbol-collector CLI on this platform - there\'s no binary available at this time.');
}

final self = SymbolCollectorCli._();

self._log.fine(
'Downloading symbol-collector CLI v$version for $platformIdentifier');
final zipData = await http.readBytes(Uri.parse(
'https://github.com/getsentry/symbol-collector/releases/download/$version/symbolcollector-console-$platformIdentifier.zip'));
self._log.fine(
'Download successful, received ${zipData.length} bytes; extracting the archive');

final archive = ZipDecoder().decodeBytes(zipData);
final stream = OutputStream();
archive.single.writeContent(stream);
stream.flush();

await tempDir.create();
final executableFile = await tempDir.childFile(executableName).create();
self.cli = executableFile.path;

executableFile.writeAsBytes(stream.getBytes(), flush: true);
self._log.fine(
'Symbol-collector CLI extracted to ${executableFile.path}: ${await executableFile.length()} bytes');
self._isExecutable = platform.isWindows;
return self;
}

void _makeExecutable() {
if (!_isExecutable) {
_isExecutable = true;
if (LocalPlatform().operatingSystem == platform.operatingSystem) {
if (platform.isLinux || platform.isMacOS) {
_log.fine('Making Symbol-collector CLI executable (chmod +x)');

posix.chmod(cli, '0666');
}
} else {
_log.warning(
'Symbol-collector CLI has been run with a platform that is not the current OS platform.'
'This should only be done in tests because we can\'t execute the downloaded program');
}
}
}

Future<String> getVersion() => _execute(['--version', '-h']);

Future<String> _execute(List<String> arguments) async {
var result = await Process.run(cli, arguments);
if (result.exitCode != 0) {
_log.shout(
'Symbol-collector CLI failed to execute $arguments with exit code ${result.exitCode}.');
_log.shout('Stderr: ${result.stderr}');
_log.shout('Stdout: ${result.stdout}');
}
return result.stdout;
}
}
5 changes: 5 additions & 0 deletions scripts/flutter_symbol_collector/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ environment:
sdk: ^3.0.0

dependencies:
archive: ^3.4.6
file: ^7.0.0
gcloud: ^0.8.11
github: ^9.19.0
http: ^1.1.0
logging: ^1.2.0
meta: ^1.11.0
path: ^1.8.3
platform: ^3.1.3
posix: ^5.0.0


dev_dependencies:
Expand Down
8 changes: 8 additions & 0 deletions scripts/flutter_symbol_collector/test/common.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:logging/logging.dart';

void setupLogging() {
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
print('${record.level.name}: ${record.time}: ${record.message}');
});
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter_symbol_collector/flutter_symbol_collector.dart';
import 'package:logging/logging.dart';
import 'package:test/test.dart';

import 'common.dart';

void main() {
Logger.root.level = Level.ALL;
setupLogging();
late FlutterSymbolSource sut;

setUp(() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter_symbol_collector/flutter_symbol_collector.dart';
import 'package:logging/logging.dart';
import 'package:test/test.dart';

void main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_symbol_collector/src/symbol_collector_cli.dart';
import 'package:platform/platform.dart';
import 'package:test/test.dart';

import 'common.dart';

void main() {
setupLogging();
late FileSystem fs;

setUp(() {
fs = MemoryFileSystem.test();
});

group('setup() downloads CLI on', () {
for (final platform in [Platform.macOS, Platform.linux]) {
test(platform, () async {
const path = 'temp/symbol-collector';

// make sure the file is overwritten if there's an older version
await fs
.file(path)
.create(recursive: true)
.then((file) => file.writeAsString('foo'));
expect(fs.file(path).lengthSync(), equals(3));

SymbolCollectorCli.platform = FakePlatform(operatingSystem: platform);
final sut = await SymbolCollectorCli.setup(fs.directory('temp'));
expect(sut.cli, equals(path));
expect(fs.file(path).existsSync(), isTrue);
expect(fs.file(path).lengthSync(), greaterThan(1000000));
});
}
});

test('exec() works', () async {
final sut = await SymbolCollectorCli.setup(fs.currentDirectory);
expect(sut.getVersion(), startsWith('${SymbolCollectorCli.version}+'));
}, skip: LocalPlatform().isWindows);
}