forked from prometheus-operator/prometheus-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (171 loc) · 4.74 KB
/
ci.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: ci
on:
pull_request:
push:
branches:
- 'release-*'
- 'master'
- 'main'
tags:
- 'v*'
env:
golang-version: '1.16'
kind-version: 'v0.10.0'
kind-image: 'kindest/node:v1.20.0' # Image defines which k8s version is used
jobs:
generate:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
name: Generate and format
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- run: make --always-make format generate && git diff --exit-code
check-links:
runs-on: ubuntu-latest
name: Check markdown links
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
config-file: '.github/workflows/.mlc_config.json'
continue-on-error: true
check-golang:
runs-on: ubuntu-latest
name: Golang linter
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.33
args: --timeout 10m0s
check-metrics:
runs-on: ubuntu-latest
name: Check prometheus metrics
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- run: make check-metrics
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
name: Build operator binary
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- run: make operator
po-rule-migration:
runs-on: ubuntu-latest
name: Build Prometheus Operator rule config map to rule file CRDs CLI tool
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- run: cd cmd/po-rule-migration && go install
unit-tests:
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- run: make test-unit
extended-tests:
runs-on: ubuntu-latest
name: Extended tests
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- run: make test-long
e2e-tests:
name: E2E tests
runs-on: ubuntu-latest
strategy:
matrix:
suite: [alertmanager, prometheus, thanosruler]
include:
- suite: alertmanager
prometheus: "exclude"
alertmanager: ""
thanosruler: "exclude"
- suite: prometheus
prometheus: ""
alertmanager: "exclude"
thanosruler: "exclude"
- suite: thanosruler
prometheus: "exclude"
alertmanager: "exclude"
thanosruler: ""
steps:
- uses: actions/checkout@v2
- name: Start KinD
uses: engineerd/setup-kind@v0.5.0
with:
version: ${{ env.kind-version }}
image: ${{ env.kind-image }}
- name: Wait for cluster to finish bootstraping
run: |
until [ "$(kubectl get pods --all-namespaces --no-headers | grep -cEv '([0-9]+)/\1')" -eq 0 ]; do
sleep 5s
done
kubectl cluster-info
kubectl get pods -A
- name: Build and load images
run: |
export SHELL=/bin/bash
make build image
kind load docker-image quay.io/prometheus-operator/prometheus-operator:$(git rev-parse --short HEAD)
kind load docker-image quay.io/prometheus-operator/prometheus-config-reloader:$(git rev-parse --short HEAD)
kubectl apply -f scripts/kind-rbac.yaml
- name: Run tests
run: >
EXCLUDE_ALERTMANAGER_TESTS=${{ matrix.alertmanager }}
EXCLUDE_PROMETHEUS_TESTS=${{ matrix.prometheus }}
EXCLUDE_THANOSRULER_TESTS=${{ matrix.thanosruler }}
make test-e2e
publish:
runs-on: ubuntu-latest
name: Publish container images to quay.io
if: github.event_name == 'push'
needs:
- generate
- build
- po-rule-migration
- unit-tests
- extended-tests
- e2e-tests
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.golang-version }}
- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build images and push
run: ./scripts/push-docker-image.sh