Skip to content

Commit c024956

Browse files
committed
add ci pipeline
1 parent d035fbd commit c024956

3 files changed

Lines changed: 163 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: CI
2+
3+
concurrency:
4+
group: ci-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches: ["*"]
10+
pull_request:
11+
branches: ["*"]
12+
13+
jobs:
14+
lint:
15+
name: Static Code Analysis
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: "1.23"
25+
cache: true
26+
27+
- name: Check Formatting (gofmt)
28+
run: |
29+
unformatted=$(gofmt -l .)
30+
if [ -n "$unformatted" ]; then
31+
echo "The following files are not formatted correctly:"
32+
echo "$unformatted"
33+
echo "Please run 'gofmt -w .' locally to fix them."
34+
exit 1
35+
fi
36+
37+
- name: Run golangci-lint
38+
uses: golangci/golangci-lint-action@v6
39+
with:
40+
version: latest
41+
args: --config=.golangci.yml
42+
43+
vulncheck:
44+
name: Security Vulnerability Scan
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
50+
- name: Set up Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version: "1.23"
54+
cache: true
55+
56+
- name: Run govulncheck
57+
run: |
58+
go install golang.org/x/vuln/cmd/govulncheck@latest
59+
govulncheck ./...
60+
61+
test:
62+
name: Build & Test
63+
runs-on: ubuntu-latest
64+
needs: [lint, vulncheck]
65+
steps:
66+
- name: Checkout repository
67+
uses: actions/checkout@v4
68+
69+
- name: Set up Go
70+
uses: actions/setup-go@v5
71+
with:
72+
go-version: "1.23"
73+
cache: true
74+
75+
- name: Download Go dependencies
76+
run: go mod download
77+
78+
- name: Build Project
79+
run: go build -v ./...
80+
81+
- name: Run Unit Tests
82+
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
83+
84+
- name: Generate Coverage Summary
85+
if: always()
86+
run: |
87+
if [ -f coverage.out ]; then
88+
echo "### Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
89+
echo '```' >> $GITHUB_STEP_SUMMARY
90+
go tool cover -func=coverage.out >> $GITHUB_STEP_SUMMARY
91+
echo '```' >> $GITHUB_STEP_SUMMARY
92+
else
93+
echo "### Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
94+
echo "No coverage file found." >> $GITHUB_STEP_SUMMARY
95+
fi

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: "1.23"
24+
cache: true
25+
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v6
28+
with:
29+
distribution: goreleaser
30+
version: latest
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
project_name: tusshi
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
8+
builds:
9+
- env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- darwin
14+
- windows
15+
goarch:
16+
- amd64
17+
- arm64
18+
main: ./cmd/main.go
19+
20+
archives:
21+
- format: tar.gz
22+
# use zip for windows archives
23+
format_overrides:
24+
- goos: windows
25+
format: zip
26+
27+
checksum:
28+
name_template: "checksums.txt"
29+
30+
changelog:
31+
sort: asc
32+
filters:
33+
exclude:
34+
- "^docs:"
35+
- "^test:"

0 commit comments

Comments
 (0)