-
Notifications
You must be signed in to change notification settings - Fork 38
148 lines (119 loc) · 4.1 KB
/
Copy pathunit-tests.yml
File metadata and controls
148 lines (119 loc) · 4.1 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Unit Tests
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
jobs:
test:
name: Unit Tests
runs-on: ${{ matrix.os }}
env:
GO111MODULE: "on"
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ["1.21", "1.22", "1.23.10"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/AppData/Local/go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run unit tests (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: go test -v -race -timeout 5m '-coverprofile=coverage.out' -covermode=atomic '-run=^Test[^E]' ./...
- name: Run unit tests (Unix)
if: matrix.os != 'windows-latest'
run: go test -v -race -coverprofile=coverage.out -run "^Test[^E]" ./...
- name: Generate coverage report (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: go tool cover '-html=coverage.out' -o coverage.html
- name: Generate coverage report (Unix)
if: matrix.os != 'windows-latest'
run: go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23.10'
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Upload coverage artifacts
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23.10'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.out
coverage.html
lint:
name: Lint
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.10"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=5m
build:
name: Build
runs-on: ${{ matrix.os }}
env:
GO111MODULE: "on"
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.10"
- name: Build (Windows)
if: matrix.os == 'windows-latest'
run: go build -v -o mcpproxy.exe ./cmd/mcpproxy
- name: Build (Unix)
if: matrix.os != 'windows-latest'
run: go build -v ./cmd/mcpproxy
- name: Build for different architectures (Linux only)
if: matrix.os == 'ubuntu-latest'
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o mcpproxy-linux-amd64 ./cmd/mcpproxy
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o mcpproxy-linux-arm64 ./cmd/mcpproxy
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o mcpproxy-darwin-amd64 ./cmd/mcpproxy || echo "macOS amd64 cross-compilation may fail (expected)"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o mcpproxy-darwin-arm64 ./cmd/mcpproxy || echo "macOS arm64 cross-compilation may fail (expected)"
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o mcpproxy-windows-amd64.exe ./cmd/mcpproxy
- name: Upload build artifacts
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: binaries
path: mcpproxy-*