From 859c5e5da4ec39c966b45d700668e87c03d5375b Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Tue, 23 Aug 2022 03:22:51 +0800 Subject: [PATCH] Makefile+github: add `make fmt-check` to check for formatting --- .github/workflows/main.yml | 18 ++++++++++++++++++ Makefile | 4 ++++ docs/release-notes/release-notes-0.16.0.md | 5 ++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e4b2cb1eb..a84ec2ad0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,24 @@ env: GO_VERSION: 1.18.2 jobs: + ######################## + # format code + ######################## + fmt-check: + name: check code format + runs-on: ubuntu-latest + steps: + - name: git checkout + uses: actions/checkout@v3 + + - name: setup go ${{ env.GO_VERSION }} + uses: actions/setup-go@v3 + with: + go-version: '${{ env.GO_VERSION }}' + + - name: fmt + run: make fmt-check + ######################## # RPC and mobile compilation check ######################## diff --git a/Makefile b/Makefile index 4fcb6ae4b..8e0cdd387 100644 --- a/Makefile +++ b/Makefile @@ -258,6 +258,10 @@ fmt: $(GOIMPORTS_BIN) @$(call print, "Formatting source.") gofmt -l -w -s $(GOFILES_NOVENDOR) +fmt-check: fmt + @$(call print, "Checking fmt results.") + if test -n "$$(git status --porcelain)"; then echo "code not formatted correctly, please run `make fmt` again!"; git status; git diff; exit 1; fi + lint: docker-tools @$(call print, "Linting source.") $(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS) diff --git a/docs/release-notes/release-notes-0.16.0.md b/docs/release-notes/release-notes-0.16.0.md index 56555472c..7228cacd1 100644 --- a/docs/release-notes/release-notes-0.16.0.md +++ b/docs/release-notes/release-notes-0.16.0.md @@ -45,6 +45,9 @@ transaction](https://github.com/lightningnetwork/lnd/pull/6730). * [The `golangci-lint` tool was updated to `v1.46.2`](https://github.com/lightningnetwork/lnd/pull/6731) +* Updated the github actions to use `make fmt-check` in its [build + process](https://github.com/lightningnetwork/lnd/pull/6853). + # Contributors (Alphabetical Order) * Carla Kirk-Cohen @@ -55,4 +58,4 @@ transaction](https://github.com/lightningnetwork/lnd/pull/6730). * hieblmi * Olaoluwa Osuntokun * Oliver Gugger -* Priyansh Rastogi \ No newline at end of file +* Priyansh Rastogi