Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Nov 28, 2024
1 parent 8d1c5be commit d644d53
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
12 changes: 3 additions & 9 deletions .github/workflows/ecosystem_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}

Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/ecosystem_test_internal.yaml
Original file line number Diff line number Diff line change
@@ -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
51 changes: 31 additions & 20 deletions pkgs/quest/bin/quest.dart
Original file line number Diff line number Diff line change
@@ -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<void> main(List<String> 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 }
Expand Down Expand Up @@ -57,15 +64,16 @@ class Repository {

static Future<Iterable<Repository>> 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
Expand All @@ -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 =
Expand Down
2 changes: 2 additions & 0 deletions pkgs/quest/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 35 additions & 0 deletions pkgs/quest/schema.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}

0 comments on commit d644d53

Please sign in to comment.