Skip to content

Commit

Permalink
Fail GitHub Actions CI build if code does not obey style rules
Browse files Browse the repository at this point in the history
  • Loading branch information
shoogle committed Jul 22, 2020
1 parent d2b9b66 commit 380623d
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/collect_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,49 @@ jobs:
name: MuseScore-x86_64.AppImage
path: ./build.release/MuseScore-x86_64.AppImage

collect_artifacts_MacOS:
codestyle_collect_artifacts_MacOS:
runs-on: macos-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
fetch-depth: 3
- name: Run code formatter
# Do this on MacOS because Homebrew has a more recent version of Uncrustify
# than is available in Ubuntu.
run: |
brew install uncrustify findutils
export PATH="/usr/local/opt/findutils/libexec/gnubin:${PATH}"
tools/codestyle/uncrustify_run.sh
- name: Test coding style
run: |
codestyle_failed_files="$(git diff --name-only)"
if [[ "${codestyle_failed_files}" ]]; then
cat >&2 <<EOF
Error: Code style is incorrect in these files:
${codestyle_failed_files}
Please run tools/codestyle/uncrustify_run_file.sh on these files and
then amend your commit.
$ git show --name-only '*.h' '*.cpp' | xargs tools/codestyle/uncrustify_run_file.sh
$ git show --name-only '*.h' '*.cpp' | xargs git add
$ git commit --amend --no-edit
If your PR contains multiple commits then you must do an interactive
rebase and amend each commit in turn.
$ git -c sequence.editor='sed -i s/^pick/edit/' rebase -i HEAD~\${NUM_COMMITS}
Where \${NUM_COMMITS} is the number of commits in your PR.
The required changes are...
$(git diff)
EOF
exit 1
fi
- name: get commit message
run: |
export commitmsg="$(git log --format=%B -n 1 --skip 1 | head -1)"
Expand Down

0 comments on commit 380623d

Please sign in to comment.