-
Notifications
You must be signed in to change notification settings - Fork 6
144 lines (133 loc) · 4.24 KB
/
test.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: test
on:
push:
branches: [main]
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
setup-environment:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.20.7
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/tools/**') }}
- name: Install dependencies
if: steps.go-cache.outputs.cache-hit != 'true'
run: make for-all CMD="go mod download"
- name: Install Tools
if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-tools
unittest:
strategy:
matrix:
go-version: ['1.21', '1.20']
runs-on: ubuntu-latest
needs: [setup-environment]
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/tools/**') }}
- name: Cache Build
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: unittest-${{ runner.os }}-go-build-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/tools/**') }}
- name: Run Unit Tests
run: make test
lint:
runs-on: ubuntu-latest
needs: [setup-environment]
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ~1.20.7
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/tools/**') }}
- name: Cache Build
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: lint-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/tools/**') }}
- name: Check go mod tidy
run: make tidy && git diff -s --exit-code || (echo "make tidy needed"; exit 1)
- name: Check gofmt
run: make fmt && git diff -s --exit-code || (echo "make fmt needed"; exit 1)
- name: Check licenses file
run: make gen-licenses && git diff --exit-code || (echo "make gen-licenses needed"; exit 1)
- name: Check golangci-lint
run: make lint OPTS="--timeout 2m"
breaking-changes:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'breaking-change') && github.event_name == 'pull_request'}}
needs: [setup-environment]
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
path: ${{ github.base_ref }}
- name: Checkout HEAD
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
path: ${{ github.head_ref }}
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/tools/**') }}
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ~1.20.7
- name: Install tools
run: |
cd ${{ github.head_ref }}
make install-tools
- name: Generate-States
run: |
cd ${{ github.base_ref }}
make apidiff-generate APIHEADERS=~/apidiff-data
- name: Compare-States
run: |
cd ${{ github.head_ref }}
make apidiff-compare APIHEADERS=~/apidiff-data