-
Notifications
You must be signed in to change notification settings - Fork 4
49 lines (47 loc) · 1.67 KB
/
test.yml
File metadata and controls
49 lines (47 loc) · 1.67 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
name: Go Tests
on:
pull_request:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: '1.26.2'
- name: Export Go module cache path
run: echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV"
- name: Restore module cache
id: modcache
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ env.GOMODCACHE }}
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
- name: Download dependencies
run: go mod download
- name: Vet code
run: go vet ./...
- name: Lint (optional)
run: |
if command -v golangci-lint >/dev/null 2>&1; then
golangci-lint run
else
echo "golangci-lint not installed, skipping"
fi
- name: Check formatting
run: test -z "$(gofmt -l .)"
- name: Run tests with coverage
run: go test -coverprofile=coverage.out ./...
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5.5.4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Save module cache
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: ${{ steps.modcache.outputs.cache-hit != 'true' }}
with:
path: ${{ env.GOMODCACHE }}
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}