docs: 移除重复的文档部署工作流 #21
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 ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| test: | |
| name: Test and Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.18' | |
| cache: true | |
| - name: Get dependencies | |
| run: go mod download | |
| - name: Verify code formatting | |
| run: | | |
| if [ -n "$(gofmt -l .)" ]; then | |
| echo "The following files are not formatted correctly:" | |
| gofmt -l . | |
| exit 1 | |
| fi | |
| - name: Run vet | |
| run: go vet ./... | |
| - name: Run standard tests | |
| run: go test -v ./... | |
| - name: Run tests with race detection | |
| run: go test -race -v ./... | |
| - name: Run coverage | |
| run: go test -coverprofile=coverage.out -covermode=atomic ./... | |
| - name: Display coverage | |
| run: go tool cover -func=coverage.out | |
| - name: Upload coverage report | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.out | |
| fail_ci_if_error: false | |
| verbose: true | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.18' | |
| cache: true | |
| - name: Get dependencies | |
| run: go mod download | |
| - name: Build | |
| run: go build -v ./... | |
| - name: Build examples | |
| run: | | |
| for dir in examples/*/; do | |
| echo "Building example in $dir" | |
| cd "$dir" | |
| go mod tidy || true | |
| go build -v || echo "Warning: Failed to build example in $dir" | |
| cd - > /dev/null | |
| done |