|
6 | 6 | pull_request: |
7 | 7 | branches: [main, dev] |
8 | 8 |
|
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
9 | 12 | jobs: |
10 | 13 | test: |
11 | 14 | runs-on: ubuntu-latest |
|
14 | 17 | - uses: ./.github/actions/setup-deps |
15 | 18 | with: |
16 | 19 | token: ${{ github.token }} |
17 | | - - run: go test -race -count=1 -timeout=120s ./... |
| 20 | + - name: Run tests with race detector |
| 21 | + run: go test -race -count=1 -timeout=120s ./... |
| 22 | + - name: Run tests with coverage |
| 23 | + run: | |
| 24 | + go test -race -coverprofile=coverage.out -covermode=atomic -timeout=120s ./... |
| 25 | + go tool cover -func=coverage.out | grep "^total:" |
| 26 | + - name: Upload coverage |
| 27 | + uses: actions/upload-artifact@v4 |
| 28 | + with: |
| 29 | + name: coverage |
| 30 | + path: coverage.out |
18 | 31 |
|
19 | 32 | lint: |
20 | 33 | runs-on: ubuntu-latest |
|
37 | 50 | - uses: ./.github/actions/setup-deps |
38 | 51 | with: |
39 | 52 | token: ${{ github.token }} |
40 | | - - run: go install golang.org/x/vuln/cmd/govulncheck@latest && govulncheck ./... || true |
| 53 | + - name: Run govulncheck |
| 54 | + run: | |
| 55 | + go install golang.org/x/vuln/cmd/govulncheck@latest |
| 56 | + govulncheck ./... |
| 57 | + - name: Run gosec |
| 58 | + run: | |
| 59 | + go install github.com/securego/gosec/v2/cmd/gosec@latest |
| 60 | + gosec -exclude=G104,G301,G302,G304,G306 ./... || true |
41 | 61 |
|
42 | 62 | build: |
43 | 63 | runs-on: ubuntu-latest |
|
59 | 79 | GOOS: ${{ matrix.goos }} |
60 | 80 | GOARCH: ${{ matrix.goarch }} |
61 | 81 | CGO_ENABLED: "0" |
62 | | - run: go build -ldflags "-s -w" -o hawk-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} . |
| 82 | + run: | |
| 83 | + go build -ldflags "-s -w -X main.Version=${{ github.sha }}" \ |
| 84 | + -o hawk-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} . |
| 85 | + - name: Upload binary |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: hawk-${{ matrix.goos }}-${{ matrix.goarch }} |
| 89 | + path: hawk-* |
| 90 | + |
| 91 | + benchmark: |
| 92 | + runs-on: ubuntu-latest |
| 93 | + if: github.event_name == 'pull_request' |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + - uses: ./.github/actions/setup-deps |
| 97 | + with: |
| 98 | + token: ${{ github.token }} |
| 99 | + - name: Run benchmarks |
| 100 | + run: go test ./... -bench=. -benchmem -count=3 -timeout=300s | tee bench.txt |
| 101 | + - name: Upload benchmark results |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: benchmarks |
| 105 | + path: bench.txt |
0 commit comments