Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
8376905
chore(ci): add api analysis for each category and core
Sep 20, 2024
d7b069e
initial generat_api_report_command
ekjotmultani Feb 27, 2025
4ab729e
introduced generate api report command and github actions for checkin…
ekjotmultani Jun 3, 2025
f5f5157
changed third party job in action to github native
ekjotmultani Jun 3, 2025
7af0df4
updated setup flutter step of workflow to match other workflows on th…
ekjotmultani Jun 3, 2025
de740a6
removed cd into packages/aft as the generate api-report command works…
ekjotmultani Jun 3, 2025
3657544
properly running command from the root of the repo
ekjotmultani Jun 3, 2025
5c4bf2e
included the newly updated api reports!
ekjotmultani Jun 3, 2025
856e0ec
updated command to ingore dependencies to example apps
ekjotmultani Jun 3, 2025
81a8c58
Revert "updated command to ingore dependencies to example apps"
ekjotmultani Jun 3, 2025
19560af
simplified pubspecs of packages in the generate api report command
ekjotmultani Jun 3, 2025
e743395
further changes to dependency check logic
ekjotmultani Jun 3, 2025
2302851
include aft bootstrap in workflow to properly handle dependencies wit…
ekjotmultani Jun 4, 2025
8c2c649
updated command to run the super constructor
ekjotmultani Jun 4, 2025
5a88d8d
printing git diff
ekjotmultani Jun 5, 2025
1617282
updated check workflow to not just run git diff on the change report …
ekjotmultani Jun 5, 2025
e638e7e
same as last commit but for checking the api change report as well
ekjotmultani Jun 5, 2025
b6e4d0a
chore(ci): add api analysis for each category and core
Sep 20, 2024
c2427e4
initial generat_api_report_command
ekjotmultani Feb 27, 2025
0c31d5a
introduced generate api report command and github actions for checkin…
ekjotmultani Jun 3, 2025
096743d
changed third party job in action to github native
ekjotmultani Jun 3, 2025
bbea081
updated setup flutter step of workflow to match other workflows on th…
ekjotmultani Jun 3, 2025
23bb51a
removed cd into packages/aft as the generate api-report command works…
ekjotmultani Jun 3, 2025
f4a51e8
properly running command from the root of the repo
ekjotmultani Jun 3, 2025
a07b5e5
included the newly updated api reports!
ekjotmultani Jun 3, 2025
d136089
updated command to ingore dependencies to example apps
ekjotmultani Jun 3, 2025
3de5798
Revert "updated command to ingore dependencies to example apps"
ekjotmultani Jun 3, 2025
a032811
simplified pubspecs of packages in the generate api report command
ekjotmultani Jun 3, 2025
66f0360
further changes to dependency check logic
ekjotmultani Jun 3, 2025
35519b8
include aft bootstrap in workflow to properly handle dependencies wit…
ekjotmultani Jun 4, 2025
76aa8d0
updated command to run the super constructor
ekjotmultani Jun 4, 2025
aae8c16
printing git diff
ekjotmultani Jun 5, 2025
cb5db93
updated check workflow to not just run git diff on the change report …
ekjotmultani Jun 5, 2025
9feb633
same as last commit but for checking the api change report as well
ekjotmultani Jun 5, 2025
08e331c
Merge branch 'chore/api-analysis' of https://github.com/aws-amplify/a…
ekjotmultani Jun 6, 2025
8714cad
check is API change comment has already been commented on a PR to avo…
ekjotmultani Jun 20, 2025
69e32b4
put api.json files into a seperate folder under aft, checking for cha…
ekjotmultani Jun 20, 2025
cabdb7e
updated action to only show diff if there is actually a change
ekjotmultani Jun 20, 2025
92cc0c0
leave metadata out of api.json
ekjotmultani Jun 23, 2025
e28b916
updated json to remove local path references
ekjotmultani Jun 23, 2025
d87f9f6
Merge branch 'main' into chore/api-analysis
ekjotmultani Jun 23, 2025
571a333
added option to filter packages on the generate command, updated flut…
ekjotmultani Jun 23, 2025
e0d6c45
Merge branch 'chore/api-analysis' of https://github.com/aws-amplify/a…
ekjotmultani Jun 23, 2025
a8ae912
changed .yml extension to .yaml for consistency
ekjotmultani Jun 23, 2025
09ce37b
sorting json to check if local is consistent with actions
ekjotmultani Jun 23, 2025
04d86d4
reverted to output whole diff for investigation
ekjotmultani Jun 23, 2025
d00b4b3
updated api reports with sorted keys
ekjotmultani Jun 23, 2025
f1b98ad
added sorting one level down in the generated json files to ensure co…
ekjotmultani Jun 23, 2025
5fd2b77
removed unnecessary sorting of packages
ekjotmultani Jun 23, 2025
1900e6e
reverted last change
ekjotmultani Jun 24, 2025
e9dfce5
sorted executable declerations block
ekjotmultani Jun 25, 2025
586c497
removed sorting from generate command, introduced sorting to the work…
ekjotmultani Jun 25, 2025
f1068cf
updated comparison logic in workflow
ekjotmultani Jun 25, 2025
9edaff9
further updates to comparison logic
ekjotmultani Jun 25, 2025
52a47f2
deleted old api reports and added full diff logging
ekjotmultani Jun 26, 2025
9caf87a
Merge branch 'main' of https://github.com/aws-amplify/amplify-flutter…
ekjotmultani Jun 26, 2025
c2eadf8
merged main and updated api report for aws_common
ekjotmultani Jun 26, 2025
8e62dbf
updated action to not fail if diff detects changes
ekjotmultani Jun 26, 2025
0792aae
used global options for selecting packages, used pubspec parse packag…
ekjotmultani Jul 1, 2025
767a5e8
Merge branch 'main' into chore/api-analysis
ekjotmultani Jul 1, 2025
331bdab
updated core package to reflect latest changes to main
ekjotmultani Jul 1, 2025
4005d92
regenerated core api json file to reflect latest changes
ekjotmultani Jul 1, 2025
23f9645
updated command to sort API surfaces by their interfaces, so that we …
ekjotmultani Jul 2, 2025
532097f
Merge branch 'main' into chore/api-analysis
ekjotmultani Jul 2, 2025
995cefd
updated command to use symlinks to a recreation of a package without …
ekjotmultani Jul 7, 2025
adf51a9
Merge branch 'chore/api-analysis' of https://github.com/aws-amplify/a…
ekjotmultani Jul 7, 2025
13e61b6
removed sorting from check action and updated aft readme to include u…
ekjotmultani Jul 7, 2025
5228b43
updated sorting
ekjotmultani Jul 8, 2025
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
78 changes: 78 additions & 0 deletions .github/workflows/api-report-approval.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: API Report Approval

on:
pull_request:
branches:
- main
paths:
- 'packages/aft/api_reports/*.api.json'

jobs:
label-api-changes:
name: Label API Changes
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check for API changes
id: check-api-changes
run: |
# Check for changes in API JSON files
API_JSON_CHANGES=$(git diff --name-only origin/main...HEAD | grep -E 'packages/aft/api_reports/.*\.api\.json' || true)

if [[ -n "$API_JSON_CHANGES" ]]; then
echo "API_CHANGES_DETECTED=true" >> $GITHUB_ENV
echo "API changes detected in the following files:"
echo "$API_JSON_CHANGES"
else
echo "API_CHANGES_DETECTED=false" >> $GITHUB_ENV
echo "No API changes detected."
fi

- name: Add API changes label
if: env.API_CHANGES_DETECTED == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['api-changes']
})

- name: Comment on PR
if: env.API_CHANGES_DETECTED == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Check if we already commented about API changes
const commentMarker = '⚠️ This PR contains API changes';
const { data: comments } = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});

// Look for an existing comment with our marker
const apiChangeComment = comments.find(comment =>
comment.body.includes(commentMarker) &&
comment.user.login === 'github-actions[bot]'
);

// Only create a comment if we haven't already
if (!apiChangeComment) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ This PR contains API changes and requires careful review. Please ensure these changes are intentional and backward compatible where possible.'
});
} else {
console.log('API changes comment already exists, skipping comment creation');
}
115 changes: 115 additions & 0 deletions .github/workflows/api-report-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: API Report Check

on:
pull_request:
branches:
- main
paths:
- 'packages/**/*.dart'
- 'packages/**/pubspec.yaml'
- '!packages/**/example/**'
- '!packages/**/test/**'

jobs:
check-api-reports:
name: Check API Reports
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
cache: true
channel: 'stable'
flutter-version: '3.32.4'

- name: Setup aft
run: flutter pub global activate -spath packages/aft

- name: Bootstrap
id: bootstrap
timeout-minutes: 20
run: aft bootstrap --fail-fast --include=aft --verbose

- name: Install dart_apitool
run: flutter pub global activate dart_apitool

- name: Generate API reports
run: aft generate api-report

- name: Check for changes in API reports
id: check-changes
run: |
# Debug: Print git status
echo "=== DEBUG: Git status ==="
git status --porcelain

# Check API JSON files for changes
API_JSON_CHANGES=$(git status --porcelain | grep 'packages/aft/api_reports/.*\.api\.json' || true)

if [[ -n "$API_JSON_CHANGES" ]]; then
echo "API report files have changes. Checking if they are actual API changes..."
git diff --name-only | grep -E 'packages/aft/api_reports/.*\.api\.json'

ACTUAL_API_CHANGES=false

# Compare API interfaces using sets instead of text diff
# We're comparing the PR's committed API reports vs freshly generated ones
for file in $(git diff --name-only | grep -E 'packages/aft/api_reports/.*\.api\.json'); do
echo "=== Checking API changes in: $file ==="

# Get the version from the PR (what developer committed)
git show HEAD:"$file" | jq -r '.interfaceDeclarations[] | tostring' > /tmp/pr_interfaces.txt 2>/dev/null || touch /tmp/pr_interfaces.txt

# Get the freshly generated version (what CI just created)
jq -r '.interfaceDeclarations[] | tostring' "$file" > /tmp/generated_interfaces.txt

# Compare the interface sets
if ! cmp -s /tmp/pr_interfaces.txt /tmp/generated_interfaces.txt; then
echo "=== ACTUAL API CHANGES DETECTED in: $file ==="
echo "The API report in your PR doesn't match the current code. Please run 'aft generate api-report' and commit the changes."
echo "Full diff for debugging:"
git diff "$file"
ACTUAL_API_CHANGES=true
else
echo "API report is up-to-date for: $file"
fi

rm -f /tmp/pr_interfaces.txt /tmp/generated_interfaces.txt
done

if [[ "$ACTUAL_API_CHANGES" == "true" ]]; then
echo "ERROR: API report files are not up-to-date. Please run 'aft generate api-report' and commit the changes."
exit 1
else
echo "All API reports are up-to-date (detected only ordering differences)."
fi
else
echo "API report files are up-to-date."
fi

- name: Check if API reports are included in PR
run: |
# Get the list of changed files in the PR
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)

# Check if any Dart files were modified
DART_FILES=$(echo "$CHANGED_FILES" | grep -E '\.dart$' || true)
if [[ -z "$DART_FILES" ]]; then
echo "No Dart files were modified, skipping API report check."
exit 0
fi

# Check if API report files are included
API_REPORTS=$(echo "$CHANGED_FILES" | grep -E 'packages/aft/api_reports/.*\.api\.json' || true)
if [[ -z "$API_REPORTS" ]]; then
echo "Error: API report files are not included in this PR."
echo "Please run 'aft generate api-report' and commit the changes."
exit 1
fi

echo "API report files are included in the PR."
11 changes: 11 additions & 0 deletions packages/aft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ A CLI tool for managing the Amplify Flutter repository.
- `exec`: Execute a command in all repo packages
- `generate`: Generates various repo items
- `workflows`: Generates GitHub actions workflows for all packages in the repo
- `api-report`: Generates API reports for all packages (run before every PR)
- `link`: Links all packages together using `pubspec_overrides.yaml`
- `list`: Lists all packages in the repo
- `publish`: Runs `dart pub publish`/`flutter pub publish` for all packages which need publishing
Expand Down Expand Up @@ -133,3 +134,13 @@ Currently, a Map with the following shape is available for querying:
```

The script passed to `run` is templated each time it is run with the current package. So when using `{{ package.name }}` in a script, for example, it will always reference the package currently running the script.

## API Reports

Before submitting a pull request that modifies Dart code, you must generate updated API reports:

```sh
$ aft generate api-report
```

This command analyzes the public API of all packages and generates JSON reports that are checked in CI. The reports help track API changes and ensure they are intentional. Always run this command and commit the generated files when your PR modifies any `.dart` files. Use the ```--include``` option to run on specific packages.
2 changes: 2 additions & 0 deletions packages/aft/api_reports/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Don't ignore any files in this directory
!*
Loading
Loading