Skip to content

Commit

Permalink
Add simple bash script to verify if public API contains data classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Jul 26, 2023
1 parent 76a38a2 commit 5d4a032
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/pull-request-with-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,24 @@ jobs:
run: ./gradlew build ktlintCheck --no-configuration-cache
- name: Build with dev Kotlin version
run: ./gradlew -PkotlinDev build ktlintCheck --no-configuration-cache

- name: Check `data class`es are not part of public API
run: |
found=0
# Loop through all .api files in the current directory and subdirectories
for file in $(find . -type f -name "*.api" ! -path "*/build/*"); do
# Check if the file contains the 'data class' specific text
if grep -q "public static synthetic fun copy$default" "$file"; then
echo "public 'data class' found in: $file"
found=1
fi
done
if [ $found -eq 0 ]; then
exit 0
else
echo "data classes found in one or more .api files. Visit https://github.com/pinterest/ktlint/issues/2133 for more details"
exit 1
fi
shell: bash

0 comments on commit 5d4a032

Please sign in to comment.