From 4063265478ff882648c8776fdcbde9aaf3f16cc3 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Fri, 20 Jan 2023 23:17:59 +0200 Subject: [PATCH] Add checks for gofmt Signed-off-by: Gabriel Adrian Samfira --- .github/workflows/go-tests.yml | 9 +++++---- Makefile | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 5501478e..e6ad1a1c 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -18,19 +18,20 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y libbtrfs-dev + sudo apt-get install -y libbtrfs-dev build-essential - uses: actions/setup-go@v3 + with: + go-version: 'stable' - uses: actions/checkout@v3 - uses: golangci/golangci-lint-action@v3 with: - version: v1.49.0 skip-cache: true args: --timeout=8m --build-tags testing - - name: Verify go vendor and go modules + - name: Verify go vendor, go modules and gofmt run: | sudo apt-get install -y jq - make verify-vendor + make verify go-tests: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 05cf6321..218fdebd 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,9 @@ build-static: test: go test -race -mod=vendor -tags testing -v $(TEST_ARGS) -timeout=15m -parallel=4 -count=1 ./... +fmtcheck: + @gofmt -l -s $$(go list ./... | sed 's|garm/||g') | grep ".*\.go"; if [ "$$?" -eq 0 ]; then echo "gofmt check failed; please tun gofmt -w -s"; exit 1;fi + verify-vendor: ## verify if all the go.mod/go.sum files are up-to-date $(eval TMPDIR := $(shell mktemp -d)) @cp -R ${ROOTDIR} ${TMPDIR} @@ -28,3 +31,4 @@ verify-vendor: ## verify if all the go.mod/go.sum files are up-to-date @diff -r -u -q ${ROOTDIR} ${TMPDIR}/garm @rm -rf ${TMPDIR} +verify: verify-vendor fmtcheck