-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
588e27e
commit fb236ec
Showing
1 changed file
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,50 @@ | ||
on:push | ||
name: Go Lint | ||
|
||
# 触发条件 | ||
on: | ||
# 当推送到 main 分支时触发 | ||
push: | ||
branches: [ main ] | ||
# 当对任何分支发起 pull request 时触发 | ||
pull_request: | ||
branches: [ '**' ] | ||
|
||
# 定义工作流程 | ||
jobs: | ||
first job: | ||
runs-on :windows-latest | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- run:node --version | ||
- run:npm --version | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
cache: true | ||
|
||
|
||
- name: Install dependencies | ||
run: go mod download | ||
|
||
|
||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
args: --timeout=5m | ||
|
||
|
||
- name: Check code formatting | ||
run: | | ||
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | ||
echo "Code is not properly formatted. Please run 'go fmt'" | ||
gofmt -s -l . | ||
exit 1 | ||
fi | ||
|
||
- name: Run go vet | ||
run: go vet ./... |