Skip to content

Commit

Permalink
chore: aft version-bump test suite (#5424)
Browse files Browse the repository at this point in the history
* chore: add `--skip-build-version` option

* chore: use `base-ref`/`head-ref` over env vars

* chore: add new version bump test suite

* chore: remove old version bump tests

* chore: only include first change log entry

* fix: sort change types before writing to the change log

* chore: remove non essential info from diffs

* chore: generate repo snapshot

* chore: generate diff snapshots

* chore: clean up tests and test output
  • Loading branch information
Jordan-Nelson authored Sep 11, 2024
1 parent f825f86 commit d05c017
Show file tree
Hide file tree
Showing 77 changed files with 2,365 additions and 454 deletions.
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

0 comments on commit d05c017

Please sign in to comment.