forked from RamenDR/ramen
-
Notifications
You must be signed in to change notification settings - Fork 0
240 lines (207 loc) · 7.34 KB
/
sanity.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
---
# yamllint disable rule:line-length
name: PR and branch sanity
on: # yamllint disable-line rule:truthy
push:
tags:
- v*
branches:
- release-*
- main
pull_request:
branches:
- '*'
env:
GO_VERSION: "1.18"
IMAGE_TAG_BASE: "quay.io/ramendr/ramen"
IMAGE_REGISTRY: "quay.io"
IMAGE_REPOSITORY: "ramendr"
IMAGE_NAME: "ramen"
IMAGE_TAG: "sanity"
defaults:
run:
shell: bash
jobs:
lint:
name: Linters
runs-on: ubuntu-20.04
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Install prereqs
run: |
echo 'APT::Acquire::Retries "5";' | sudo tee /etc/apt/apt.conf.d/80-retries
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip ruby
sudo gem install mdl
sudo pip3 install yamllint
- name: Run linters
run: ./hack/pre-commit.sh
golangci:
name: Golangci Lint
runs-on: ubuntu-20.04
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: GolangCI Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
build-image-and-ensure-clean-branch:
name: Build image and ensure clean branch
runs-on: ubuntu-20.04
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Build image
run: make docker-build
- name: Run unit tests
run: GO_TEST_GINKGO_ARGS="" make test
- name: Export image
run: docker save -o /tmp/ramen-operator.tar ${IMAGE_TAG_BASE}-operator:${IMAGE_TAG}
- name: Save image artifact
uses: actions/upload-artifact@v2
with:
name: ramen-operator
path: /tmp/ramen-operator.tar
retention-days: 1
- name: Go tidy
run: go mod tidy
- name: Git branch sanity
run: |
echo "Failing if any auto generated files are updated, checking 'git status'"
git --no-pager diff
git status --porcelain 2>&1 | tee /dev/stderr | (! read)
deploy-check:
name: Check artifacts and operator deployment
needs: [build-image-and-ensure-clean-branch]
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
kubernetes_version: ["1.20.7"]
include:
- kubernetes_version: "1.20.7"
kind_image: "1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9"
kind_version: "v0.11.1"
env:
KUBERNETES_VERSION: ${{ matrix.kubernetes_version }}
KIND_VERSION: ${{ matrix.kind_version }}
KIND_IMAGE: ${{ matrix.kind_image }}
KIND_CLUSTER_NAME: "sanity"
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install kubectl
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
sudo install ./kubectl /usr/local/bin/
- name: Create Kind kubernetes cluster
run: ./hack/setup-kind-cluster.sh
- name: Download image artifact
uses: actions/download-artifact@v1
with:
name: ramen-operator
path: /tmp
- name: Load image artifact
run: |
docker load -i /tmp/ramen-operator.tar
kind load docker-image ${IMAGE_TAG_BASE}-operator:${IMAGE_TAG} --name ${KIND_CLUSTER_NAME}
- name: Deploy dependent CRDs
run: |
kubectl apply -f hack/test/
- name: Deploy operator
run: |
make deploy
kubectl get deployment -n ramen-system
kubectl -n ramen-system wait --for=condition=Available --timeout=60s deploy/ramen-hub-operator
kubectl -n ramen-system wait --for=condition=Available --timeout=60s deploy/ramen-dr-cluster-operator
- name: Display failure logs
if: ${{ failure() }}
run: |
echo "===> BEGIN failure details <==="
echo "===> NODE details <==="
kubectl get node -o yaml
echo "===> Ramen POD details <==="
kubectl get pods -n ramen-system -o yaml
echo "===> Ramen POD describe <==="
kubectl describe pods -n ramen-system
echo "===> Ramen DR Orchestrator POD logs <==="
kubectl logs -n ramen-system deployment/ramen-hub-operator -c manager
echo "===> Ramen DR Manager POD logs <==="
kubectl logs -n ramen-system deployment/ramen-dr-cluster-operator -c manager
echo "===> END failure details <==="
publish-image:
name: Publish built image
needs: [deploy-check, lint, golangci]
if: >
(github.event_name == 'push') &&
(github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/release-') ||
startsWith(github.ref, 'refs/tags/v')) &&
(github.repository == 'ramendr/ramen')
runs-on: ubuntu-20.04
steps:
- name: Download image artifact
uses: actions/download-artifact@v1
with:
name: ramen-operator
path: /tmp
- name: Load image artifact
run: |
docker load -i /tmp/ramen-operator.tar
- name: Login to Quay
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Determine image tag
run: |
[[ "${{ github.ref }}" =~ ^refs\/(heads|tags)\/(release-)?(.*) ]]
echo "heads or tags? ${BASH_REMATCH[1]}"
echo "release? ${BASH_REMATCH[2]}"
echo "version? ${BASH_REMATCH[3]}"
TAG=""
if test "${BASH_REMATCH[1]}" = "heads"; then
if test "${BASH_REMATCH[2]}" = "" && test "${BASH_REMATCH[3]}" = "main"; then
TAG="canary"
elif test "${BASH_REMATCH[2]}" = "release-"; then
TAG="${BASH_REMATCH[3]}-canary"
fi
elif test "${BASH_REMATCH[1]}" == "tags" && test "${BASH_REMATCH[2]}" = ""; then
TAG="${BASH_REMATCH[3]}"
fi
test "${TAG}" = "" && exit 1
echo "Publish image tag ${TAG}"
echo "publish_image_tag=${TAG}" >> $GITHUB_ENV
- name: Push operator image to Quay
run: |
docker tag "${IMAGE_TAG_BASE}-operator:${IMAGE_TAG}" "${IMAGE_TAG_BASE}-operator:${{ env.publish_image_tag }}"
docker push "${IMAGE_TAG_BASE}-operator:${{ env.publish_image_tag }}"
# TODO: We do not need to build bundles and catalogs each time, fix once we reach alpha
- name: Checkout source
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Build and push bundle images to Quay
run: |
IMAGE_TAG="${{ env.publish_image_tag }}" make bundle-build bundle-push
- name: Build and push catalog image to Quay
run: |
IMAGE_TAG="${{ env.publish_image_tag }}" make catalog-build catalog-push
# TODO: Test built bundles and catalog based install