This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
193 lines (169 loc) · 6.14 KB
/
ci.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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
---
name: CI
on:
schedule:
- cron: "0 12 * * 0"
push:
branches:
- EVEREST-107-update-ci
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
permissions:
contents: read
packages: write
checks: write
pull-requests: write
repository-projects: read
jobs:
integration_tests:
strategy:
fail-fast: false
matrix:
go-version: [1.21.x]
may-fail: [false]
name: API Integration Tests
runs-on: ubuntu-20.04
env:
# no `-mod=readonly` to test PRs made by @dependabot;
# `git diff --exit-code` step below still checks what we need
GOPRIVATE: github.com/percona,github.com/percona/everest-operator
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
steps:
- name: Set up Go release
uses: percona-platform/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Set GO_VERSION environment variable
run: |
go version
echo "GO_VERSION=$(go version)" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
lfs: true
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Enable Go modules cache
uses: percona-platform/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-modules-
- name: Enable Go build cache
uses: percona-platform/cache@v3
with:
path: ~/.cache/go-build
key: ${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-${{ hashFiles('**') }}
restore-keys: |
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
- name: Start local Kubernetes cluster with the local registry
uses: medyagh/setup-minikube@latest
id: minikube
with:
cpus: 2
memory: 2000m
addons: registry
insecure-registry: 'localhost:5000'
- name: Expose local registry
run: |
kubectl port-forward --namespace kube-system service/registry 5000:80 &
- name: Build Everest backend
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build-debug
- name: Build Everest docker container
uses: docker/metadata-action@v5
id: meta
with:
images: localhost:5000/perconalab/everest
tags:
0.0.0
- name: Build and Push everest dev image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Checkout CLI repo
uses: actions/checkout@v4
with:
repository: percona/percona-everest-cli
ref: 'main'
path: percona-everest-cli
ssh-key: ${{ secrets.CLI_SSH_KEY }}
- name: Configure git for private modules
env:
ROBOT_TOKEN: ${{ secrets.ROBOT_TOKEN }}
run: git config --global url."https://percona-platform-robot:${ROBOT_TOKEN}@github.com".insteadOf "https://github.com"
# We need to have Everest CRDs available before running provisioning and everest backend
# to have an ability to create monitoring configs and use them during the provisioning as
# a mock pmm server without running a real PMM.
- name: Install everest operator without Everest
run: |
kubectl create ns everest-system
kubectl create ns everest-monitoring
curl https://raw.githubusercontent.com/percona/everest-operator/main/deploy/bundle.yaml -o bundle.yaml
sed -i "s/namespace: everest-operator-system/namespace: everest-system/g" bundle.yaml
kubectl -n everest-system apply -f bundle.yaml
# We create a dummy monitoring instance so we can enable monitoring during provisioning
# without having to install PMM.
- name: Create a monitoring instance
run: |
cat <<EOF | kubectl apply -f -
kind: Secret
apiVersion: v1
metadata:
name: pmm-local
namespace: everest-monitoring
type: Opaque
stringData:
"apiKey": "dummy-key"
EOF
cat <<EOF | kubectl apply -f -
kind: MonitoringConfig
apiVersion: everest.percona.com/v1alpha1
metadata:
name: pmm-local
namespace: everest-monitoring
spec:
type: pmm
credentialsSecretName: pmm-local
pmm:
url: http://localhost
image: percona/pmm-client:2
EOF
- name: Provision Everest using CLI
shell: bash
run: |
cd percona-everest-cli
echo $(git describe --always)
make build
./bin/everest install \
--operator.mongodb \
--operator.postgresql \
--operator.xtradb-cluster \
--skip-wizard \
--namespace everest
# API_TOKEN is used later by "make test"
echo "API_TOKEN=$(./bin/everest token reset --json | jq .token -r)" >> $GITHUB_ENV
- name: Patch Everest Deployment to use the PR image
run: |
kubectl -n everest-system patch deployment percona-everest --type strategic --patch-file dev/patch-deployment-image.yaml
kubectl -n everest-system rollout status deploy/percona-everest --timeout=120s
- name: Expose Everest backend
run: |
kubectl port-forward --namespace everest-system deployment/percona-everest 8080:8080 &
- name: Run integration tests
run: |
cd api-tests
make init
make test
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
kubectl -n everest-system describe pods
kubectl -n everest-monitoring describe pods
kubectl -n everest describe pods
kubectl -n everest-system logs deploy/percona-everest