This repository was archived by the owner on Jun 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (166 loc) · 5.75 KB
/
Copy pathutify.yml
File metadata and controls
179 lines (166 loc) · 5.75 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
permissions:
contents: write
name: Utify CI/CD Pipeline
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
schedule:
- cron: '0 2 * * 1'
workflow_dispatch:
jobs:
validate:
name: Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify modules and tidy
run: |
go mod verify
go mod tidy
if [ -f go.sum ]; then
git diff --exit-code go.mod go.sum
else
git diff --exit-code go.mod
fi
- name: Run tests with full coverage (all packages + tests)
run: |
go test -v -race -timeout=10m -covermode=atomic -coverprofile=coverage.out $(go list ./... | grep -v /examples)
- name: Run benchmarks
run: go test -bench=. -benchtime=5s ./tests/benchmarks/...
- name: Analyze coverage
run: |
go tool cover -func=coverage.out
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 90" | bc -l) )); then
echo "Coverage below 90% - failing." && exit 1
fi
- name: Upload coverage reports to Codecov
if: github.ref == 'refs/heads/main'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: jsas4coding/utify
quality:
name: Code Quality & Security
runs-on: ubuntu-latest
needs: validate
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-
- name: Run static analysis
run: |
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run ./...
gocyclo -over 15 .
release:
name: Release Validation & Preparation
runs-on: ubuntu-latest
needs: validate
if: startsWith(github.ref, 'refs/tags/v')
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version
id: get-version
run: |
RAW_VERSION="${GITHUB_REF#refs/tags/}" # e.g., v1.5.1
CLEAN_VERSION="${RAW_VERSION#v}" # e.g., 1.5.1
echo "version=${RAW_VERSION}" >> $GITHUB_OUTPUT
echo "clean_version=${CLEAN_VERSION}" >> $GITHUB_OUTPUT
- name: Validate tag format
run: |
if ! [[ "${{ steps.get-version.outputs.clean_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Invalid version format: ${{ steps.get-version.outputs.clean_version }}" && exit 1
fi
- name: Validate changelog file
run: |
FILE="changelogs/${{ steps.get-version.outputs.clean_version }}.md"
if [ ! -f "$FILE" ]; then
echo "Changelog file $FILE not found for this version!" && exit 1
fi
if ! grep -q "(${FILE})" CHANGELOG.md; then
echo "Changelog file $FILE is missing from the main CHANGELOG.md index!" && exit 1
fi
cp "$FILE" RELEASE_BODY.md
- name: Build all examples
run: |
mkdir -p dist/examples
for dir in ./examples/*/ ; do
name=$(basename "$dir")
go build -o "dist/examples/$name" "$dir"
done
- name: Generate coverage report (Markdown)
run: |
go tool cover -func=coverage.out | tee coverage_report.txt
echo "# Coverage Report" > coverage_report.md
echo '```' >> coverage_report.md
cat coverage_report.txt >> coverage_report.md
echo '```' >> coverage_report.md
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage_report.md
- name: Create or Update GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get-version.outputs.version }}
name: Utify Release ${{ steps.get-version.outputs.version }}
body_path: RELEASE_BODY.md
files: dist/examples/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-packages:
name: Publish Packages
runs-on: ubuntu-latest
needs: release
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-
- name: Publish to Go Module Proxy
run: |
VERSION="${{ needs.release.outputs.version }}"
echo "Publishing ${VERSION} to Go module proxy..."
GOPROXY=proxy.golang.org go list -m github.com/jsas4coding/utify@${VERSION}
- name: Confirm publication
run: echo "Release ${{ needs.release.outputs.version }} published successfully!"