-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (135 loc) · 3.8 KB
/
ci.yaml
File metadata and controls
163 lines (135 loc) · 3.8 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
name: CI/CD
on:
push:
branches:
- "**"
tags: ["v*"]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GO_VERSION: "1.26"
jobs:
test:
name: Lint & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version-file: .golangci-lint-version
args: ./cmd/... ./internal/...
- name: Run tests
run: |
go test -v -race -coverprofile=coverage.out ./...
- name: Run govulncheck
uses: golang/govulncheck-action@v1
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
files: coverage.out
disable_search: true
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Generate coverage summary
run: |
go tool cover -func=coverage.out | tee coverage.txt
echo "## Coverage" >> "$GITHUB_STEP_SUMMARY"
echo '```text' >> "$GITHUB_STEP_SUMMARY"
cat coverage.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
property:
name: Property Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run property-based tests
run: ./scripts/property_test.sh
build:
name: Build binaries
runs-on: ubuntu-latest
needs:
- test
- property
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Compute build version
id: build_version
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
echo "value=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
else
echo "value=dev-${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
fi
- name: Build
run: |
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then
EXT=".exe"
fi
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -ldflags="-s -w -X main.version=${{ steps.build_version.outputs.value }}" \
-o ragcli-${{ matrix.goos }}-${{ matrix.goarch }}$EXT ./cmd/ragcli
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ragcli-${{ matrix.goos }}-${{ matrix.goarch }}
path: ragcli-${{ matrix.goos }}-${{ matrix.goarch }}*
release:
name: Release
runs-on: ubuntu-latest
needs:
- test
- property
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean --config .goreleaser.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}