Skip to content

Commit

Permalink
refactor: Add more checks to pre-commit
Browse files Browse the repository at this point in the history
Updated existing pre-commit hooks and added some new hooks:

- Remove trailing whitespace
- Ensure every non-empty file ends with a new line
- Check YAML file validity
- Prevent adding large files
- Ensure any scripts with shebangs are executable

Added a GitHub action to run pre-commit on every commit. Removed any
existing actions which duplicate pre-commit.

Ran pre-commit on the codebase.
  • Loading branch information
joelspadin authored and petejohanson committed Apr 24, 2023
1 parent 9c4f1e0 commit 32ae776
Show file tree
Hide file tree
Showing 247 changed files with 768 additions and 806 deletions.
24 changes: 13 additions & 11 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<!-- If you're adding a board/shield please fill out this check-list, otherwise you can delete it -->

## Board/Shield Check-list
- [ ] This board/shield is tested working on real hardware
- [ ] Definitions follow the general style of other shields/boards upstream ([Reference](https://zmk.dev/docs/development/new-shield))
- [ ] `.zmk.yml` metadata file added
- [ ] Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited)
- [ ] General consistent formatting of DeviceTree files
- [ ] Keymaps do not use deprecated key defines (Check using the [upgrader tool](https://zmk.dev/docs/codes/keymap-upgrader))
- [ ] `&pro_micro` used in favor of `&pro_micro_d/a` if applicable
- [ ] If split, no name added for the right/peripheral half
- [ ] Kconfig.defconfig file correctly wraps *all* configuration in conditional on the shield symbol
- [ ] `.conf` file has optional extra features commented out
- [ ] Keyboard/PCB is part of a shipped group buy or is generally available in stock to purchase (OSH/personal projects without general availability should create a zmk-config repo instead)

- [ ] This board/shield is tested working on real hardware
- [ ] Definitions follow the general style of other shields/boards upstream ([Reference](https://zmk.dev/docs/development/new-shield))
- [ ] `.zmk.yml` metadata file added
- [ ] Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited)
- [ ] General consistent formatting of DeviceTree files
- [ ] Keymaps do not use deprecated key defines (Check using the [upgrader tool](https://zmk.dev/docs/codes/keymap-upgrader))
- [ ] `&pro_micro` used in favor of `&pro_micro_d/a` if applicable
- [ ] If split, no name added for the right/peripheral half
- [ ] Kconfig.defconfig file correctly wraps _all_ configuration in conditional on the shield symbol
- [ ] `.conf` file has optional extra features commented out
- [ ] Keyboard/PCB is part of a shipped group buy or is generally available in stock to purchase (OSH/personal projects without general availability should create a zmk-config repo instead)
4 changes: 2 additions & 2 deletions .github/workflows/build-user-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ on:
required: false
type: string
archive_name:
description: 'Archive output file name'
default: 'firmware'
description: "Archive output file name"
default: "firmware"
required: false
type: string

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
for (const configuration of combinedUnique) {
if (!perBoard[configuration.board])
perBoard[configuration.board] = [];
perBoard[configuration.board].push({
shield: configuration.shield,
'cmake-args': configuration['cmake-args'],
Expand Down Expand Up @@ -234,7 +234,7 @@ jobs:
};
}
} else if (hm.exposes) {
return hm.exposes.flatMap(i =>
return hm.exposes.flatMap(i =>
metadata.interconnects[i].shields.flatMap(s => boardAndShield(hm, s))
);
} else {
Expand All @@ -243,7 +243,7 @@ jobs:
break;
case "shield":
if (hm.features && hm.features.includes("keys")) {
return hm.requires.flatMap(i =>
return hm.requires.flatMap(i =>
metadata.interconnects[i].boards.flatMap(b => boardAndShield(b, hm))
);
} else {
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/clang-format-lint.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .github/workflows/doc-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ jobs:
- name: ESLint
run: npm run lint
working-directory: docs
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: bahmutov/npm-install@v1
with:
working-directory: docs
- name: Prettier check
run: npm run prettier:check
working-directory: docs
typecheck:
runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/hardware-metadata-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ on:
- "app/scripts/west_commands/metadata.py"

jobs:
check-metadata-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
- uses: bahmutov/npm-install@v1
with:
working-directory: app
- name: Prettier Check
run: npm run prettier:check
working-directory: app
validate-metadata:
runs-on: ubuntu-latest
container:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pre-commit

on:
pull_request:
push:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]
12 changes: 10 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
fail_fast: false
repos:
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.1.1
rev: v1.3.5
hooks:
- id: clang-format
args:
- -i
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
rev: v2.7.1
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- id: check-shebang-scripts-are-executable
exclude: "\\.mustache$"
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"*.keymap": "dts"
},
"python.formatting.provider": "black"
}
}
2 changes: 1 addition & 1 deletion app/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
endOfLine: "auto",
endOfLine: "auto",
};
10 changes: 5 additions & 5 deletions app/boards/arm/bluemicro840/arduino_pro_micro_pins.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map
= <0 0 &gpio0 8 0> /* D0 D2 */
, <1 0 &gpio0 6 0> /* D1 D3*/
, <2 0 &gpio0 15 0> /* D2 D1*/
, <3 0 &gpio0 17 0> /* D3 D0*/
, <4 0 &gpio0 20 0> /* D4/A6 D4*/
= <0 0 &gpio0 8 0> /* D0 D2 */
, <1 0 &gpio0 6 0> /* D1 D3*/
, <2 0 &gpio0 15 0> /* D2 D1*/
, <3 0 &gpio0 17 0> /* D3 D0*/
, <4 0 &gpio0 20 0> /* D4/A6 D4*/
, <5 0 &gpio0 13 0> /* D5 C6*/
, <6 0 &gpio0 24 0> /* D6/A7 D7*/
, <7 0 &gpio0 9 0> /* D7 E6*/
Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/corneish_zen/corneish_zen_v2_left.dts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
, <&gpio1 9 GPIO_ACTIVE_HIGH>
, <&gpio0 7 GPIO_ACTIVE_HIGH>
, <&gpio0 5 GPIO_ACTIVE_HIGH>
;
;
};

leds {
Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/corneish_zen/corneish_zen_v2_right.dts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
, <&gpio1 9 GPIO_ACTIVE_HIGH>
, <&gpio0 7 GPIO_ACTIVE_HIGH>
;

};

leds {
Expand Down
1 change: 0 additions & 1 deletion app/boards/arm/ferris/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Building ZMK for the Ferris 0.2


## Standard Build

```
Expand Down
2 changes: 2 additions & 0 deletions app/boards/arm/nice60/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# nice!60

![nice!60](https://i.imgur.com/0YWv5PE.png)

The nice!60 is a hotswap 60% made by Nice Keyboards. https://nicekeyboards.com/nice-60

## Building nice!60 ZMK firmware

```
west build -p -b nice60
```
4 changes: 2 additions & 2 deletions app/boards/arm/nice60/nice60.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/ {
keymap {
compatible = "zmk,keymap";

default_layer {
// ------------------------------------------------------------------------------------------
// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP |
Expand Down Expand Up @@ -40,7 +40,7 @@
// ------------------------------------------------------------------------------------------------
bindings = <
&bt BT_CLR &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &rgb_ug RGB_EFR
&bt BT_SEL 0 &trans &kp UP &trans &rgb_ug RGB_HUI &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &trans &trans &trans &trans &trans &trans
&bt BT_SEL 0 &trans &kp UP &trans &rgb_ug RGB_HUI &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &trans &trans &trans &trans &trans &trans
&bt BT_SEL 1 &kp LEFT &kp DOWN &kp RIGHT &rgb_ug RGB_HUD &rgb_ug RGB_SAD &rgb_ug RGB_BRD &rgb_ug RGB_SPD &trans &trans &trans &trans &rgb_ug RGB_EFF
&bt BT_SEL 2 &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&bt BT_SEL 3 &trans &trans &rgb_ug RGB_TOG &kp PSCRN &trans &trans &kp DEL
Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/pillbug/pillbug.dts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
label = "Blue LED";
};
};

ext-power {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/preonic/preonic_rev3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ supported:
- lsm303dlhc
- nvs
- can
- kscan
- kscan
2 changes: 2 additions & 0 deletions app/boards/arm/s40nc/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# S40NC

![S40NC](https://i.imgur.com/fk8587n.jpg)

Shorty40NoCordy (S40NC) is a limited run 40% bluetooth keyboard originally made and sold by MechWild.

## Building S40NC ZMK firmware

```
west build -p -b s40nc
```
8 changes: 4 additions & 4 deletions app/boards/arm/s40nc/s40nc.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/ {
keymap {
compatible = "zmk,keymap";

default_layer {
bindings = <
&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC
Expand All @@ -35,7 +35,7 @@
&trans &trans &trans &kp TAB &kp TAB &kp TAB &kp HOME &kp PG_DN &kp END
>;
};

raise_layer {
bindings = <
&kp TILDE &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp STAR &kp LPAR &kp RPAR &trans
Expand All @@ -44,7 +44,7 @@
&trans &trans &trans &kp TAB &kp TAB &kp TAB &kp HOME &kp PG_DN &kp END
>;
};

control_layer {
bindings = <
&bt BT_CLR &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp C_PP
Expand All @@ -55,4 +55,4 @@
};
};
};

8 changes: 4 additions & 4 deletions app/boards/shields/bfo9000/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Customizable full-size split ortholinear.

## Features

* Compatible with MX-compatible, Alps-compatible, and Kailh Low-Profile Choc switches.
* Breakoff pieces to allow for 4 to 6 rows and 7 to 9 columns.
* RGB LED connections
- Compatible with MX-compatible, Alps-compatible, and Kailh Low-Profile Choc switches.
- Breakoff pieces to allow for 4 to 6 rows and 7 to 9 columns.
- RGB LED connections

## Hardware Notes

[Included default keymap](http://www.keyboard-layout-editor.com/#/gists/51293c31afcd5f1765e8f413a46bfcf8)
[Included default keymap](http://www.keyboard-layout-editor.com/#/gists/51293c31afcd5f1765e8f413a46bfcf8)
6 changes: 3 additions & 3 deletions app/boards/shields/boardsource5x12/boardsource5x12.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: MIT
*/

#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
Expand All @@ -28,7 +28,7 @@
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH
&kp LSHFT &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT
&kp LCTRL &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RET
&mo 3 &kp LCTRL &kp LALT &kp LGUI &mo 1 &kp SPACE &kp SPACE &mo 2 &kp LEFT &kp DOWN &kp UP &kp RIGHT
&mo 3 &kp LCTRL &kp LALT &kp LGUI &mo 1 &kp SPACE &kp SPACE &mo 2 &kp LEFT &kp DOWN &kp UP &kp RIGHT
>;
};

Expand All @@ -44,7 +44,7 @@
&kp TILDE &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp ASTRK &kp LPAR &kp RPAR &kp DEL
&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp UNDER &kp PLUS &kp LBRC &kp RBRC &kp PIPE
&trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp LS(NON_US_HASH) &kp LS(NON_US_BSLH) &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &mo 3 &kp C_NEXT &kp C_VOL_DN &kp C_VOL_UP &kp C_PLAY_PAUSE
&trans &trans &trans &trans &trans &trans &trans &mo 3 &kp C_NEXT &kp C_VOL_DN &kp C_VOL_UP &kp C_PLAY_PAUSE
>;
};

Expand Down
2 changes: 1 addition & 1 deletion app/boards/shields/boardsource5x12/boardsource5x12.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
, <&pro_micro 6 GPIO_ACTIVE_HIGH>
;
};
};
};
8 changes: 4 additions & 4 deletions app/boards/shields/chalice/chalice.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
bindings = <
&kp ESC &kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC
&kp INSERT &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH
&kp DELETE &kp CAPS &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp ENTER
&kp DELETE &kp CAPS &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp ENTER
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp B &kp N &kp M &kp COMMA &kp DOT &kp SLASH &kp RSHFT &kp UP
&kp LCTRL &kp LALT &kp SPACE &mo 1 &kp SPACE &kp RALT &kp RCTRL &kp LEFT &kp DOWN &kp RIGHT
&kp LCTRL &kp LALT &kp SPACE &mo 1 &kp SPACE &kp RALT &kp RCTRL &kp LEFT &kp DOWN &kp RIGHT
>;
};

Expand All @@ -30,9 +30,9 @@
bindings = <
&bootloader &out OUT_TOG &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans
&trans &bt BT_CLR &rgb_ug RGB_TOG &rgb_ug RGB_HUD &rgb_ug RGB_HUI &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &bt BT_SEL 0 &rgb_ug RGB_EFF &rgb_ug RGB_SAD &rgb_ug RGB_SAI &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &bt BT_SEL 0 &rgb_ug RGB_EFF &rgb_ug RGB_SAD &rgb_ug RGB_SAI &trans &trans &trans &trans &trans &trans &trans &trans &trans
&bt BT_SEL 1 &rgb_ug RGB_EFR &rgb_ug RGB_BRD &rgb_ug RGB_BRI &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp PG_UP
&bt BT_SEL 2 &trans &trans &trans &trans &trans &trans &kp HOME &kp PG_DN &kp END
&bt BT_SEL 2 &trans &trans &trans &trans &trans &trans &kp HOME &kp PG_DN &kp END
>;
};
};
Expand Down
Loading

0 comments on commit 32ae776

Please sign in to comment.