forked from IBM/ibm-spectrum-scale-csi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
264 lines (249 loc) · 10.9 KB
/
.travis.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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
services: docker
dist: focal
language: go
go:
- 1.22.x
env:
global:
# Shared ENV
- REPO_OWNER=$(dirname $TRAVIS_REPO_SLUG)
# REPO_NAME should normally be 'ibm-spectrum-scale-csi'
- REPO_NAME=$(basename $TRAVIS_REPO_SLUG)
- REPO_NAME_DRIVER="ibm-spectrum-scale-csi-driver"
- REPO_NAME_OPERATOR="ibm-spectrum-scale-csi-operator"
# Grab quay username from 'user+bot_token'
- IMAGE_REPO_OWNER=${QUAY_BOT_USERNAME%%\+*}
# Format quay image target
- IMAGE_REPO_DRIVER=quay.io/${IMAGE_REPO_OWNER}/${REPO_NAME_DRIVER}
- IMAGE_REPO_OPERATOR=quay.io/${IMAGE_REPO_OWNER}/${REPO_NAME_OPERATOR}
# Add image tag
- IMAGE_TAG=$(
if [[ $TRAVIS_EVENT_TYPE == 'cron' ]];
then
echo "nightly-${TRAVIS_BUILD_ID}-`date -u +%F`";
else
echo $TRAVIS_BRANCH;
fi
)
# Add image repo and tag
- IMAGE_FQN_DRIVER=${IMAGE_REPO_DRIVER}:${IMAGE_TAG}
- IMAGE_FQN_OPERATOR=${IMAGE_REPO_OPERATOR}:${IMAGE_TAG}
- IMAGE_VERSION=${IMAGE_TAG}
# Add image label to expire nightlies
- COMMIT=$(git log -1 --format=%H)
- IMAGE_LABEL=$(
if [[ $TRAVIS_EVENT_TYPE == 'cron' ]];
then
echo "--label version=${IMAGE_VERSION} --label quay.expires-after=2w";
else
echo "--label version=${IMAGE_VERSION}";
fi
)
- BUILD_DIR_OPERATOR="${TRAVIS_BUILD_DIR}/operator"
- BUILD_DIR_DRIVER="${TRAVIS_BUILD_DIR}/driver"
- BUILD_PLATFORMS="linux/ppc64le,linux/s390x,linux/amd64"
# For the quay app
- BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
#- OPERATOR_DIR=deploy/olm-catalog/ibm-spectrum-scale-csi-operator
- QUAY_NAMESPACE=${IMAGE_REPO_OWNER}
- PACKAGE_NAME=${REPO_NAME}-${BRANCH}
# Operator ENV
- OCTOKIT_API_ENDPOINT="https://github.ibm.com/api/v3/"
- PATH=/opt/python/3.6.7/bin:$PATH
- GO111MODULE=on
- KUBE_VERSION="v1.20.4"
- OP_VER="v1.13.0"
- OPERATOR_LOCAL_IMAGE="csi.ibm.com/${REPO_NAME_OPERATOR}:testing"
- OPERATOR_SDK="https://github.com/operator-framework/operator-sdk/releases/download/${OP_VER}/operator-sdk_linux_amd64"
#- OLM_MANIFEST="${BUILD_DIR_OPERATOR}/config/olm-catalog/${REPO_NAME_OPERATOR}/"
- CHANGE_MINIKUBE_NONE_USER=true
- MINIKUBE_WANTUPDATENOTIFICATION=false
- MINIKUBE_WANTREPORTERRORPROMPT=false
- MINIKUBE_HOME=$HOME
- KUBECONFIG=$HOME/.kube/config
docker: &docker_buildx
before_install:
- mkdir -vp ~/.docker/cli-plugins/
- curl --silent -L "https://github.com/docker/buildx/releases/download/v0.4.2/buildx-v0.4.2.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
- chmod a+x ~/.docker/cli-plugins/docker-buildx
- sudo rm -f /etc/docker/daemon.json
- sudo service docker restart
- docker buildx create --use
addons:
apt:
packages:
- "python3"
- "python3-dev"
- "python3-pip"
- "conntrack"
stages:
- lint
- build
- test
jobs:
fast_finish: true
include:
# Install operator-courier and run the lint on the manifest.
- stage: lint
name: "Lint - Driver: run golangci-lint"
before_install:
- >-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh |
sh -s -- -b $(go env GOPATH)/bin v1.54.2 # pinned
before_script:
- cd ${BUILD_DIR_DRIVER}
script:
#- golangci-lint run
- golangci-lint run --no-config --disable-all -E gosec --out-format json,colored-line-number --timeout 3m0s
# stage: lint
- name: "Lint - Operator: run linters and bundle automation."
before_install:
- >-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh |
sh -s -- -b $(go env GOPATH)/bin v1.54.2 # pinned
before_script:
- cd ${BUILD_DIR_OPERATOR}
script:
- pip3 install ansible
- curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- 4.5.7 ${HOME}/bin
# Testing that the generated files match the deploy/*.yaml files, it they do not match, fail Travis
- ansible-playbook ${TRAVIS_BUILD_DIR}/tools/ansible/generate-playbook.yaml --extra-vars "travis_testing=true"
#- pip3 install operator-courier==2.1.11
#- cd ${BUILD_DIR_OPERATOR}
#- ls ${OLM_MANIFEST}
#- echo ${BUILD_DIR_OPERATOR}
#- ls ${BUILD_DIR_OPERATOR}
#- python3 hacks/package_operator.py -d ${OLM_MANIFEST} -o /tmp/operator --nozip
# #Disabling for now..
#- operator-courier --verbose verify --ui_validate_io /tmp/operator
- golangci-lint run --no-config --disable-all -E gosec --out-format json,colored-line-number --timeout 3m0s
# stage: lint
- name: "Lint - Operator: CASE"
if: env.HELM_REPO_SSH_LOCATION!=""
before_install:
- if [[ -z "$HELM_REPO_SSH_LOCATION" ]] ; then exit 0;fi
install:
# Resolve symlinks for testing.
- cp -R -L cloudpak/ cloudpak-static
- cd cloudpak-static
- ls -ltra stable/ibm-spectrum-scale-csi-operator-bundle/case/ibm-spectrum-scale-csi-operator/inventory/ibmCSIScaleOperator/files
# Clone build tools & set tools path for follow on processing
# The clone command will use the ssh key from the travis settings to clone the repo from github.ibm.com
- if [[ -z "$HELM_REPO_SSH_LOCATION" ]] ; then exit 0;fi
- if [[ ! -z "$BRANCH_OVERRIDE" ]] ; then
git clone -b $BRANCH_OVERRIDE [email protected]:ibmprivatecloud/content-tools;
else
git clone [email protected]:ibmprivatecloud/content-tools;
fi
- export toolsPath=`pwd`/content-tools/travis-tools/
# Install dependencies & determine chart delta
- $toolsPath/build/bin/installDependencies.sh
- export changeList=`$toolsPath/build/bin/determineChartDelta.sh | tee determineChartDelta.out | grep 'return determineChartDelta:' | cut -f2 -d:` && cat determineChartDelta.out
# Package for release
- if [[ ! -z "$TRAVIS_TAG" ]] ; then $toolsPath/release/bin/package.sh; fi
# Lint and install/test charts (if cv-tests exist)
- $toolsPath/cv-test/bin/validateContent.sh
deploy:
# scp helm repo(s) to location identified (Note: SSHPASS env variable must contain password)
- provider: script
skip_cleanup: true
script: $toolsPath/build/bin/deployHelmRepo.sh
on:
all_branches: true
# Publish tagged release
- provider: releases
skip_cleanup: true
api_key: $GITHUB_TOKEN
file_glob: true
file: repo/stable/*
on:
tags: true
# end stage: lint
- stage: build
name: "Build - Driver: image and push to registry"
<<: *docker_buildx
before_script:
- cd ${BUILD_DIR_DRIVER}
- go mod vendor
script:
- go test -v -race ./...
- docker buildx build --progress=plain --platform ${BUILD_PLATFORMS} ${IMAGE_LABEL} --build-arg commit=${COMMIT} --build-arg build_date="$(date -u)" .
before_deploy:
- echo "$QUAY_BOT_PASSWORD" | docker login -u "$QUAY_BOT_USERNAME" --password-stdin quay.io
deploy:
- provider: script
script: docker buildx build --progress=plain --platform ${BUILD_PLATFORMS} ${IMAGE_LABEL} --build-arg commit=${COMMIT} --build-arg build_date="$(date -u)" -t ${IMAGE_FQN_DRIVER} --push .
on:
all_branches: true
condition: -n "$QUAY_BOT_USERNAME" && -n "$QUAY_BOT_PASSWORD"
# stage: build
- name: "Build - Operator: image and push to registry"
<<: *docker_buildx
install:
- docker version
before_script:
- ${TRAVIS_BUILD_DIR}/tools/scripts/ci/install_operator-sdk.sh
- operator-sdk version
- cd ${BUILD_DIR_OPERATOR}
script:
- docker buildx build --progress=plain --platform ${BUILD_PLATFORMS} ${IMAGE_LABEL} --build-arg commit=${COMMIT} --build-arg build_date="$(date -u)" .
before_deploy:
- echo "$QUAY_BOT_PASSWORD" | docker login -u "$QUAY_BOT_USERNAME" --password-stdin quay.io
deploy:
- provider: script
script: docker buildx build --progress=plain --platform ${BUILD_PLATFORMS} ${IMAGE_LABEL} --build-arg commit=${COMMIT} --build-arg build_date="$(date -u)" -t ${IMAGE_FQN_OPERATOR} --push .
on:
all_branches: true
condition: -n "$QUAY_BOT_USERNAME" && -n "$QUAY_BOT_PASSWORD"
# - provider: script
# script: ../tools/scripts/push_app.sh
# on:
# all_branches: true
# condition: -n "$QUAY_BOT_USERNAME" && -n "$QUAY_BOT_PASSWORD" && -n "$QUAY_APP"
# # stage: build
# - name: "Build - Operator: docs"
# script:
# - pip3 install sphinx sphinx_rtd_theme recommonmark
# - cd ${TRAVIS_BUILD_DIR}/docs
# - make html
# # end stage: build
# # Install minikube, build the image and run the scorecard then execute molecule testing.
# - stage: test
# name: "Test - Operator: molecule"
# dist: xenial
# before_install:
# - pip install --upgrade pip
# - pip install docker molecule ansible-lint yamllint flake8 openshift jmespath kubernetes-validate
# - ${TRAVIS_BUILD_DIR}/tools/scripts/ci/install_minikube.sh
# - ${TRAVIS_BUILD_DIR}/tools/scripts/ci/install_operator-sdk.sh
# - kubectl version
# - cd ${BUILD_DIR_OPERATOR}
# - eval $(minikube docker-env) # Popping this out, because I don't think the script is working.
# - operator-sdk build ${REPO_NAME_OPERATOR}
# - docker tag ${REPO_NAME_OPERATOR} ${OPERATOR_LOCAL_IMAGE}
# script:
# # molecule
# - ansible-playbook hacks/change_deploy_image.yml --extra-vars "quay_operator_endpoint=${OPERATOR_LOCAL_IMAGE}"
# - kubectl create namespace ibm-spectrum-scale-csi-driver
# #- molecule test -s test-local
#
# - stage: test
# name: "Test - Operator: scorecard"
# dist: xenial
# before_install:
# - pip install --upgrade pip
# - pip install docker molecule ansible-lint yamllint flake8 openshift jmespath kubernetes-validate
# - ${TRAVIS_BUILD_DIR}/tools/scripts/ci/install_minikube.sh
# - ${TRAVIS_BUILD_DIR}/tools/scripts/ci/install_operator-sdk.sh
# - kubectl version
# - cd ${BUILD_DIR_OPERATOR}
# - eval $(minikube docker-env) # Popping this out, because I don't think the script is working.
# script:
# - python hacks/clear_finalizers.py
# #- ansible-playbook hacks/change_deploy_image.yml --extra-vars "quay_operator_endpoint=${OPERATOR_LOCAL_IMAGE}"
# - operator-sdk build ${REPO_NAME_OPERATOR}
# - docker tag ${REPO_NAME_OPERATOR} ${OPERATOR_LOCAL_IMAGE}
# - kubectl create namespace ibm-spectrum-scale-csi-driver
# - operator-sdk scorecard --config .osdk-scorecard.yaml --verbose
notifications:
email: false