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

Add a double-check test to verify that we bump versions #1498

Merged
merged 2 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ jobs:
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- name: Run checks
run: dart pub run grinder sanity-check-before-release
run: dart pub run grinder double-check-before-release

bootstrap:
name: "Bootstrap ${{ matrix.bootstrap_version }}"
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dev_dependencies:
grinder: ^0.9.0
node_preamble: ^2.0.0
pedantic: ^1.11.0
pub_api_client: ^2.1.1
pub_semver: ^2.0.0
pubspec_parse: ^1.0.0
stream_channel: ^2.1.0
Expand Down
2 changes: 1 addition & 1 deletion tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import 'grind/synchronize.dart';

export 'grind/bazel.dart';
export 'grind/benchmark.dart';
export 'grind/double_check.dart';
export 'grind/frameworks.dart';
export 'grind/sanity_check.dart';
export 'grind/subpackages.dart';
export 'grind/synchronize.dart';

Expand Down
23 changes: 22 additions & 1 deletion tool/grind/sanity_check.dart → tool/grind/double_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import 'dart:io';

import 'package:cli_pkg/cli_pkg.dart' as pkg;
import 'package:grinder/grinder.dart';
import 'package:path/path.dart' as p;
import 'package:pub_api_client/pub_api_client.dart';
import 'package:pubspec_parse/pubspec_parse.dart';

import 'package:sass/src/utils.dart';

import 'utils.dart';

@Task('Verify that the package is in a good state to release.')
void sanityCheckBeforeRelease() {
Future<void> doubleCheckBeforeRelease() async {
var ref = environment("GITHUB_REF");
if (ref != "refs/tags/${pkg.version}") {
fail("GITHUB_REF $ref is different than pubspec version ${pkg.version}.");
Expand All @@ -27,4 +30,22 @@ void sanityCheckBeforeRelease() {
if (!File("CHANGELOG.md").readAsStringSync().contains(versionHeader)) {
fail("There's no CHANGELOG entry for ${pkg.version}.");
}

var client = PubClient();
try {
for (var dir in [
".",
...Directory("pkg").listSync().map((entry) => entry.path)
]) {
var pubspec = Pubspec.parse(File("$dir/pubspec.yaml").readAsStringSync(),
sourceUrl: p.toUri("$dir/pubspec.yaml"));

var package = await client.packageInfo(pubspec.name);
if (pubspec.version == package.latestPubspec.version) {
fail("${pubspec.name} ${pubspec.version} has already been released!");
}
}
} finally {
client.close();
}
}