-
Notifications
You must be signed in to change notification settings - Fork 11
94 lines (77 loc) · 2.42 KB
/
Copy pathtests-static-check.yaml
File metadata and controls
94 lines (77 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Tests & Static Analysis
env:
GO_VERSION: "1.26.0"
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
jobs:
lint:
name: Lint & Vulnerabilities
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Verify dependencies
run: go mod verify
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=5m
- name: Run golvulncheck
uses: golang/govulncheck-action@v1
continue-on-error: true
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run tests
if: ${{ matrix.os != 'ubuntu-latest' }}
run: go test -race ./...
- name: Run tests (with coverage)
if: ${{ matrix.os == 'ubuntu-latest' }} # collect & upload coverage only from one of the runners
run: go test -race -coverprofile=coverage.out ./...
- name: Check code coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
go tool cover -func=coverage.out -o=coverage.txt
go tool cover -html=coverage.out -o=coverage.html
- name: Upload coverage artifacts
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.out
coverage.html
coverage.txt
- name: Upload coverage data to Codecov
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
name: codecov-umbrella
slug: Warp-net/warpnet
fail_ci_if_error: true
- name: Calculate coverage
if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }}
id: coverage
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT