From 089cc271d56756e3a7b5e7a2f531ec2480e7b1fe Mon Sep 17 00:00:00 2001 From: runkecheng <1131648942@qq.com> Date: Wed, 19 Jan 2022 11:13:50 +0800 Subject: [PATCH] ci: go fmt and static check. --- .github/workflows/code_check.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/code_check.yml diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml new file mode 100644 index 0000000..dd5959a --- /dev/null +++ b/.github/workflows/code_check.yml @@ -0,0 +1,40 @@ +name: code check + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + + gofmt: + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + + - name: Check out source code + uses: actions/checkout@v1 + + - name: Run go fmt + run: d="$(gofmt -d ../../)" && if [ -n "$d" ]; then echo "format error:" ; echo "$d"; exit 1; fi + + staticcheck: + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + + - name: Check out source code + uses: actions/checkout@v1 + + - name: Install staticcheck + run: go get honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck -f stylish ./...