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

Test has API Folder #98

Open
wants to merge 156 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
3695cd4
Create swift-api.yml
rozaychen May 30, 2024
fddd484
Create apiBreakage.yml
rozaychen May 30, 2024
ca82303
Delete .github/workflows/name: SwiftAPIBreakage on: pull_request: …
rozaychen May 30, 2024
3d65ad1
Merge pull request #1 from rozaychen/rozaychen-patch-1
rozaychen May 30, 2024
69fef3f
Update apiBreakage.yml
rozaychen May 30, 2024
d8c2cf2
Update apiBreakage.yml
rozaychen May 30, 2024
06a517f
Update apiBreakage.yml
rozaychen May 30, 2024
79b6371
Update Amplify.swift
rozaychen May 30, 2024
6fcb615
Merge pull request #2 from rozaychen/rozaychen-patch-2
rozaychen May 30, 2024
b3c6d2d
chore: Test No API Break
rozaychen May 30, 2024
6f702cd
Merge pull request #4 from rozaychen/rozaychen-patch-4
rozaychen May 30, 2024
9c64c95
Update Amplify.swift
rozaychen May 30, 2024
4baff0a
Delete .github/workflows directory
rozaychen May 31, 2024
eb49b7f
Create apiBreak.yml
rozaychen May 31, 2024
083a839
Add API file
rozaychen May 31, 2024
ecd3536
Merge pull request #5 from rozaychen/rozaychen-patch-4
rozaychen May 31, 2024
0a1edb5
Change to adaptation version of swift-api-diff
rozaychen May 31, 2024
1cb3b45
Update
rozaychen May 31, 2024
3348251
Temporary change 5.9 to 5.1
rozaychen May 31, 2024
403cc88
Update Package.swift
rozaychen May 31, 2024
dff148c
Update apiBreak.yml
rozaychen May 31, 2024
b98b0a4
Update apiBreak.yml
rozaychen May 31, 2024
035457a
Update apiBreak.yml
rozaychen May 31, 2024
b5f9c19
Create apiBreakTest.yml
rozaychen May 31, 2024
528b8a9
Update apiBreakTest.yml
rozaychen May 31, 2024
4148986
Update apiBreakTest.yml
rozaychen May 31, 2024
186008c
Create check_deletions.yml
rozaychen Jun 3, 2024
c7b5943
Create check_deletions.sh
rozaychen Jun 3, 2024
453a30f
Update check_deletions.sh
rozaychen Jun 3, 2024
cf6f55a
Update check_deletions.yml
rozaychen Jun 3, 2024
c37e805
Update check_deletions.sh
rozaychen Jun 3, 2024
c4c7b13
Update apiBreakTest.yml
rozaychen Jun 3, 2024
187124d
Update apiBreakTest.yml
rozaychen Jun 3, 2024
add7a32
Update apiBreakTest.yml
rozaychen Jun 3, 2024
8436cee
Update apiBreakTest.yml
rozaychen Jun 3, 2024
f3fde69
Update apiBreakTest.yml
rozaychen Jun 3, 2024
5642c99
Update apiBreakTest.yml
rozaychen Jun 3, 2024
db912ee
Update apiBreakTest.yml
rozaychen Jun 3, 2024
f28abf9
Update apiBreakTest.yml
rozaychen Jun 3, 2024
8ee15f8
Update apiBreakTest.yml
rozaychen Jun 3, 2024
8406537
Update apiBreakTest.yml
rozaychen Jun 3, 2024
2516d20
Update apiBreakTest.yml
rozaychen Jun 3, 2024
f052eaf
Update apiBreakTest.yml
rozaychen Jun 3, 2024
7c518a1
Delete .github/workflows/apiBreak.yml
rozaychen Jun 3, 2024
a1d4e83
Update apiBreakTest.yml
rozaychen Jun 3, 2024
e6ecc04
Update apiBreakTest.yml
rozaychen Jun 3, 2024
5d0905f
Update apiBreakTest.yml
rozaychen Jun 3, 2024
032e45b
Update apiBreakTest.yml
rozaychen Jun 3, 2024
6841e1f
Update apiBreakTest.yml
rozaychen Jun 3, 2024
491014b
Update apiBreakTest.yml
rozaychen Jun 4, 2024
38ed9f4
Update apiBreakTest.yml
rozaychen Jun 4, 2024
2e39879
Update apiBreakTest.yml
rozaychen Jun 4, 2024
60bf553
Update apiBreakTest.yml
rozaychen Jun 4, 2024
a442bf1
Update apiBreakTest.yml
rozaychen Jun 4, 2024
ba29076
Update apiBreakTest.yml
rozaychen Jun 4, 2024
4ff6b65
Update apiBreakTest.yml
rozaychen Jun 4, 2024
13d3af6
Update apiBreakTest.yml
rozaychen Jun 4, 2024
8360cef
Update apiBreakTest.yml
rozaychen Jun 4, 2024
eaa9bc7
Add Local Script
rozaychen Jun 5, 2024
02c0fdb
Update check_api_breakage.sh
rozaychen Jun 5, 2024
fe66be1
Update apiBreakTest.yml
rozaychen Jun 5, 2024
75553c7
Update apiBreakTest.yml
rozaychen Jun 5, 2024
6cf9da3
Update apiBreakTest.yml
rozaychen Jun 5, 2024
99c1857
Update apiBreakTest.yml
rozaychen Jun 6, 2024
5c1969c
Update apiBreakTest.yml
rozaychen Jun 6, 2024
3ec6ddf
Update apiBreakTest.yml
rozaychen Jun 6, 2024
6df254d
Update apiBreakTest.yml
rozaychen Jun 6, 2024
390c199
Update apiBreakTest.yml
rozaychen Jun 6, 2024
22da4eb
Update apiBreakTest.yml
rozaychen Jun 6, 2024
1042fbe
Update apiBreakTest.yml
rozaychen Jun 6, 2024
5d61d2c
Update .gitignore
rozaychen Jun 6, 2024
7bd2463
Update API Dump
rozaychen Jun 6, 2024
b04bde5
Update apiBreakTest.yml
rozaychen Jun 6, 2024
9152215
Test Break API
rozaychen Jun 6, 2024
fc68a8d
Delete .github/workflows/check_deletions.yml
rozaychen Jun 6, 2024
6d597d0
Update apiBreakTest.yml
rozaychen Jun 6, 2024
0fcf042
Update apiBreakTest.yml
rozaychen Jun 6, 2024
5dc5b41
Update apiBreakTest.yml
rozaychen Jun 6, 2024
eef811a
Update API dump for new version
github-actions[bot] Jun 6, 2024
7ddafdc
Merge pull request #26 from rozaychen/test-caching
rozaychen Jun 6, 2024
a9631c9
Update apiBreakTest.yml
rozaychen Jun 6, 2024
3257f47
Update apiBreakTest.yml
rozaychen Jun 6, 2024
f0f54b7
Update apiBreakTest.yml
rozaychen Jun 6, 2024
f8674ae
Update apiBreakTest.yml
rozaychen Jun 6, 2024
68c1fa6
Update apiBreakTest.yml
rozaychen Jun 6, 2024
8d681c0
Update apiBreakTest.yml
rozaychen Jun 7, 2024
2aeff34
Update apiBreakTest.yml
rozaychen Jun 7, 2024
5593f59
Update apiBreakTest.yml
rozaychen Jun 7, 2024
e66f6a2
Update apiBreakTest.yml
rozaychen Jun 7, 2024
687a25e
Update apiBreakTest.yml
rozaychen Jun 7, 2024
ee682cb
Update check_api_breakage.sh
rozaychen Jun 10, 2024
ce816c1
Update check_api_breakage.sh
rozaychen Jun 10, 2024
c164827
Update check_api_breakage.sh
rozaychen Jun 10, 2024
c55f204
Update apiBreakTest.yml
rozaychen Jun 10, 2024
67cbbe7
Update MLPlugin
rozaychen Jun 10, 2024
7364e0c
Test 2 modules break
rozaychen Jun 10, 2024
ece42ef
Update API dumps for new version
github-actions[bot] Jun 10, 2024
bd9680b
Merge pull request #29 from rozaychen/test-rozay-6
rozaychen Jun 10, 2024
3167028
Update apiBreakTest.yml
rozaychen Jun 10, 2024
8cdb957
Update apiBreakTest.yml
rozaychen Jun 10, 2024
e9842c4
Update apiBreakTest.yml
rozaychen Jun 10, 2024
38ffbe0
Update apiBreakTest.yml
rozaychen Jun 10, 2024
9fba742
Merge branch 'aws-amplify:main' into main
rozaychen Jun 11, 2024
52cff65
Update apiBreakTest.yml
rozaychen Jun 11, 2024
8f528fb
Update
rozaychen Jun 12, 2024
9379798
Update API dumps for new version
github-actions[bot] Jun 12, 2024
ed018f0
Merge pull request #59 from rozaychen/Enum-update
rozaychen Jun 12, 2024
207954f
Update apiBreakTest.yml
rozaychen Jun 12, 2024
a3d1c6e
Update apiBreakTest.yml
rozaychen Jun 12, 2024
8da13c7
Update apiBreakTest.yml
rozaychen Jun 12, 2024
0a803aa
Update apiBreakTest.yml
rozaychen Jun 12, 2024
cf37d2c
Update API dumps for new version
github-actions[bot] Jun 12, 2024
57dc087
Merge pull request #91 from rozaychen/Enum
rozaychen Jun 12, 2024
294f78a
Update apiBreakTest.yml
rozaychen Jun 12, 2024
3edd3c2
Final Test
rozaychen Jun 12, 2024
92f43ec
Update API dumps for new version
github-actions[bot] Jun 12, 2024
b4f72ea
Merge branch 'main' into Final-test
rozaychen Jun 12, 2024
5553142
Merge pull request #93 from rozaychen/Final-test
rozaychen Jun 12, 2024
ba5db53
Create APIDigesterCheck
rozaychen Jun 12, 2024
0eb999c
Update apiBreakTest.yml
rozaychen Jun 12, 2024
1998582
Add test
rozaychen Jun 13, 2024
1865b4d
Update APIDigesterCheck
rozaychen Jun 13, 2024
c6b6a22
Update and rename APIDigesterCheck to APIDigesterCheck.yml
rozaychen Jun 13, 2024
ffccec2
Update APIDigesterCheck.yml
rozaychen Jun 13, 2024
b0be253
Update APIDigesterCheck.yml
rozaychen Jun 13, 2024
feca055
Update APIDigesterCheck.yml
rozaychen Jun 13, 2024
bb29fde
Update APIDigesterCheck.yml
rozaychen Jun 13, 2024
34aae9f
Update test json
rozaychen Jun 13, 2024
5d7f9e5
Merge branch 'main' of https://github.com/rozaychen/amplify-swift
rozaychen Jun 13, 2024
a0be698
Update expected-result.txt
rozaychen Jun 13, 2024
855b3f3
Update expected-result.txt
rozaychen Jun 13, 2024
cb0d13e
Update expected-result.txt
rozaychen Jun 13, 2024
0929886
Update test json
rozaychen Jun 13, 2024
54100d5
Update expected-result.txt
rozaychen Jun 13, 2024
fba1df4
Update B.json
rozaychen Jun 13, 2024
b75e0a0
Update expected-result.txt
rozaychen Jun 13, 2024
64517d9
Update APIDigesterCheck.yml
rozaychen Jun 13, 2024
8ce8338
Delete api-dump directory
rozaychen Jun 13, 2024
fe919ba
Update Amplify.swift
rozaychen Jun 13, 2024
b3809ff
Update apiBreakTest.yml
rozaychen Jun 13, 2024
1ed1ee2
Update apiBreakTest.yml
rozaychen Jun 13, 2024
f9826de
Update apiBreakTest.yml
rozaychen Jun 13, 2024
e2650a8
Update apiBreakTest.yml
rozaychen Jun 13, 2024
5c2e20d
Update apiBreakTest.yml
rozaychen Jun 13, 2024
4a86e6f
Update apiBreakTest.yml
rozaychen Jun 13, 2024
99e84ef
Update apiBreakTest.yml
rozaychen Jun 13, 2024
54cf39f
Update API dumps for new version
github-actions[bot] Jun 13, 2024
0868707
Merge pull request #95 from rozaychen/test-no-api-folder
rozaychen Jun 13, 2024
cd20f4b
Delete api-dump directory
rozaychen Jun 13, 2024
6952228
Update apiBreakTest.yml
rozaychen Jun 13, 2024
95b7a86
test no api folder
rozaychen Jun 13, 2024
90abd65
Update API dumps for new version
github-actions[bot] Jun 13, 2024
3ff74b5
Update API dumps for new version
github-actions[bot] Jun 13, 2024
9d58009
Merge pull request #96 from rozaychen/test-no-api-folder
rozaychen Jun 13, 2024
d5e110e
Test has API Folder
rozaychen Jun 13, 2024
9bdde29
Update API dumps for new version
github-actions[bot] Jun 13, 2024
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
37 changes: 37 additions & 0 deletions .github/workflows/APIDigesterCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Swift API Digester Check

on:
schedule:
- cron: '0 0 * * *' # This will run the action every night at midnight
workflow_dispatch: # Allows manual triggering

jobs:
check-swift-api-digester:
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0


- name: Check API Dihester
run: |
TEMP_DIR=$(mktemp -d)
echo "Temporary directory created at $TEMP_DIR"
SDK_PATH=$(xcrun --sdk macosx --show-sdk-path)
echo "SDK Path: $SDK_PATH"

# Run swift-api-digester
swift api-digester -sdk "$SDK_PATH" -diagnose-sdk --input-paths api-dump-test/A.json --input-paths api-dump-test/B.json >> "$TEMP_DIR/api-digester-output.txt" 2>&1

# Display the output
cat "$TEMP_DIR/api-digester-output.txt"

if diff "$TEMP_DIR/api-digester-output.txt" api-dump-test/expected-result.txt; then
echo "The output matches the expected result."
else
echo "The output does not match the expected result."
exit 1
fi
188 changes: 188 additions & 0 deletions .github/workflows/apiBreakTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
name: "Solution1b"

on:
pull_request:

jobs:
buildAndCheckAPIBreakage:
name: Build and Check API Breakage
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0

- name: Setup and Run Swift API Diff
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Swift version: $(swift --version)"
echo "Swift package manager version: $(swift package --version)"
swift package resolve

# Ensure we are in the correct directory
cd $GITHUB_WORKSPACE

# Run swift-api-diff commands here directly
NEW_API_DIR=$(mktemp -d)
OLD_API_DIR=$(mktemp -d)
SDK_PATH=$(xcrun --show-sdk-path)

# Get all library module names
modules=$(swift package dump-package | jq -r '.products | map(select(.name == "Amplify" or .name == "CoreMLPredictionsPlugin" or .name == "AWSDataStorePlugin" or .name == "AWSPluginsCore")) | map(.name) | .[]')
echo "Modules: $modules"

echo "Fetching old version..."
git checkout ${{ github.event.pull_request.base.sha }}
built=false
for module in $modules; do
# If file doesn't exits in the old directory
if [ ! -f api-dump/${module}.json ]; then
echo "Old API file does not exist in the base branch. Generating it..."
# Check if the project has been built
if ! $built; then
echo "Building project..."
swift build > /dev/null 2>&1 || { echo "Failed to build project"; exit 1; }
built=true
fi

# Generate the API file using api-digester
swift api-digester -sdk "$SDK_PATH" -dump-sdk -module "$module" -o "$OLD_API_DIR/${module}.json" -I .build/debug || { echo "Failed to dump new SDK for module $module"; exit 1; }
else
# Use the api-dump/${module}.json file from the base branch directly
cp "api-dump/${module}.json" "$OLD_API_DIR/${module}.json"
fi
done

echo "Fetching new version..."
git checkout ${{ github.sha }}
git log -1 # Print the commit info for debugging
swift build> /dev/null 2>&1 || { echo "Failed to build new version"; exit 1; }
for module in $modules; do
swift api-digester -sdk "$SDK_PATH" -dump-sdk -module "$module" -o "$NEW_API_DIR/${module}.json" -I .build/debug || { echo "Failed to dump new SDK for module $module"; exit 1; }
done

# Compare APIs for each module and capture the output
api_diff_output=""
for module in $modules; do
swift api-digester -sdk "$SDK_PATH" -diagnose-sdk --input-paths "$OLD_API_DIR/${module}.json" --input-paths "$NEW_API_DIR/${module}.json" >> "api-diff-report-${module}.txt" 2>&1
module_diff_output=$(grep -v '^/\*' "api-diff-report-${module}.txt" | grep -v '^$' | grep -v 'has been added as a new enum case$' | grep -v 'is now with @_spi$' || true)
if [ -n "$module_diff_output" ]; then
api_diff_output="${api_diff_output}\n**Module: ${module}**\n${module_diff_output}\n"

# Check if there are lines containing "has been renamed to Func"
if echo "$module_diff_output" | grep -q 'has been renamed to Func'; then
# Capture the line containing "has been renamed to Func"
renamed_line=$(echo "$module_diff_output" | grep 'has been renamed to Func')

# Append a message to the module_diff_output
api_diff_output="${api_diff_output}👉🏻 _Note: If you're just adding optional parameters to existing methods, neglect the line:_\n_${renamed_line}_\n"
fi
fi
done
echo "API_DIFF_OUTPUT<<EOF" >> $GITHUB_ENV
if [ -n "$api_diff_output" ]; then
echo "### 💔 Public API Breaking Change detected:" >> $GITHUB_ENV
echo -e "$api_diff_output" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "BREAKING_CHANGE_DETECTED=true" >> $GITHUB_ENV
else
echo "### ✅ No Public API Breaking Change detected" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "BREAKING_CHANGE_DETECTED=false" >> $GITHUB_ENV
fi

# Checkout to the branch associated with the pull request
git stash --include-untracked
git checkout ${{ github.head_ref }}

if [ ! -d "api-dump" ]; then
echo "api-dump folder does not exist. Creating it..."
mkdir -p "api-dump"
fi

# Update the api-dump folder of the new version by making a commit if there are changes
for module in $modules; do
if [ ! -f api-dump/${module}.json ]; then
echo "API file does not exist in api-dump folder. Creating it..."
# Create an empty JSON file
echo "{}" > "api-dump/${module}.json"
fi
if ! diff "$NEW_API_DIR/${module}.json" "api-dump/${module}.json" > /dev/null; then
echo "Updating API Dumps..."
mv "$NEW_API_DIR/${module}.json" "api-dump/${module}.json"
fi
done

git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

# Check if there are changes in the api-dump folder
# if ! git diff --quiet --exit-code -- api-dump/*.json; then
git add api-dump/*.json

if ! git diff --cached --quiet --exit-code; then
git commit -m "Update API dumps for new version"
git push origin HEAD:${{ github.head_ref }}
else
echo "No changes to commit in the api-dump folder."
fi

git stash pop || true

- name: Comment on PR with API Diff
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const apiDiffOutput = process.env.API_DIFF_OUTPUT;
const issueNumber = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;

if (apiDiffOutput && apiDiffOutput.trim().length > 0) {
github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: issueNumber,
body: `## API Breakage Report\n${apiDiffOutput}\n`
});
} else {
console.log("No API diff output found.");
}

- name: Add Reviewer if Breaking Change Detected
if: env.BREAKING_CHANGE_DETECTED == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueNumber = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;

// Define the list of potential reviewers
const potentialReviewers = ["rozayc", "rozayc", "rozayc", "rozayc", "rozayc"];

// Shuffle the array to ensure randomness
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}

// Shuffle the potential reviewers list
shuffle(potentialReviewers);

// Select the first 2 reviewers from the shuffled list
const selectedReviewers = potentialReviewers.slice(0, 1);

github.rest.pulls.requestReviewers({
owner: owner,
repo: repo,
pull_number: issueNumber,
reviewers: selectedReviewers
});
68 changes: 0 additions & 68 deletions .github/workflows/build_amplify_swift_platforms.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/build_minimum_supported_swift_platforms.yml

This file was deleted.

Loading