|
1 | 1 | name: Build and Test |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
7 | | - pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - job_go_checks: |
11 | | - runs-on: ubuntu-latest |
12 | | - defaults: |
13 | | - run: |
14 | | - shell: bash |
15 | | - steps: |
16 | | - - name: Checkout code |
17 | | - uses: actions/checkout@v4 |
18 | | - with: |
19 | | - fetch-depth: 1 |
20 | | - - name: Set up Go environment |
21 | | - uses: actions/setup-go@v5 |
22 | | - with: |
23 | | - go-version: "1.24" |
24 | | - - name: Tidy go module |
25 | | - run: | |
26 | | - go mod tidy |
27 | | - if [[ $(git status --porcelain) ]]; then |
28 | | - git diff |
29 | | - echo |
30 | | - echo "go mod tidy made these changes, please run 'go mod tidy' and include those changes in a commit" |
31 | | - exit 1 |
32 | | - fi |
33 | | - - name: Run gofumpt |
34 | | - run: diff -u <(echo -n) <(go run mvdan.cc/gofumpt@@latest -d .) |
35 | | - - name: Run go vet |
36 | | - run: go vet ./... |
| 10 | + job_go_checks: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + defaults: |
| 13 | + run: |
| 14 | + shell: bash |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 1 |
| 20 | + - name: Set up Go environment |
| 21 | + uses: actions/setup-go@v5 |
| 22 | + with: |
| 23 | + go-version: "1.24" |
| 24 | + - name: Tidy go module |
| 25 | + run: | |
| 26 | + go mod tidy |
| 27 | + if [[ $(git status --porcelain) ]]; then |
| 28 | + git diff |
| 29 | + echo |
| 30 | + echo "go mod tidy made these changes, please run 'go mod tidy' and include those changes in a commit" |
| 31 | + exit 1 |
| 32 | + fi |
| 33 | + - name: Run gofumpt |
| 34 | + run: diff -u <(echo -n) <(go run mvdan.cc/gofumpt@@latest -d .) |
| 35 | + - name: Run go vet |
| 36 | + run: go vet ./... |
37 | 37 |
|
38 | | - job_go_test: |
39 | | - runs-on: ubuntu-latest |
40 | | - steps: |
41 | | - - name: Checkout code |
42 | | - uses: actions/checkout@v4 |
43 | | - with: |
44 | | - fetch-depth: 2 |
45 | | - - name: Set up Go environment |
46 | | - uses: actions/setup-go@v5 |
47 | | - with: |
48 | | - go-version: "1.24" |
49 | | - - name: Run Go test -race |
50 | | - run: go test ./... -v -race -timeout=1h |
51 | | - - name: Rerun Go test to generate coverage report |
52 | | - run: | |
53 | | - go test -v -timeout 15m -coverprofile=./cover.out -json ./... > tests.log |
54 | | - - name: Convert report to html |
55 | | - run: go tool cover -html=cover.out -o cover.html |
56 | | - - name: Print coverage report |
57 | | - run: | |
58 | | - set -o pipefail && cat tests.log | node .github/parse-coverage-report.js >> $GITHUB_STEP_SUMMARY |
59 | | - echo $GITHUB_STEP_SUMMARY |
60 | | - - name: Print coverage report |
61 | | - run: | |
62 | | - go tool cover -func=cover.out > ./cover.txt |
63 | | - echo "<details><summary>📏 Tests coverage</summary>" >> $GITHUB_STEP_SUMMARY |
64 | | - echo -e "\n\`\`\`" >> $GITHUB_STEP_SUMMARY |
65 | | - cat ./cover.txt >> $GITHUB_STEP_SUMMARY |
66 | | - echo -e "\`\`\`\n</details>" >> $GITHUB_STEP_SUMMARY |
67 | | - - name: Store coverage report |
68 | | - uses: actions/upload-artifact@v4 |
69 | | - with: |
70 | | - name: report |
71 | | - path: | |
72 | | - tests.log |
73 | | - cover.txt |
74 | | - cover.out |
75 | | - cover.html |
| 38 | + job_go_test: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + fetch-depth: 2 |
| 45 | + - name: Set up Go environment |
| 46 | + uses: actions/setup-go@v5 |
| 47 | + with: |
| 48 | + go-version: "1.24" |
| 49 | + - name: Run Go test -race |
| 50 | + run: go test ./... -v -race -timeout=1h |
0 commit comments