refactor: refactoring autotrack core in sdk 4.x #190
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code Format | |
on: | |
pull_request: | |
paths: | |
- 'Growing*/**' | |
- 'Modules/**' | |
- 'Services/**' | |
- 'Package.swift' | |
permissions: | |
contents: write | |
jobs: | |
code-format: | |
name: Code Format | |
runs-on: macos-latest | |
if: ${{ github.actor != 'GIOSDK' }} # 禁止套娃 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GIOSDK_PAT }} | |
- name: Install clang-format | |
run: brew install clang-format | |
- name: Install swiftformat | |
run: swiftformat --version | |
- name: Code Format | |
run: | | |
git fetch | |
git diff --name-only --relative --diff-filter=ACMR origin/master HEAD \ | |
| sed -E -n ' | |
\%\.pbobjc\.% d | |
\%^GrowingTrackerCore/Thirdparty/% d | |
\%^Services/Compression/LZ4/% d | |
\%^Services/Database/FMDB/% d | |
\%^Services/WebSocket/% d | |
\%^(Growing|Modules/|Services/).*\.(h|hpp|c|cpp|m|mm)% p | |
' \ | |
| xargs clang-format -i -style=file | |
git diff --name-only --relative --diff-filter=ACMR origin/master HEAD \ | |
| sed -E -n ' | |
\%\.pb\.% d | |
\%^(Growing|Modules/|Services/).*\.swift% p | |
\%Package.swift% p | |
' \ | |
| xargs swiftformat | |
- name: Commit | |
run: | | |
if [[ $(git status) == *"nothing to commit"* ]]; then | |
echo "All Code formatted correctly." | |
else | |
git checkout ${{ github.head_ref }} | |
git config user.name GIOSDK | |
git config user.email [email protected] | |
git commit -am "style: code format" | |
git push origin ${{ github.head_ref }} | |
fi |