Skip to content

Commit c6fdb59

Browse files
committed
ci: add GitHub Actions workflow for test, build and docker verification
Run go vet, race tests and coverage upload on Go 1.24 and 1.25. Build binaries for linux, windows and macos. Verify Docker image build with Buildx and GHA cache.
1 parent fb33b51 commit c6fdb59

1 file changed

Lines changed: 118 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
paths-ignore:
7+
- "**.md"
8+
- "docs/**"
9+
- "LICENSE"
10+
pull_request:
11+
branches: [main, master]
12+
paths-ignore:
13+
- "**.md"
14+
- "docs/**"
15+
- "LICENSE"
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
# ---- Go test matrix ----
22+
test:
23+
name: Test (Go ${{ matrix.go-version }})
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
go-version: ["1.24", "1.25"]
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Go
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: ${{ matrix.go-version }}
37+
cache: true
38+
39+
- name: Vet
40+
run: go vet ./...
41+
42+
- name: Test
43+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
44+
45+
- name: Coverage report
46+
uses: actions/upload-artifact@v4
47+
if: always()
48+
with:
49+
name: coverage-go-${{ matrix.go-version }}
50+
path: coverage.out
51+
52+
# ---- Binary build check ----
53+
build:
54+
name: Build (${{ matrix.os }})
55+
runs-on: ${{ matrix.os }}
56+
needs: test
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
os: [ubuntu-latest, windows-latest, macos-latest]
61+
include:
62+
- os: ubuntu-latest
63+
binary: warpshift-linux-amd64
64+
- os: windows-latest
65+
binary: warpshift-windows-amd64.exe
66+
- os: macos-latest
67+
binary: warpshift-darwin-amd64
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
72+
- name: Setup Go
73+
uses: actions/setup-go@v5
74+
with:
75+
go-version: "1.24"
76+
cache: true
77+
78+
- name: Build
79+
run: |
80+
go build -trimpath -ldflags="-s -w -X main.version=ci-${GITHUB_SHA::8}" -o "${{ matrix.binary }}" ./cmd/warpshift
81+
82+
- name: Verify binary
83+
shell: bash
84+
run: |
85+
if [ ! -f "${{ matrix.binary }}" ]; then
86+
echo "Binary not found: ${{ matrix.binary }}"
87+
exit 1
88+
fi
89+
echo "Built: $(ls -lh ${{ matrix.binary }})"
90+
91+
- name: Upload binary
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: ${{ matrix.binary }}
95+
path: ${{ matrix.binary }}
96+
97+
# ---- Docker image build verification ----
98+
docker-build:
99+
name: Docker Build
100+
runs-on: ubuntu-latest
101+
needs: test
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@v4
105+
106+
- name: Setup Docker Buildx
107+
uses: docker/setup-buildx-action@v3
108+
109+
- name: Build Docker image
110+
uses: docker/build-push-action@v6
111+
with:
112+
context: .
113+
push: false
114+
load: false
115+
build-args: |
116+
VERSION=ci-${GITHUB_SHA::8}
117+
cache-from: type=gha
118+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)