Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ VARIABLE+=ESPPORT
HELP_ESPPORT=which device to flash/monitor
export ESPPORT

VARIABLE+=FORMAT
HELP_FORMAT=patterns of files to format
ifndef FORMAT
FORMAT += **/*.h
FORMAT += **/*.c
FORMAT += !**/build/**/*
endif

### internal variables ###

# assume /etc/passwd holds right shell of user
Expand All @@ -31,6 +39,8 @@ TEMPLATEPATH=../.Makefile.template
### default target ###
DEFAULT += help

UNCRUSTIFY_CFG = ./.uncrustify.cfg

### menuconfig targets ###

.PHONY: menuconfig
Expand Down Expand Up @@ -107,6 +117,28 @@ CHECK += check-monitor
HELP_check-monitor = check env if monitor is possible
check-monitor: | check-docker check-dev

### code format

.PHONY: format
TARGET += format
HELP_format = formats code with uncrustify
format: | check-docker
@make --no-print-directory -C $(DOCKERDIR) uncrustify \
EXEC="git ls-files -ico $(foreach PATTERN,$(FORMAT),-x $(PATTERN)) \
| xargs -I % uncrustify -c $(UNCRUSTIFY_CFG) --replace --no-backup %"

.PHONY: check-format
TARGET += check-format
HELP_check-format = check if formatting code with uncrustify is necessary
check-format: | check-docker
@make --no-print-directory -C $(DOCKERDIR) uncrustify \
EXEC="git ls-files -ico $(foreach PATTERN,$(FORMAT),-x $(PATTERN)) \
| xargs -I % sh -c \"uncrustify -c $(UNCRUSTIFY_CFG) -f % \
| git diff --exit-code \
--no-index \
--color \
% - \""

### vscode ###

.PHONY: vscode
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Check code format

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: build uncrustify image
run: make -C docker uncrustify-image
- name: check code format
run: make -C lifesensor DOCKEROPTS=--tty=false check-format
Loading