Skip to content

Commit 84655fa

Browse files
committed
Add initial github action: ci.yml
1 parent 9a12452 commit 84655fa

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

.github/workflows/ci.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: ['**']
8+
9+
jobs:
10+
golangci-lint:
11+
name: golangci-lint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v5
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v6
20+
with:
21+
go-version: '1.23'
22+
cache: false # golangci-lint-action handles its own caching
23+
24+
- name: Run golangci-lint
25+
uses: golangci/golangci-lint-action@v9
26+
with:
27+
version: latest
28+
29+
- name: Check for formatting issues
30+
run: |
31+
if [ -n "$(gofmt -l .)" ]; then
32+
echo "Go code is not formatted:"
33+
gofmt -d .
34+
exit 1
35+
fi
36+
37+
go-vet:
38+
name: go vet
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v5
44+
45+
- name: Set up Go
46+
uses: actions/setup-go@v6
47+
with:
48+
go-version: '1.23'
49+
cache: true
50+
51+
- name: Run go vet
52+
run: go vet ./...
53+
54+
staticcheck:
55+
name: staticcheck
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v5
61+
62+
- name: Set up Go
63+
uses: actions/setup-go@v6
64+
with:
65+
go-version: '1.23'
66+
cache: true
67+
68+
- name: Install staticcheck
69+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
70+
71+
- name: Run staticcheck
72+
run: staticcheck ./...
73+
74+
build:
75+
name: Build (Alpine)
76+
runs-on: ubuntu-latest
77+
container:
78+
image: golang:1.23-alpine
79+
80+
steps:
81+
- name: Install build dependencies
82+
run: apk add --no-cache gcc musl-dev ncurses-dev ncurses-static git
83+
84+
- name: Checkout code
85+
uses: actions/checkout@v5
86+
87+
- name: Build binary
88+
run: |
89+
cd cmd/yc
90+
go build -buildvcs=false -ldflags="-s -w" -o yc
91+
./yc --version || true
92+
93+
test:
94+
name: Test (Ubuntu)
95+
runs-on: ubuntu-latest
96+
97+
steps:
98+
- name: Checkout code
99+
uses: actions/checkout@v5
100+
101+
- name: Set up Go
102+
uses: actions/setup-go@v6
103+
with:
104+
go-version: '1.23'
105+
cache: true
106+
107+
- name: Install Java (for JVM tests)
108+
uses: actions/setup-java@v5
109+
with:
110+
distribution: 'temurin'
111+
java-version: '11'
112+
113+
- name: Download dependencies
114+
run: go mod download
115+
116+
- name: Verify dependencies
117+
run: go mod verify
118+
119+
- name: Run tests (excluding CGO-dependent packages)
120+
run: |
121+
go test -v -race $(go list ./... | grep -v 'internal/cli' | grep -v 'internal/capture/procps/linux')
122+

0 commit comments

Comments
 (0)