|
| 1 | +name: Go |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + push: |
| 9 | + branches: [master] |
| 10 | + paths: |
| 11 | + - "**.go" |
| 12 | + - "go.mod" |
| 13 | + - "go.sum" |
| 14 | + pull_request: |
| 15 | + branches: [master] |
| 16 | + paths: |
| 17 | + - "**.go" |
| 18 | + - "go.mod" |
| 19 | + - "go.sum" |
| 20 | + |
| 21 | +jobs: |
| 22 | + golangci: |
| 23 | + name: Lint |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + # step 1: checkout repository code |
| 27 | + - name: Checkout code into workspace directory |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + # step 2: set up go |
| 31 | + - name: Set up Go |
| 32 | + uses: actions/setup-go@v5 |
| 33 | + with: |
| 34 | + go-version: stable |
| 35 | + |
| 36 | + # step 3: run golangci-lint |
| 37 | + - name: Run golangci-lint |
| 38 | + uses: golangci/golangci-lint-action@v8 |
| 39 | + with: |
| 40 | + version: latest |
| 41 | + args: --timeout=5m |
| 42 | + |
| 43 | + test: |
| 44 | + name: Test |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + # step 1: checkout repository code |
| 48 | + - name: Checkout code into workspace directory |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + # step 2: set up go |
| 52 | + - name: Set up Go |
| 53 | + uses: actions/setup-go@v5 |
| 54 | + with: |
| 55 | + go-version: stable |
| 56 | + |
| 57 | + # step 3: install dependencies |
| 58 | + - name: Install all Go dependencies |
| 59 | + run: go mod download |
| 60 | + |
| 61 | + # step 4: run test |
| 62 | + - name: Run coverage |
| 63 | + run: go test -race -coverprofile=coverage.out -covermode=atomic ./... |
| 64 | + |
| 65 | + # step 5: upload coverage |
| 66 | + - name: Upload coverage to Codecov |
| 67 | + uses: codecov/codecov-action@v5 |
| 68 | + with: |
| 69 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 70 | + |
| 71 | + benchmark: |
| 72 | + name: Benchmark |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + # step 1: checkout repository code |
| 76 | + - name: Checkout code into workspace directory |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + # step 2: set up go |
| 80 | + - name: Set up Go |
| 81 | + uses: actions/setup-go@v5 |
| 82 | + with: |
| 83 | + go-version: stable |
| 84 | + |
| 85 | + - name: Run benchmarks |
| 86 | + run: go test -bench=. -benchmem ./... | tee benchmark.txt |
| 87 | + |
| 88 | + - name: Upload benchmark results |
| 89 | + uses: benchmark-action/github-action-benchmark@v1 |
| 90 | + with: |
| 91 | + name: Benchmark |
| 92 | + tool: "go" |
| 93 | + output-file-path: benchmark.txt |
| 94 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + auto-push: false |
| 96 | + alert-threshold: "200%" |
| 97 | + comment-on-alert: true |
| 98 | + fail-on-alert: true |
| 99 | + alert-comment-cc-users: "@capcom6" |
0 commit comments