forked from FoundationDB/fdb-kubernetes-operator
-
-
Notifications
You must be signed in to change notification settings - Fork 1
173 lines (172 loc) · 6.87 KB
/
pull_request.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
name: Integration checks
on:
push:
branches:
- master
- main
pull_request:
jobs:
lint-go:
name: Lint go code
runs-on: ubuntu-latest
strategy:
matrix:
fdbver: [ "6.2.30", "6.3.15" ]
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go
- name: Get dependencies
run: curl --fail "https://www.foundationdb.org/downloads/${{ matrix.fdbver }}/ubuntu/installers/foundationdb-clients_${{ matrix.fdbver }}-1_amd64.deb" -o fdb.deb
- name: Install dependencies
run: sudo dpkg -i fdb.deb
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.31
lint-python:
name: Lint Python code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/cache@v2
with:
path: .cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./foundationdb-kubernetes-sidecar/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Get Python dependencies
run: |
python3 -m pip install -r ./foundationdb-kubernetes-sidecar/requirements.txt
python3 -m pip install black==20.8b1
python3 -m pip install pycodestyle==2.6.0
- name: Run Python lint
run: |
pycodestyle --max-line-length=120 ./**/*.py
black --check --diff ./
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# With a new supported Kubernetes version we should adjust the version
# See https://kubernetes.io/releases for the current releases
kubever: [ "v1.19.0", "v1.20.0", "v1.21.1" ]
fdbver: ["6.2.30", "6.3.15"]
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go
- name: Get dependencies
if: steps.dependency_cache.outputs.cache-hit != 'true'
env:
KUBEBUILDER_VER: "2.3.2"
KUSTOMIZE_VER: "v3.9.4"
TEST_RACE_CONDITIONS: "1"
KIND_VER: "v0.11.1"
YQ_VERSION: "v4.6.1"
run: |
# Only download all dependencies
go get -v -t -d ./...
curl --fail -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/${KUSTOMIZE_VER}/kustomize_${KUSTOMIZE_VER}_linux_amd64.tar.gz" -o kustomize.tar.gz
os=$(go env GOOS)
arch=$(go env GOARCH)
curl --fail -L "https://go.kubebuilder.io/dl/${KUBEBUILDER_VER}/${os}/${arch}" -o kubebuilder.tar.gz
curl --fail "https://www.foundationdb.org/downloads/${{ matrix.fdbver }}/ubuntu/installers/foundationdb-clients_${{ matrix.fdbver }}-1_amd64.deb" -o fdb.deb
curl -Lo kind https://kind.sigs.k8s.io/dl/${KIND_VER}/kind-linux-amd64
curl -Lo yq.tar.gz https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64.tar.gz
- name: Install dependencies
env:
KUBEBUILDER_VER: "2.3.2"
run: |
# Install dependencies either from cache or freshly downloaded
tar xvfz kustomize.tar.gz
sudo mv kustomize /usr/local/bin/
tar -xz -C /tmp/ -f kubebuilder.tar.gz
os=$(go env GOOS)
arch=$(go env GOARCH)
sudo mv "/tmp/kubebuilder_${KUBEBUILDER_VER}_${os}_${arch}" /usr/local/kubebuilder
sudo dpkg -i fdb.deb
# Install Kind and start a local Kubernetes cluster
chmod +x kind
sudo mv kind /usr/local/bin/kind
./scripts/setup_kind_local_registry.sh ${{ matrix.kubever }}
tar xvfz yq.tar.gz
sudo mv ./yq_linux_amd64 /usr/bin/yq
- name: Run tests
# Currently the default runner has 2 vCPU:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources
env:
GOMAXPROCS: "2"
run: |
# Ensure the Minio CRD is installed and in place
kubectl apply -f ./config/minio/operator.yaml
# Install the current manifests to ensure we can upgrade/apply the manifests without any issue
kubectl apply -f https://raw.githubusercontent.com/FoundationDB/fdb-kubernetes-operator/master/config/crd/bases/apps.foundationdb.org_foundationdbbackups.yaml
kubectl apply -f https://raw.githubusercontent.com/FoundationDB/fdb-kubernetes-operator/master/config/crd/bases/apps.foundationdb.org_foundationdbclusters.yaml
kubectl apply -f https://raw.githubusercontent.com/FoundationDB/fdb-kubernetes-operator/master/config/crd/bases/apps.foundationdb.org_foundationdbrestores.yaml
# Generate secrets used by the operator
./config/test-certs/generate_secrets.bash
SKIP_TEST=1 IMG=localhost:5000/fdb-kubernetes-operator:latest make clean all docker-build docker-push deploy
# Wait for the operator to start
kubectl rollout status deploy fdb-kubernetes-operator-controller-manager --timeout=120s
# Check if all resources can be applied
kubectl apply --dry-run=server -f ./config/samples
RUN_E2E=true make test
# Change the image back to the default otherwise the next check will complain
cd config/manager && kustomize edit set image controller=fdb-kubernetes-operator:latest
- name: Check for uncommitted changes
run: git diff --exit-code
push_images:
if: github.ref == 'refs/heads/master'
needs: build
name: Push Docker images
runs-on: ubuntu-latest
strategy:
matrix:
image:
- fdb-kubernetes-operator
- fdb-data-loader
include:
- image: fdb-kubernetes-operator
context: ./
name: foundationdb/fdb-kubernetes-operator
- image: fdb-data-loader
context: ./sample-apps/data-loader
name: foundationdb/fdb-data-loader
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push to registry
uses: docker/build-push-action@v2
with:
push: true
context: ${{ matrix.context }}
tags: ${{ matrix.name }}:latest