summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2020-12-10 17:02:28 +0000
committerQMK Bot <hello@qmk.fm>2020-12-10 17:02:28 +0000
commitf77f715aa2215ae08920f8c2929c3b181657456d (patch)
treed018f8ed0cfcce14c7b7f30e8a1243cc3a8af262
parent15373c8367df04248cdf1f1eb80d08109ca62b85 (diff)
parent6c4b6531fe8fed46bec54fae993a1bab8246dd7d (diff)
Merge remote-tracking branch 'origin/master' into develop
-rw-r--r--.github/workflows/format.yaml34
-rw-r--r--.travis.yml1
-rw-r--r--lib/python/qmk/cli/__init__.py1
-rw-r--r--lib/python/qmk/cli/fileformat.py13
-rwxr-xr-xutil/travis_compiled_push.sh5
5 files changed, 48 insertions, 6 deletions
diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml
new file mode 100644
index 0000000000..ac0835c3af
--- /dev/null
+++ b/.github/workflows/format.yaml
@@ -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: hello@qmk.fm
diff --git a/.travis.yml b/.travis.yml
index a6533d6130..17f401da45 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,7 +19,6 @@ addons:
- llvm-toolchain-trusty-7
packages:
- diffutils
- - dos2unix
- clang-format-7
- libstdc++-7-dev
script:
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index 10536bb230..372c40921a 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -14,6 +14,7 @@ from . import compile
from . import config
from . import docs
from . import doctor
+from . import fileformat
from . import flash
from . import generate
from . import hello
diff --git a/lib/python/qmk/cli/fileformat.py b/lib/python/qmk/cli/fileformat.py
new file mode 100644
index 0000000000..502a3b7b1f
--- /dev/null
+++ b/lib/python/qmk/cli/fileformat.py
@@ -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
diff --git a/util/travis_compiled_push.sh b/util/travis_compiled_push.sh
index a9c6f028fb..6300442fdb 100755
--- a/util/travis_compiled_push.sh
+++ b/util/travis_compiled_push.sh
@@ -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 git@github.com:qmk/qmk_firmware.git master
git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE}