mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
58 lines
2.0 KiB
YAML
58 lines
2.0 KiB
YAML
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
|
|
- 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
|
|
run: |
|
|
IFS=$'\n'
|
|
for fname in `find . -type f -name '*.cpp' -o -name '*.h'`
|
|
do
|
|
echo "${fname}"
|
|
new_fname=`echo ${fname} | tr ' ' '_'`
|
|
echo " ${new_fname}"
|
|
new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
|
|
echo " ${new_fname}"
|
|
new_fname=`echo ${new_fname} | tr '-' '_'`
|
|
echo " ${new_fname}"
|
|
if [ ${fname} != ${new_fname} ]
|
|
then
|
|
echo " ${fname} --> ${new_fname}"
|
|
git "mv" "${fname}" ${new_fname}
|
|
fi
|
|
done
|
|
git commit -am "formatting filenames $GITHUB_SHA" || true
|
|
- name: Clang Formatter
|
|
run: |
|
|
for fname in $(find . -name '*.cpp' -o -name '*.h')
|
|
do
|
|
clang-format --verbose -i --style="$line1 $line2 $line3 $line4" "$fname"
|
|
done
|
|
git commit -am "formatting source-code for $GITHUB_SHA" || true
|
|
env:
|
|
line1: "{ BasedOnStyle: Google, UseTab: Never,"
|
|
line2: "IndentWidth: 4, TabWidth: 4"
|
|
line3: "AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false,"
|
|
line4: "ColumnLimit: 80, AccessModifierOffset: -3 }"
|
|
- name: Git Push
|
|
run: git pull && git push
|