Skip to content

Commit 03d3391

Browse files
committed
Improve CI
1 parent 3a7f304 commit 03d3391

File tree

4 files changed

+768
-164
lines changed

4 files changed

+768
-164
lines changed

.github/workflows/go.yaml

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,63 @@ on:
99
push:
1010
branches:
1111
- main
12+
release:
13+
types:
14+
- published
15+
16+
env:
17+
IS_PR: ${{github.event_name == 'pull_request' || ''}}
18+
IS_MAIN: ${{github.event_name == 'push' || ''}}
19+
IS_RELEASE: ${{github.event_name == 'release' || ''}}
1220

1321
jobs:
1422
build:
1523
runs-on: ubuntu-latest
1624
steps:
17-
- uses: actions/checkout@v4
18-
19-
- name: Setup Go
20-
uses: actions/setup-go@v5
21-
22-
- name: Download dependencies
23-
run: go mod download
24-
25-
- name: Test
26-
env:
27-
GOTESTSUM_JUNITFILE: junit.xml
28-
run: make
29-
30-
- name: Upload results to Codecov
31-
uses: codecov/codecov-action@v4
32-
with:
33-
token: ${{ secrets.CODECOV_TOKEN }}
34-
35-
- name: Upload test results to Codecov
36-
if: ${{ !cancelled() }}
37-
uses: codecov/test-results-action@v1
38-
with:
39-
token: ${{ secrets.CODECOV_TOKEN }}
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/cache/restore@v4
28+
with:
29+
key: ${{ runner.os }}-go-cache
30+
path: |
31+
~/.magefile
32+
~/.cache/golangci-lint
33+
~/.cache/go-build
34+
~/go/pkg/mod
35+
36+
- uses: actions/setup-go@v5
37+
with:
38+
go-version-file: go.mod
39+
cache: false
40+
41+
- name: Install dependencies
42+
run: go mod download
43+
44+
- name: Lint
45+
run: make lint
46+
47+
- name: Test
48+
run: make test
49+
50+
- name: Upload results to Codecov
51+
uses: codecov/codecov-action@v4
52+
with:
53+
token: ${{ secrets.CODECOV_TOKEN }}
54+
files: ./coverage.txt
55+
56+
- name: Upload test results to Codecov
57+
if: ${{ !cancelled() }}
58+
uses: codecov/test-results-action@v1
59+
with:
60+
token: ${{ secrets.CODECOV_TOKEN }}
61+
files: ./junit.xml
62+
63+
- uses: actions/cache/save@v4
64+
if: ${{ env.IS_MAIN }}
65+
with:
66+
key: ${{ runner.os }}-go-cache
67+
path: |
68+
~/.magefile
69+
~/.cache/golangci-lint
70+
~/.cache/go-build
71+
~/go/pkg/mod

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
.PHONY: test clean
22

3-
all: test
3+
all: clean lint test
44

5-
test: clean
6-
go run gotest.tools/gotestsum@v1.12.0 -- -coverprofile=coverage.txt ./...
5+
.PHONY: lint
6+
lint: ## Run linter
7+
go tool github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout=15m ./...
78

8-
clean:
9+
.PHONY: test
10+
test: ## Run tests
11+
go tool gotest.tools/gotestsum --junitfile=junit.xml -- -race -covermode=atomic -coverprofile=coverage.txt ./...
12+
13+
.PHONY: clean
14+
clean: ## Clean files
915
git clean -Xdf

0 commit comments

Comments
 (0)