Skip to content

Commit

Permalink
Merge branch 'next' into feat/next/analytics_migrate_new_new
Browse files Browse the repository at this point in the history
  • Loading branch information
fjnoyp committed Jan 10, 2023
2 parents 87006ed + f7a89fa commit e285a2b
Show file tree
Hide file tree
Showing 58 changed files with 3,377 additions and 326 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Expand Up @@ -42,6 +42,7 @@ commands:
- run:
name: Install and set up aft
command: |
git submodule update --init
flutter pub global activate -spath packages/aft
aft bootstrap
activate_pana:
Expand Down
49 changes: 33 additions & 16 deletions .github/workflows/aft.yaml
@@ -1,20 +1,15 @@
# Generated with aft. To update, run: `aft generate workflows`
name: aft
on:
push:
branches:
- main
- stable
- next
paths:
- 'packages/aft/**/*.dart'
pull_request:
paths:
- 'packages/aft/**/*.dart'
- 'packages/aft/**/*.yaml'
- 'packages/aft/lib/**/*'
- 'packages/aft/test/**/*'
- '.github/workflows/dart_vm.yaml'
- '.github/workflows/dart_native.yaml'
- '.github/workflows/aft.yaml'
schedule:
- cron: "0 0 * * 0" # Every Sunday at 00:00
defaults:
Expand All @@ -24,12 +19,34 @@ permissions: read-all

jobs:
test:
uses: ./.github/workflows/dart_vm.yaml
with:
working-directory: packages/aft
native_test:
if: ${{ github.event_name == 'push' }}
needs: test
uses: ./.github/workflows/dart_native.yaml
with:
working-directory: packages/aft
name: Test
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0
with:
submodules: true

# Needed for `git` but only ever used locally.
- name: Git Config
run: |
git config --global user.email "amplify-flutter@amazon.com"
git config --global user.name "Amplify Flutter"
- name: Setup Dart
uses: dart-lang/setup-dart@196f54580e9eee2797c57e85e289339f85e6779d # main
with:
sdk: stable

- name: Get Packages
working-directory: packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd external/libgit2dart; git apply ../libgit2dart.patch )
dart pub upgrade
mkdir linux
cp external/libgit2dart/linux/*.so linux
- name: Run Tests
working-directory: packages/aft
run: dart test
6 changes: 5 additions & 1 deletion .github/workflows/dart_dart2js.yaml
Expand Up @@ -50,7 +50,11 @@ jobs:
sdk: ${{ matrix.sdk }}

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
- name: Setup Firefox
if: ${{ matrix.browser == 'firefox' }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dart_ddc.yaml
Expand Up @@ -54,7 +54,11 @@ jobs:
sdk: ${{ matrix.sdk }}

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
- name: Setup Firefox
if: ${{ matrix.browser == 'firefox' }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dart_native.yaml
Expand Up @@ -51,7 +51,11 @@ jobs:
sdk: stable

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
- name: Bootstrap
id: bootstrap
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dart_vm.yaml
Expand Up @@ -47,7 +47,11 @@ jobs:
sdk: ${{ matrix.sdk }}

- name: Setup aft
run: dart pub global activate -spath packages/aft
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
( cd packages/aft/external/libgit2dart; git reset --hard HEAD )
- name: Bootstrap
id: bootstrap
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/flutter_vm.yaml
Expand Up @@ -23,6 +23,9 @@ jobs:
- name: Git Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0

- name: Git Submodules
run: git submodule update --init

- name: Setup Flutter
uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d # 2.8.0
with:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/smoke_test.yaml
Expand Up @@ -25,7 +25,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # 3.1.0

- name: Git Submodules
run: git submodule update --init

- name: Setup Dart
uses: dart-lang/setup-dart@196f54580e9eee2797c57e85e289339f85e6779d # main
Expand All @@ -34,6 +37,8 @@ jobs:

- name: Link Packages
run: |
# Patch libgit2dart (see https://github.com/dart-lang/pub/issues/3563)
( cd packages/aft/external/libgit2dart; git apply ../libgit2dart.patch )
dart pub global activate -spath packages/aft
aft link
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -11,3 +11,6 @@
path = packages/smithy/goldens/smithy
url = https://github.com/awslabs/smithy.git
branch = main
[submodule "packages/aft/external/libgit2dart"]
path = packages/aft/external/libgit2dart
url = https://github.com/SkinnyMind/libgit2dart.git
47 changes: 46 additions & 1 deletion aft.yaml
Expand Up @@ -17,6 +17,51 @@ dependencies:
uuid: ">=3.0.6 <=3.0.7"
xml: ">=6.1.0 <=6.2.2"

# Packages to ignore in all repo operations
# Packages to ignore in all repo operations.
ignore:
- synthetic_package
- libgit2dart

# Strongly connected components which should have version bumps happen
# in unison, i.e. a version bump to one package cascades to all.
#
# By default, this happens only for minor version bumps. However, this
# can be modified on a per-component basis using the `propagate` flag.
components:
- name: Amplify Flutter
summary: amplify_flutter
packages:
- amplify_flutter
- amplify_flutter_ios
- amplify_flutter_android
- amplify_core
- amplify_datastore
- amplify_datastore_plugin_interface
- amplify_analytics_pinpoint
- amplify_api
- amplify_api_android
- amplify_api_ios
- amplify_auth_cognito
- amplify_auth_cognito_android
- amplify_auth_cognito_ios
- amplify_storage_s3
- name: Amplify Dart
summary: amplify_core
propagate: none
packages:
- amplify_auth_cognito_dart
- amplify_analytics_pinpoint_dart
- amplify_storage_s3_dart
- name: Amplify UI
packages:
- amplify_authenticator
- name: Smithy
summary: smithy
packages:
- smithy
- smithy_aws
- name: Worker Bee
summary: worker_bee
packages:
- worker_bee
- worker_bee_builder
21 changes: 21 additions & 0 deletions packages/aft/README.md
Expand Up @@ -18,3 +18,24 @@ A CLI tool for managing the Amplify Flutter repository.
- `get`: Runs `dart pub get`/`flutter pub get` for all packages
- `upgrade`: Runs `dart pub upgrade`/`flutter pub upgrade` for all packages
- `publish`: Runs `dart pub publish`/`flutter pub publish` for all packages which need publishing
- `version-bump`: Bumps version using git history

## Setup

To run some commands, `libgit2` is required and can be installed with the following commands:

```sh
$ brew install libgit2
```

```sh
$ sudo apt-get install libgit2-dev
```

To activate `aft`, run:

```sh
$ dart pub global activate -spath packages/aft
```

A full list of available commands and options can be found by running `aft --help`.
1 change: 1 addition & 0 deletions packages/aft/analysis_options.yaml
Expand Up @@ -5,3 +5,4 @@ analyzer:
public_member_api_docs: ignore
exclude:
- '**/*.g.dart'
- external/
3 changes: 2 additions & 1 deletion packages/aft/bin/aft.dart
Expand Up @@ -25,7 +25,8 @@ Future<void> main(List<String> args) async {
..addCommand(LinkCommand())
..addCommand(CleanCommand())
..addCommand(PubCommand())
..addCommand(BootstrapCommand());
..addCommand(BootstrapCommand())
..addCommand(VersionBumpCommand());
try {
await runner.run(args);
} on UsageException catch (e) {
Expand Down
36 changes: 36 additions & 0 deletions packages/aft/doc/versioning.md
@@ -0,0 +1,36 @@
# Versioning Algorithm

The `aft version-bump` command uses Git history + [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) formatting to determine a suitable next version for a package along with the required changes for depending packages.

1. Let `packages` be the set of all packages in the repo which are publishable to `pub.dev`.
2. For every package `P` in `packages`:
1. Let `component` be the component of `P`, if any.
2. Let `baseRef` be the commit of the last release of `P`.
3. Let `headRef` be the releaseable commit of `P` (defaults to `HEAD`).
4. Let `history` be the list of git commits in the range `baseRef..headRef` which affected `P`, i.e. those commits which included changes to files in `P`.
5. Let `nextVersion = currentVersion`.
6. For each `commit` in `history`:
1. If `commit` is a version bump (i.e. `chore(version)`), ignore it.
2. If `commit` is a merge commit, update dependencies based on the packages changed by the commit.
1. The thinking here is that PRs should either be squashed into a single commit or merged as a set of independent commits capped off by a merge commit. The independent commits are isolated changes which are used to update changelogs and bump versions. The merge commit is then used solely for associating previous commits and updating constraints accordingly.
3. If `commit` is a breaking change (i.e. `feat(auth)!`), set `bumpType = breaking`.
1. else if `commit`'s type is `feat`, set `bumpType = nonBreaking`.
2. else, set `bumpType = patch`.
4. If `commit` is a noteworthy change (scope is one of `feat`, `fix`, `bug`, `perf`, or `revert` or it's a breaking change), set `includeInChangelog = true`.
5. Let `proposedVersion = currentVersion.bump(bumpType)`
6. Let `nextVersion = max(nextVersion, proposedVersion)`
7. If `nextVersion > currentVersion`:
1. Update `pubspec.yaml`, set `version = nextVersion`
2. If `includeInChangelog`:
1. Update `CHANGELOG.md` with an entry for `commit`.
3. If `bumpType == breaking`:
1. For every package `Q` which directly depends on `P`:
1. Bump the version of `Q` with `bumpType = patch` and `includeInChangelog = false`.
2. Update `Q`'s constraint on `P`.
4. If `bumpType == breaking` or `bumpType == nonBreaking` and `component != null`:
1. For every package `Q` in `component`:
1. Bump the version of `Q` with the same `bumpType` as `P` and `includeInChangelog = false`.
8. If `component` has a summary package:
1. Update `CHANGELOG.md` in the summary package with `commit`.
9. For every package `Q` which was affected by `commit`:
1. Update `Q`'s constraint on `P` using `nextVersion`.
1 change: 1 addition & 0 deletions packages/aft/external/libgit2dart
Submodule libgit2dart added at 34d492
29 changes: 29 additions & 0 deletions packages/aft/external/libgit2dart.patch
@@ -0,0 +1,29 @@
diff --git a/pubspec.yaml b/pubspec.yaml
index 5acda72..2831e58 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -8,7 +8,6 @@ homepage: https://github.com/SkinnyMind/libgit2dart

environment:
sdk: ">=2.18.0 <3.0.0"
- flutter: ">=3.3.0"

dependencies:
args: ^2.3.0
@@ -23,16 +22,6 @@ dev_dependencies:
lints: ^2.0.0
test: ^1.20.0

-flutter:
- plugin:
- platforms:
- linux:
- pluginClass: Libgit2dartPlugin
- macos:
- pluginClass: Libgit2dartPlugin
- windows:
- pluginClass: Libgit2dartPlugin
-
ffigen:
output: "lib/src/bindings/libgit2_bindings.dart"
headers:
1 change: 1 addition & 0 deletions packages/aft/lib/aft.dart
Expand Up @@ -12,6 +12,7 @@ export 'src/commands/link_command.dart';
export 'src/commands/list_packages_command.dart';
export 'src/commands/pub_command.dart';
export 'src/commands/publish_command.dart';
export 'src/commands/version_bump_command.dart';
export 'src/models.dart';
export 'src/pub/pub_runner.dart';
export 'src/util.dart';

0 comments on commit e285a2b

Please sign in to comment.