-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (124 loc) · 3.74 KB
/
go.yml
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
name: Test
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
go:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.17"]
path: ["", "examples"]
name: Go ${{ matrix.go }} ${{ matrix.path }}
steps:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go modules cache
id: cache-go-module
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ matrix.path }}-${{ hashFiles('go.sum') }}-
restore-keys: |
${{ runner.os }}-gomod-
- name: Setup Go build cache
id: cache-go-build
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-gobuild-${{ matrix.path }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-gobuild-
- name: Download dependencies
working-directory: ${{ matrix.path }}
if: steps.cache-go-module.outputs.cache-hit != 'true'
run: go mod download
- name: Verify go modules up to date
working-directory: ${{ matrix.path }}
run: |
set -ex
go mod tidy
[ -z "$(git diff -- go.{mod,sum})" ] # Check there are no changes!
- name: Test
working-directory: ${{ matrix.path }}
run: go test ./...
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41
skip-go-installation: true
github-token: ${{ secrets.GITHUB_TOKEN }}
only-new-issues: false
skip-pkg-cache: true
skip-build-cache: true
args: --timeout=10m
working-directory: ${{ matrix.path }}
go-mongo:
runs-on: ubuntu-latest
services:
mongo:
image: mongo:4.0
ports:
- "27017"
strategy:
matrix:
go: ["1.17"]
path: ["storers/mongo"]
name: Go ${{ matrix.go }} ${{ matrix.path }}
steps:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go modules cache
id: cache-go-module
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ matrix.path }}-${{ hashFiles('go.sum') }}-
restore-keys: |
${{ runner.os }}-gomod-
- name: Setup Go build cache
id: cache-go-build
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-gobuild-${{ matrix.path }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-gobuild-
- name: Download dependencies
working-directory: ${{ matrix.path }}
if: steps.cache-go-module.outputs.cache-hit != 'true'
run: go mod download
- name: Verify go modules up to date
working-directory: ${{ matrix.path }}
run: |
set -ex
go mod tidy
[ -z "$(git diff -- go.{mod,sum})" ] # Check there are no changes!
- name: Test
env:
GOTEST_MONGODB: mongodb://localhost:${{ job.services.mongo.ports[27017] }}
working-directory: ${{ matrix.path }}
run: go test ./...
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41
skip-go-installation: true
github-token: ${{ secrets.GITHUB_TOKEN }}
only-new-issues: false
skip-pkg-cache: true
skip-build-cache: true
args: --timeout=10m
working-directory: ${{ matrix.path }}