扩展artifact.go文件,新增多种制品搜索和分析功能 #18
This file contains hidden or 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
name: Go Tests | |
on: | |
push: | |
branches: [ main, master ] | |
paths-ignore: | |
- '**.md' | |
- 'docs/**' | |
pull_request: | |
branches: [ main, master ] | |
paths-ignore: | |
- '**.md' | |
- 'docs/**' | |
jobs: | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: ['1.18', '1.19', '1.20'] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Set up Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
cache: true | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Get dependencies | |
run: go mod download | |
- name: Verify dependencies | |
run: go mod verify | |
- name: Run tests | |
run: go test -v -race -cover -coverprofile=coverage.out ./... | |
- name: Convert coverage to XML for reporting | |
run: | | |
go install github.com/axw/gocov/gocov@latest | |
go install github.com/AlekSi/gocov-xml@latest | |
gocov convert coverage.out | gocov-xml > coverage.xml | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.xml | |
fail_ci_if_error: false | |
verbose: true | |
flags: unittests,${{ matrix.go-version }} | |
name: codecov-umbrella | |
- name: Run linter | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
args: --timeout=5m | |
skip-pkg-cache: false | |
skip-build-cache: false | |
- name: Build | |
run: go build -v ./... | |
benchmark: | |
name: Run Benchmarks | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
cache: true | |
- name: Run benchmarks | |
run: go test -bench=. -benchmem ./... |