-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (96 loc) · 3.09 KB
/
Copy pathpush.yml
File metadata and controls
116 lines (96 loc) · 3.09 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
name: CI
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: ["main", "master", "dev"]
pull_request:
branches: ["*"]
permissions:
contents: read
jobs:
lint:
name: Static Code Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
id: setup-go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
- name: Check Formatting (gofmt)
run: |
unformatted=$(gofmt -s -l .)
if [ -n "$unformatted" ]; then
echo "The following files are not formatted correctly:"
echo "$unformatted"
echo "Please run 'gofmt -w .' locally to fix them."
exit 1
fi
- name: Cache golangci-lint binary
id: cache-golangci-lint
uses: actions/cache@v4
with:
path: ~/go/bin/golangci-lint
key: ${{ runner.os }}-golangci-lint-latest-${{ steps.setup-go.outputs.go-version }}
- name: Install golangci-lint
if: steps.cache-golangci-lint.outputs.cache-hit != 'true'
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
- name: Run golangci-lint
run: $(go env GOPATH)/bin/golangci-lint run --config=.golangci.yml
vulncheck:
name: Security Vulnerability Scan
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
id: setup-go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
- name: Cache govulncheck binary
id: cache-govulncheck
uses: actions/cache@v4
with:
path: ~/go/bin/govulncheck
key: ${{ runner.os }}-govulncheck-latest-${{ steps.setup-go.outputs.go-version }}
- name: Install govulncheck
if: steps.cache-govulncheck.outputs.cache-hit != 'true'
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run govulncheck
run: govulncheck ./...
test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
- name: Download Go dependencies
run: go mod download
- name: Build Project
run: go build -v ./...
- name: Run Unit Tests
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Generate Coverage Summary
if: always()
run: |
if [ -f coverage.out ]; then
echo "### Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
go tool cover -func=coverage.out >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "### Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "No coverage file found." >> $GITHUB_STEP_SUMMARY
fi