perf(ci): 启用 Go 模块缓存,缓存 golangci-lint 二进制
This commit is contained in:
@@ -22,15 +22,22 @@ jobs:
|
|||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: Download dependencies
|
- name: Cache golangci-lint
|
||||||
run: go mod download
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: /usr/local/bin/golangci-lint
|
||||||
|
key: golangci-lint-${{ env.GOLANGCI_LINT_VERSION }}
|
||||||
|
|
||||||
|
- name: Install golangci-lint
|
||||||
|
run: |
|
||||||
|
if [ ! -f /usr/local/bin/golangci-lint ]; then
|
||||||
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin ${{ env.GOLANGCI_LINT_VERSION }}
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v4
|
run: golangci-lint run --timeout=5m --issues-exit-code=0
|
||||||
with:
|
|
||||||
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
|
||||||
args: --timeout=5m --issues-exit-code=0
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
@@ -43,13 +50,10 @@ jobs:
|
|||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
cache: true
|
||||||
- name: Download dependencies
|
|
||||||
run: go mod download
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
# 跳过无测试文件的情况
|
|
||||||
test_files=$(find . -name "*_test.go" -type f)
|
test_files=$(find . -name "*_test.go" -type f)
|
||||||
if [ -z "$test_files" ]; then
|
if [ -z "$test_files" ]; then
|
||||||
echo "No test files found, skipping tests"
|
echo "No test files found, skipping tests"
|
||||||
@@ -76,9 +80,7 @@ jobs:
|
|||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
cache: true
|
||||||
- name: Download dependencies
|
|
||||||
run: go mod download
|
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user