Skip to content

Commit

Permalink
ci: add scripts to validate that public API has not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklasl committed Jul 3, 2024
1 parent 38bc53a commit 34279e9
Show file tree
Hide file tree
Showing 8 changed files with 31,906 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ on:
- 'main'

jobs:
API-diff:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
- name: Run public API diff
run: scripts/api_diff.sh

Tests:
runs-on: macOS-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ DerivedData/
.netrc
.build
.mockingbird
project.json
project.json
scripts/raw_api.json
31,051 changes: 31,051 additions & 0 deletions scripts/api.json

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions scripts/api_diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

script_dir=$(dirname $0)
root_dir="$script_dir/../"

# Generate the json file with:
sourcekitten doc --module-name Confidence -- -scheme Confidence-Package -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' > $script_dir/raw_api.json

# Extract the public API from the raw api json file
python3 $script_dir/extract_public_funcs.py $script_dir/raw_api.json $script_dir/current_public_api.json

# Clean up the raw api json file
rm $script_dir/raw_api.json

# Compare the public API with the previous public API and exit with 1 if there are changes
# TODO(nicklasl): store the result (exit code) and provide information on how to remedy.
git diff --no-index --exit-code $script_dir/public_api.json $script_dir/current_public_api.json
Loading

0 comments on commit 34279e9

Please sign in to comment.