Skip to content

Commit

Permalink
feat: add go format workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Norton-Lin committed Oct 28, 2024
1 parent 67104f3 commit fa389ed
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/golint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Go Format Check

on:
push:
pull_request:
workflow_dispatch:

jobs:
gofmt:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
- name: Run golangci-lint
run: golangci-lint run

- name: Check Go format
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Go code is not formatted:"
gofmt -d .
exit 1
else
echo "Go code is properly formatted"
fi
4 changes: 1 addition & 3 deletions .github/workflows/prlint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Commitlint

on:
push:
branches-ignore: ["main"] # 排除 main 分支的 push 事件
pull_request:
branches-ignore: ["main"] # 排除 main 分支的 pull request 事件
branches: ["main"] # 排除 main 分支的 pull request 事件
workflow_dispatch:

jobs:
Expand Down

0 comments on commit fa389ed

Please sign in to comment.