forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Add workflow for codebase formatting (qmk#7382)
* Add workflow for codebase formatting * stash * review comments * Swap to a more complete push action
- Loading branch information
Showing
5 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Format Codebase | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
generate: | ||
runs-on: ubuntu-latest | ||
container: qmkfm/base_container | ||
|
||
# protect against those who develop with their fork on master | ||
if: github.repository == 'qmk/qmk_firmware' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
apt-get update && apt-get install -y dos2unix | ||
- name: Format files | ||
run: | | ||
bin/qmk cformat | ||
bin/qmk pyformat | ||
bin/qmk fileformat | ||
- name: Commit files | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: "Format code according to conventions for ${GITHUB_SHA}" | ||
commit_user_name: QMK Bot | ||
commit_user_email: [email protected] |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Format files according to QMK's style. | ||
""" | ||
from milc import cli | ||
|
||
import subprocess | ||
|
||
|
||
@cli.subcommand("Format files according to QMK's style.", hidden=True) | ||
def fileformat(cli): | ||
"""Run several general formatting commands. | ||
""" | ||
dos2unix = subprocess.run(['bash', '-c', 'dos2unix **']) | ||
return dos2unix.returncode |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,7 @@ echo "Using git hash ${rev}" | |
|
||
if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; then | ||
|
||
# fix formatting | ||
git checkout master | ||
git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 dos2unix | ||
git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} '*.c' '*.h' '*.cpp' | grep -z -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | grep -zv -e 'quantum/template' -e 'tmk_core/protocol/usb_hid' -e 'platforms/chibios' | xargs -0 clang-format-7 -i | ||
git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 git add | ||
git commit -m "format code according to conventions [skip ci]" && git push [email protected]:qmk/qmk_firmware.git master | ||
|
||
git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | ||
|
||
|