2020-05-30 05:06:37 +08:00
|
|
|
name: Code Formatting
|
|
|
|
|
|
|
|
on: [push]
|
|
|
|
# push:
|
|
|
|
# branches: [ master ]
|
|
|
|
# pull_request:
|
|
|
|
# branches: [ master ]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: requirements
|
|
|
|
run: |
|
|
|
|
sudo apt -qq -y update
|
|
|
|
sudo apt -qq install clang-format
|
|
|
|
- uses: actions/checkout@master
|
|
|
|
with:
|
|
|
|
submodules: true
|
2020-05-30 05:22:51 +08:00
|
|
|
- name: Setup Git Specs
|
|
|
|
run: |
|
|
|
|
git config --global user.name github-actions
|
|
|
|
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
|
|
|
|
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
|
|
|
- name: Filename Formatter
|
2020-05-30 05:24:14 +08:00
|
|
|
run: |
|
2020-05-30 06:06:55 +08:00
|
|
|
for fname in $(find . -type f -name '*.cpp' -o -name '*.h')
|
2020-05-30 05:22:51 +08:00
|
|
|
do
|
2020-05-30 06:20:21 +08:00
|
|
|
new_fname="$(echo -e '${fname}' | tr ' ' '_')"
|
2020-05-30 06:17:46 +08:00
|
|
|
new_fname="$(echo -e ${new_fname} | tr 'A-Z' 'a-z')"
|
2020-05-30 05:52:50 +08:00
|
|
|
if [ $fname != $new_fname ]
|
2020-05-30 05:43:28 +08:00
|
|
|
then
|
2020-05-30 06:14:56 +08:00
|
|
|
echo -e "\"$fname\" --> $new_fname"
|
2020-05-30 06:06:55 +08:00
|
|
|
git mv "$fname" $new_fname
|
2020-05-30 05:43:28 +08:00
|
|
|
fi
|
2020-05-30 05:22:51 +08:00
|
|
|
done
|
|
|
|
git commit -am "formatting filenames $GITHUB_SHA" || true
|
|
|
|
- name: Clang Formatter
|
2020-05-30 05:06:37 +08:00
|
|
|
run: |
|
|
|
|
for fname in $(find . -name '*.cpp' -o -name '*.h')
|
|
|
|
do
|
|
|
|
clang-format --verbose -i --style="$line1 $line2 $line3 $line4" "$fname"
|
|
|
|
done
|
2020-05-30 05:22:51 +08:00
|
|
|
git commit -am "formatting source-code for $GITHUB_SHA" || true
|
2020-05-30 05:06:37 +08:00
|
|
|
env:
|
|
|
|
line1: "{ BasedOnStyle: Google, UseTab: Never,"
|
|
|
|
line2: "IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman,"
|
|
|
|
line3: "AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false,"
|
2020-05-30 05:07:47 +08:00
|
|
|
line4: "ColumnLimit: 80, AccessModifierOffset: -3 }"
|
2020-05-30 05:22:51 +08:00
|
|
|
# -name: Git Push
|
|
|
|
# run: git push
|