Skip to content

Commit 2c0ef3e

Browse files
committed
feat: Add CI workflow and upgrade to Go 1.25
- Add comprehensive GitHub Actions CI workflow with linting, testing, static analysis, and cross-platform builds - Add golangci-lint configuration with multiple linters enabled - Upgrade Go version from 1.22 to 1.25 in go.mod - Update release workflow to use Go 1.25 and setup-go@v5 - CI includes jobs for: lint, test (multi-OS), build (cross-platform), staticcheck, and go vet - Test job runs on Ubuntu, macOS, and Windows with race detection and coverage reporting
1 parent 9b8c14a commit 2c0ef3e

File tree

4 files changed

+229
-4
lines changed

4 files changed

+229
-4
lines changed

.github/workflows/ci.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- next
8+
- next-major
9+
- beta
10+
- alpha
11+
pull_request:
12+
branches:
13+
- main
14+
15+
jobs:
16+
lint:
17+
name: Lint
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.25'
27+
28+
- name: Configure git for private modules
29+
env:
30+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
31+
run: git config --global url."https://gsmlg:${TOKEN}@github.com".insteadOf "https://github.com"
32+
33+
- name: golangci-lint
34+
uses: golangci/golangci-lint-action@v6
35+
with:
36+
version: latest
37+
args: --timeout=5m
38+
env:
39+
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang
40+
41+
test:
42+
name: Test
43+
runs-on: ${{ matrix.os }}
44+
strategy:
45+
matrix:
46+
os: [ubuntu-latest, macos-latest, windows-latest]
47+
go-version: ['1.25']
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Go
53+
uses: actions/setup-go@v5
54+
with:
55+
go-version: ${{ matrix.go-version }}
56+
57+
- name: Configure git for private modules
58+
env:
59+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
60+
run: git config --global url."https://gsmlg:${TOKEN}@github.com".insteadOf "https://github.com"
61+
62+
- name: Download dependencies
63+
run: go mod download
64+
env:
65+
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang
66+
67+
- name: Run tests
68+
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
69+
env:
70+
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang
71+
72+
- name: Upload coverage to Codecov
73+
if: matrix.os == 'ubuntu-latest'
74+
uses: codecov/codecov-action@v4
75+
with:
76+
file: ./coverage.out
77+
flags: unittests
78+
name: codecov-umbrella
79+
fail_ci_if_error: false
80+
81+
build:
82+
name: Build
83+
runs-on: ubuntu-latest
84+
strategy:
85+
matrix:
86+
goos: [linux, darwin, windows, freebsd]
87+
goarch: [amd64, arm64]
88+
exclude:
89+
- goos: windows
90+
goarch: arm64
91+
steps:
92+
- name: Checkout code
93+
uses: actions/checkout@v4
94+
95+
- name: Setup Go
96+
uses: actions/setup-go@v5
97+
with:
98+
go-version: '1.25'
99+
100+
- name: Configure git for private modules
101+
env:
102+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
103+
run: git config --global url."https://gsmlg:${TOKEN}@github.com".insteadOf "https://github.com"
104+
105+
- name: Build binary
106+
run: |
107+
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -v -o gsmlg-cli-${{ matrix.goos }}-${{ matrix.goarch }} .
108+
env:
109+
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang
110+
111+
staticcheck:
112+
name: Static Analysis
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout code
116+
uses: actions/checkout@v4
117+
118+
- name: Setup Go
119+
uses: actions/setup-go@v5
120+
with:
121+
go-version: '1.25'
122+
123+
- name: Configure git for private modules
124+
env:
125+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
126+
run: git config --global url."https://gsmlg:${TOKEN}@github.com".insteadOf "https://github.com"
127+
128+
- name: Install staticcheck
129+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
130+
131+
- name: Run staticcheck
132+
run: staticcheck ./...
133+
env:
134+
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang
135+
136+
vet:
137+
name: Go Vet
138+
runs-on: ubuntu-latest
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
143+
- name: Setup Go
144+
uses: actions/setup-go@v5
145+
with:
146+
go-version: '1.25'
147+
148+
- name: Configure git for private modules
149+
env:
150+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
151+
run: git config --global url."https://gsmlg:${TOKEN}@github.com".insteadOf "https://github.com"
152+
153+
- name: Download dependencies
154+
run: go mod download
155+
env:
156+
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang
157+
158+
- name: Run go vet
159+
run: go vet ./...
160+
env:
161+
GOPRIVATE: github.com/gsmlg-dev/gsmlg-golang

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Setup golang
26-
uses: actions/setup-go@v3
26+
uses: actions/setup-go@v5
2727
with:
28-
go-version: '1.22.1'
28+
go-version: '1.25'
2929

3030
- name: Configure git for private modules
3131
env:

.golangci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
linters-settings:
2+
errcheck:
3+
check-type-assertions: true
4+
check-blank: true
5+
govet:
6+
enable-all: true
7+
gocyclo:
8+
min-complexity: 15
9+
dupl:
10+
threshold: 100
11+
misspell:
12+
locale: US
13+
lll:
14+
line-length: 140
15+
goconst:
16+
min-len: 3
17+
min-occurrences: 3
18+
funlen:
19+
lines: 100
20+
statements: 50
21+
22+
linters:
23+
enable:
24+
- errcheck
25+
- gosimple
26+
- govet
27+
- ineffassign
28+
- staticcheck
29+
- unused
30+
- gofmt
31+
- goimports
32+
- misspell
33+
- goconst
34+
- dupl
35+
- lll
36+
- unconvert
37+
- gocyclo
38+
- funlen
39+
- revive
40+
- gosec
41+
- exportloopref
42+
- whitespace
43+
disable:
44+
- structcheck
45+
- varcheck
46+
- deadcode
47+
- ifshort
48+
49+
issues:
50+
exclude-rules:
51+
- path: _test\.go
52+
linters:
53+
- gocyclo
54+
- errcheck
55+
- dupl
56+
- gosec
57+
- funlen
58+
59+
max-issues-per-linter: 0
60+
max-same-issues: 0
61+
62+
run:
63+
timeout: 5m
64+
tests: true

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/gsmlg-dev/gsmlg-cli
22

3-
go 1.22
3+
go 1.25
44

5-
toolchain go1.22.1
5+
toolchain go1.25.0
66

77
require (
88
github.com/Masterminds/semver/v3 v3.2.1

0 commit comments

Comments
 (0)