From d644d5317122ff16d40b3da7d053953c448556f8 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 28 Nov 2024 15:19:15 +0100 Subject: [PATCH] testing --- .github/test_repos/{intl.json => repos.json} | 6 ++- .github/workflows/ecosystem_test.yaml | 12 ++--- .../workflows/ecosystem_test_internal.yaml | 6 +-- pkgs/quest/bin/quest.dart | 51 +++++++++++-------- pkgs/quest/pubspec.yaml | 2 + pkgs/quest/schema.json | 35 +++++++++++++ 6 files changed, 78 insertions(+), 34 deletions(-) rename .github/test_repos/{intl.json => repos.json} (51%) create mode 100644 pkgs/quest/schema.json diff --git a/.github/test_repos/intl.json b/.github/test_repos/repos.json similarity index 51% rename from .github/test_repos/intl.json rename to .github/test_repos/repos.json index 69642426..616587ff 100644 --- a/.github/test_repos/intl.json +++ b/.github/test_repos/repos.json @@ -1,8 +1,12 @@ { + "$schema": "../../pkgs/quest/schema.json", "https://github.com/mosuem/my_app_old_web": { "level": "analyze" }, "https://github.com/mosuem/my_app_new_web": { - "level": "test" + "level": "test", + "packages": { + "exclude": "intl4x" + } } } diff --git a/.github/workflows/ecosystem_test.yaml b/.github/workflows/ecosystem_test.yaml index 5d949dff..dddd5715 100644 --- a/.github/workflows/ecosystem_test.yaml +++ b/.github/workflows/ecosystem_test.yaml @@ -7,14 +7,6 @@ on: description: 'Path to the file containing the list of repository names' type: string required: true - package_name: - description: 'Name of the package to update' - type: string - required: true - new_version: - description: 'New version of the package' - type: string - required: true jobs: update_and_test: @@ -29,12 +21,14 @@ jobs: with: channel: main + - run: echo ${{ github.event.pull_request.labels }} + - run: dart pub get working-directory: pkgs/quest - name: Update package and test run: | - dart run pkgs/quest/bin/quest.dart ${{ inputs.package_name }} ${{ inputs.new_version }} ${{ inputs.repos_file }} + dart run pkgs/quest/bin/quest.dart ${{ inputs.repos_file }} ${{ github.event.pull_request.labels }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ecosystem_test_internal.yaml b/.github/workflows/ecosystem_test_internal.yaml index 4d562419..b5fd98e3 100644 --- a/.github/workflows/ecosystem_test_internal.yaml +++ b/.github/workflows/ecosystem_test_internal.yaml @@ -1,14 +1,12 @@ name: Ecosystem test:Internal on: - push: pull_request: - workflow_dispatch: + branches: [ main ] + types: [opened, synchronize, reopened, labeled, unlabeled] jobs: test_ecosystem: uses: ./.github/workflows/ecosystem_test.yaml with: repos_file: .github/test_repos/intl.json - package_name: intl - new_version: 0.20.0 diff --git a/pkgs/quest/bin/quest.dart b/pkgs/quest/bin/quest.dart index 47103bd2..5dc4e68e 100644 --- a/pkgs/quest/bin/quest.dart +++ b/pkgs/quest/bin/quest.dart @@ -1,17 +1,24 @@ import 'dart:convert'; import 'dart:io'; +import 'package:collection/collection.dart'; +import 'package:firehose/firehose.dart' as fire; import 'package:path/path.dart' as p; Future main(List arguments) async { - final candidatePackage = arguments.first; - final version = arguments[1]; - final repositoriesFile = arguments[2]; - final chronicles = - await Quest(candidatePackage, version, repositoriesFile).embark(); - final comment = createComment(chronicles); - await writeComment(comment); - print(chronicles); + final repositoriesFile = arguments[0]; + final labels = arguments[1].split(','); + + final packages = fire.Repository().locatePackages(); + final package = packages.firstWhereOrNull( + (package) => labels.any((label) => label == 'ecosystem-test-$package')); + if (package != null) { + final chronicles = + await Quest('', package.version!.toString(), repositoriesFile).embark(); + final comment = createComment(chronicles); + await writeComment(comment); + print(chronicles); + } } enum Level { solve, analyze, test } @@ -57,15 +64,16 @@ class Repository { static Future> listFromFile(String path) async { final s = await File(path).readAsString(); - return (jsonDecode(s) as Map).entries + return (jsonDecode(s) as Map) + .entries .map((e) => MapEntry(e.key as String, e.value as Map)) .map((e) { - return Repository( - url: e.key, - name: (e.value['name'] as String?) ?? p.basename(e.key), - level: Level.values.firstWhere((l) => l.name == e.value['level']), - ); - }); + return Repository( + url: e.key, + name: (e.value['name'] as String?) ?? p.basename(e.key), + level: Level.values.firstWhere((l) => l.name == e.value['level']), + ); + }); } @override @@ -84,11 +92,14 @@ class Quest { for (var repository in await Repository.listFromFile(repositoriesFile)) { final path = await cloneRepo(repository.url); print('Cloned $repository'); - final processResult = await Process.run('flutter', [ - 'pub', - 'deps', - '--json', - ], workingDirectory: path); + final processResult = await Process.run( + 'flutter', + [ + 'pub', + 'deps', + '--json', + ], + workingDirectory: path); final depsListResult = processResult.stdout as String; print(depsListResult); final depsJson = diff --git a/pkgs/quest/pubspec.yaml b/pkgs/quest/pubspec.yaml index 49f3df30..c6e70789 100644 --- a/pkgs/quest/pubspec.yaml +++ b/pkgs/quest/pubspec.yaml @@ -8,6 +8,8 @@ environment: # Add regular dependencies here. dependencies: + collection: ^1.19.1 + firehose: ^0.9.3 io: ^1.0.4 path: ^1.9.1 diff --git a/pkgs/quest/schema.json b/pkgs/quest/schema.json new file mode 100644 index 00000000..424371dc --- /dev/null +++ b/pkgs/quest/schema.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Repository Configuration", + "description": "Schema for repository configuration", + "type": "object", + "patternProperties": { + "^https:\\/\\/github\\.com\\/[^\\/]+\\/[^\\/]+$": { + "type": "object", + "properties": { + "level": { + "type": "string", + "description": "Level of analysis for the repository", + "enum": [ + "solve", + "analyze", + "test" + ] + }, + "packages": { + "type": "object", + "description": "Packages which are tested using this repository", + "properties": { + "exclude": { + "type": "string", + "description": "Packages to exclude from the analysis" + } + } + } + }, + "required": [ + "level" + ] + } + } +}