Merge pull request #5175 from ByteHamster/format-xml

Add CI check that enforces layout xml file formatting
This commit is contained in:
ByteHamster 2021-06-05 22:56:44 +02:00 committed by GitHub
commit b8e311d9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -96,3 +96,15 @@ workflows:
- run:
name: SpotBugs
command: ./gradlew spotbugsPlayDebug spotbugsDebug 2>&1 | grep -i "spotbugs"
- build:
name: XML
build-steps:
- run:
name: XML of changed files
command: |
git fetch origin develop
branchBaseCommit=`git merge-base origin/develop HEAD`
echo "Comparing to $branchBaseCommit"
curl -s -L https://github.com/ByteHamster/android-xml-formatter/releases/download/1.1.0/android-xml-formatter.jar > android-xml-formatter.jar
git diff --name-only $branchBaseCommit | { grep "res/layout/" || true; } | xargs java -jar android-xml-formatter.jar
test $(git diff | wc -l) -eq 0 || (echo -e "\n\n===== Found XML code style violations! See output below how to fix them. =====\n\n" && git --no-pager diff --color=always && false)