-
-
Notifications
You must be signed in to change notification settings - Fork 19
124 lines (105 loc) · 3 KB
/
ci.yml
File metadata and controls
124 lines (105 loc) · 3 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
name: CI
on:
push:
branches: [master, develop]
pull_request:
branches: [master]
# Set default permissions for all jobs
permissions:
contents: read
packages: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: .go-version
cache: true
cache-dependency-path: go.sum
- name: Run go vet
run: go vet ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=5m
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: .go-version
cache: true
cache-dependency-path: go.sum
- name: Run tests
run: |
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -func=coverage.out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
file: ./coverage.out
fail_ci_if_error: false
build:
name: Build
needs: [test] # Only depend on test, not lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: .go-version
cache: true
cache-dependency-path: go.sum
- name: Build binary (Windows)
if: matrix.os == 'windows-latest'
run: |
New-Item -ItemType Directory -Force -Path dist
go build -ldflags="-s -w" -o ./dist/pvetui.exe ./cmd/pvetui
- name: Build binary (Unix)
if: matrix.os != 'windows-latest'
run: |
mkdir -p dist
go build -ldflags="-s -w" -o ./dist/pvetui ./cmd/pvetui
- name: List built files (debug)
if: matrix.os == 'windows-latest'
run: |
Write-Host "Contents of dist directory:"
Get-ChildItem .\dist\
- name: List built files (debug)
if: matrix.os != 'windows-latest'
run: |
echo "Contents of dist directory:"
ls -la dist/
- name: Test binary (Unix)
if: matrix.os != 'windows-latest'
run: ./dist/pvetui --help
- name: Test binary (Windows)
if: matrix.os == 'windows-latest'
run: |
if (Test-Path ".\dist\pvetui.exe") {
.\dist\pvetui.exe --help
} else {
Write-Error "Binary not found at .\dist\pvetui.exe"
Get-ChildItem .\dist\
exit 1
}
- name: Upload artifacts
if: success()
uses: actions/upload-artifact@v7
with:
name: binary-${{ matrix.os }}
path: dist/
if-no-files-found: error