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

chore: aft version-bump test suite #5424

Merged
merged 10 commits into from
Sep 11, 2024
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ packages/smithy/goldens/models/custom/** -linguist-vendored
## Genrated dart files
*.g.dart linguist-generated

## Genrated test files
**/snapshots/*.diff linguist-generated
**/repo_snapshot/** linguist-generated

## Lock files
package-lock.json linguist-generated
pnpm-lock.yaml linguist-generated
Expand Down
4 changes: 3 additions & 1 deletion packages/aft/lib/src/changelog/changelog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ abstract class Changelog implements Built<Changelog, ChangelogBuilder> {
// bug fixes/improvements.
nodes.add(Element.text('li', 'Minor bug fixes and improvements\n'));
} else {
for (final typedCommits in commitsByType.entries) {
final sortedCommitTypes =
commitsByType.entries.sortedBy<num>((entry) => entry.key.index);
for (final typedCommits in sortedCommitTypes) {
nodes.add(Element.text('h3', typedCommits.key.header));

// Transform PR #'s into links to the main repo
Expand Down
2 changes: 1 addition & 1 deletion packages/aft/lib/src/changelog/commit_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ final RegExp _trailerRegex = RegExp(r'^[^:\s]+:[^:]+$');

enum CommitTypeGroup {
breaking('Breaking Changes'),
fixes('Fixes'),
features('Features'),
fixes('Fixes'),
other('Other Changes');

const CommitTypeGroup(this.header);
Expand Down
33 changes: 22 additions & 11 deletions packages/aft/lib/src/commands/version_bump_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class VersionBumpCommand extends AmplifyCommand
'force-patch',
help: 'Forces a patch version bump',
negatable: false,
)
..addFlag(
'skip-build-version',
help: 'Skips running build version in packages that depend on '
'build_version. Intended for use in tests.',
negatable: false,
);
}

Expand Down Expand Up @@ -90,18 +96,23 @@ class VersionBumpCommand extends AmplifyCommand

final bumpedPackages = await _updateVersions();

for (final package in bumpedPackages) {
// Run build_runner for packages which generate their version number.
final needsBuildRunner = package.pubspecInfo.pubspec.devDependencies
.containsKey('build_version');
if (!needsBuildRunner) {
continue;
final skipBuildVersion =
argResults?['skip-build-version'] as bool? ?? false;

if (!skipBuildVersion) {
for (final package in bumpedPackages) {
// Run build_runner for packages which generate their version number.
final needsBuildRunner = package.pubspecInfo.pubspec.devDependencies
.containsKey('build_version');
if (!needsBuildRunner) {
continue;
}
await runBuildRunner(
package,
logger: logger,
verbose: verbose,
);
}
await runBuildRunner(
package,
logger: logger,
verbose: verbose,
);
}

logger.info('Version successfully bumped');
Expand Down
8 changes: 4 additions & 4 deletions packages/aft/lib/src/options/git_ref_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ mixin GitRefOptions on AmplifyCommand {
///
/// By default, this is the latest release tag.
String? get baseRef {
return Platform.environment['GITHUB_BASE_REF'] ??
argResults!['base-ref'] as String?;
return argResults?['base-ref'] as String? ??
Platform.environment['GITHUB_BASE_REF'];
}

/// The head reference git operations should be based on.
///
/// By default, this is the current `HEAD`.
String get headRef {
return Platform.environment['GITHUB_HEAD_REF'] ??
argResults!['head-ref'] as String? ??
return argResults?['head-ref'] as String? ??
Platform.environment['GITHUB_HEAD_REF'] ??
'HEAD';
}
}
Loading