-
Notifications
You must be signed in to change notification settings - Fork 6
120 lines (103 loc) · 3.32 KB
/
build.yaml
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
name: Continuous Integration
on:
push:
branches:
- "**"
tags:
- "**"
pull_request:
jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Run golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
version: v1.52.2
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
with:
go-version: 1.18
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up limgo
uses: GoTestTools/limgo-action@fe8392ce7f182c119ae7c27faa6d63170825e689 # v1.0.1
with:
version: "v1.0.0"
install-only: true
- name: Setup go mockgen
run: go install go.uber.org/mock/mockgen@v0.3.0
- name: generate mocks
run: go generate ./...
- name: run tests
run: |
set -euo pipefail
go test -coverprofile=test.cov -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: upload test log
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
- name: Calculate test coverage
run: |
cat .limgo.json
limgo -coverfile=test.cov -config=.limgo.json -outfmt=md -outfile=limgo_cov.md
cat limgo_cov.md >> $GITHUB_STEP_SUMMARY
- name: upload coverage results
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: coverage
path: limgo_cov.md
if-no-files-found: error
release:
name: release
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs:
- golangci-lint
- test
if: startsWith(github.event.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
with:
go-version: 1.18
- name: Setup go mockgen
run: go install github.com/golang/mock/mockgen@v1.6
- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: binaries
path: dist