Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support nested packages in firehose #277

Merged
merged 5 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
5 changes: 5 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.9.1

- Support packages nested under other packages, as long as the outer package
jakemac53 marked this conversation as resolved.
Show resolved Hide resolved
is not publishable or a pub workspace root package.
jakemac53 marked this conversation as resolved.
Show resolved Hide resolved

## 0.9.0

- Add `leaking` check to the health workflow.
Expand Down
18 changes: 10 additions & 8 deletions pkgs/firehose/lib/src/repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,18 @@ class Repository {
if (pubspecFile.existsSync()) {
var pubspec = yaml.loadYaml(pubspecFile.readAsStringSync()) as Map;
var publishTo = pubspec['publish_to'] as String?;
if (publishTo != 'none') {
if (publishTo != 'none' && !pubspec.containsKey('workspace')) {
packages.add(Package(directory, this));
// There is an assumption here that published, non-workspace packages do
// not contain nested published packages.
return;
jakemac53 marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
if (directory.existsSync()) {
for (var child in directory.listSync().whereType<Directory>()) {
var name = path.basename(child.path);
if (!name.startsWith('.')) {
_recurseAndGather(child, packages);
}
}
if (directory.existsSync()) {
for (var child in directory.listSync().whereType<Directory>()) {
var name = path.basename(child.path);
if (!name.startsWith('.')) {
_recurseAndGather(child, packages);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.9.0
version: 0.9.1
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down
51 changes: 46 additions & 5 deletions pkgs/firehose/test/repo_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@
library;

import 'dart:io';
import 'dart:isolate';

import 'package:firehose/src/github.dart';
import 'package:firehose/src/repo.dart';
import 'package:github/github.dart' show RepositorySlug;
import 'package:test/test.dart';

void main() {
group('repo', () {
late Repository packages;
late Repository packages;
late Uri packageRoot;

setUpAll(() async {
packageRoot = (await Isolate.resolvePackageUri(
Uri.parse('package:firehose/test.dart')))!
.resolve('../');
});

group('repo', () {
setUp(() {
// Tests are run in the package directory; look up two levels to get the
// repo directory.
packages = Repository(Directory.current.parent.parent);
// Look up two levels from the package directory to get the repo dir.
packages = Repository(Directory.fromUri(packageRoot.resolve('../../')));
});

test('isSinglePackageRepo', () {
Expand Down Expand Up @@ -59,4 +66,38 @@ void main() {
expect(queryParams['body'], package.changelog.describeLatestChanges);
});
});

group('pub workspace repo', () {
setUp(() {
packages = Repository(
Directory.fromUri(packageRoot.resolve('test_data/workspace_repo')));
});

test('locatePackages', () {
var result = packages.locatePackages();
expect(
result,
equals([
isA<Package>().having((p) => p.name, 'name', 'pkg_1'),
isA<Package>().having((p) => p.name, 'name', 'pkg_2'),
]));
});
});

group('repo with an unpublished root package', () {
setUp(() {
packages = Repository(Directory.fromUri(
packageRoot.resolve('test_data/root_unpublished_pkg')));
});

test('locatePackages', () {
var result = packages.locatePackages();
expect(
result,
equals([
isA<Package>().having((p) => p.name, 'name', 'pkg_1'),
isA<Package>().having((p) => p.name, 'name', 'pkg_2'),
]));
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: pkg_1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: pkg_2
2 changes: 2 additions & 0 deletions pkgs/firehose/test_data/root_unpublished_pkg/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: root
publish_to: none
2 changes: 2 additions & 0 deletions pkgs/firehose/test_data/workspace_repo/pkg_1/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: pkg_1
resolution: workspace
2 changes: 2 additions & 0 deletions pkgs/firehose/test_data/workspace_repo/pkg_2/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: pkg_2
resolution: workspace
4 changes: 4 additions & 0 deletions pkgs/firehose/test_data/workspace_repo/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: workspace
workspace:
- pkg_1
- pkg_2