Skip to content

Commit 6c7d034

Browse files
committed
Fix travis build
/skip-cloud Signed-off-by: Alvaro Saurin <[email protected]>
1 parent 832aa0f commit 6c7d034

17 files changed

+153
-144
lines changed

.travis.yml

+24-68
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
os: linux
2+
dist: xenial
3+
14
language: go
25

36
go:
@@ -42,15 +45,17 @@ jobs:
4245
# see the ci/infra/providers/CREDENTIALS.md for details on the credentials
4346
- stage: End-to-end tests
4447
name: "e2e tests in Google Cloud (GKE)"
45-
if: type = cron OR tag IS present
48+
# Run on cron jobs, tagged releases or any builds where commit message contains "test-gke"
49+
if: (type IN (cron, api) OR (tag =~ ^v) OR (commit_message =~ test-gke) OR (commit_message =~ test-cloud)) AND NOT (commit_message =~ skip-gke OR commit_message =~ skip-cloud)
4650
env:
4751
- CLUSTER_PROVIDER="gke"
4852
- CLUSTER_MACHINE="e2-standard-8"
4953
- CLUSTER_REUSE=1
5054
script: make ci/cluster-setup ci/e2e
5155

5256
- name: "e2e tests in Azure (AKS)"
53-
if: type = cron OR tag IS present
57+
# Run on cron jobs, tagged releases or any builds where commit message contains "test-azure"
58+
if: (type IN (cron, api) OR (tag =~ ^v) OR (commit_message =~ test-azure) OR (commit_message =~ test-cloud)) AND NOT (commit_message =~ skip-azure OR commit_message =~ skip-cloud)
5459
env:
5560
- CLUSTER_PROVIDER="azure"
5661
- CLUSTER_REUSE=1
@@ -63,79 +68,39 @@ jobs:
6368
#####################################################
6469
# stage 3: push images
6570
#####################################################
66-
- stage: Publish artifacts
67-
name: "Publish artifacts to GitHub"
68-
if: tag IS present
69-
env:
70-
- AMB_OPER_TAG="$TRAVIS_TAG"
71-
- REL_REGISTRY="docker.io/datawire"
72-
deploy:
73-
- provider: script
74-
on:
75-
all_branches: true
76-
script: make ci/release
77-
# publish YAMLs to GitHub releases
78-
# `make ci/release` should have left everything in build/artifacts/*
79-
- provider: releases
80-
on:
81-
branch: master
82-
api_key:
83-
secure: XFAZ+q3B7TL7ae0lK6Nl4RCkYxknZ0gZ44g/aR5zOcTkAuJ9049vOUol7UQT9ZyRMMOigfma5IQRFqcQlHBPnBRGkuHFGqxx48Kw1pvLRR3BhIYG0aSyDR3ZnI0eEkaKzui1zKBC5R03DK1NpVl+muomNDWgsEb9M9qn7onYQPMfCi4ZZ8x/ev5GtXlHPrCh4O/m51X0nLoVMsvFaogNiiwKtS/sWlLTiY9DWwACF5yY58Q65l3GNiLaIQCIvdU3losq08KJViIE8qBNojCRr+zLXluOlpgVb7ozZ3vWNephuHZoRIvW8hH8MTgaiuDh+XGlbTNlLBrJAF43CPZLQdzZdLMp74XRx90OkXHA8p6crBoQRa5Q7/MhV0pswdMcSKnHIe9dRkkPiGmDGXFg5WAchI6egGskAD4SAZMmiXBoj8TcjtyDa4NExakebrrU/XzvU951teAk2czNs1yoXTDfrpgDiIfI7PaIXgUGJi8VjkuwgSZ8uU1EQNwrvhikngbtFKnzM7I2KGr3nIE9cTxxo81PWoElrGAarArQZjARJp1z2myTqPiUi3FcvFOmaeOZbTvHc2kt2Z5iZCJ4Np/YwmXL7pCjijxbb8MB6MrQLv96woX0do/lDDsq8tXrRRoxGqpRzvBtLWHVMw55aKrbnvfnic1HGwyMZnFex+E=
84-
file_glob: true
85-
file: build/artifacts/*
86-
skip_cleanup: true
87-
88-
- name: "Publish image to Docker.io"
89-
if: tag IS present
71+
- stage: Push images to repositories
72+
name: "Push images to repositories"
73+
if: (branch =~ ^v) AND (tag =~ ^v) AND (type != pull_request) AND NOT (commit_message =~ skip-push)
9074
env:
91-
- AMB_OPER_TAG="$TRAVIS_TAG"
92-
- REL_REGISTRY="docker.io/datawire"
75+
- AMB_OPER_IMAGE_TAG="$TRAVIS_TAG"
9376
deploy:
9477
# publish images to Docker.io
9578
# NOTE: make sure DOCKER_USERNAME/DOCKER_PASSWORD have values for a bot
9679
- provider: script
9780
on:
9881
all_branches: true
99-
script: make ci/release ci/publish-image
100-
101-
- name: "Push images to Quay.io"
102-
if: tag IS present
103-
env:
104-
- AMB_OPER_TAG="$TRAVIS_TAG"
105-
- DOCKER_USERNAME="$QUAY_USERNAME"
106-
- DOCKER_PASSWORD="$QUAY_PASSWORD"
107-
- REL_REGISTRY="quay.io/datawire"
108-
deploy:
82+
script: REL_REGISTRY="docker.io/datawire" make ci/publish-image
10983
# publish images to Quay.io
11084
# NOTE: make sure DOCKER_USERNAME/DOCKER_PASSWORD have values for a bot
11185
# (from https://quay.io/repository/datawire/ambassador-operator?tab=settings)
11286
- provider: script
11387
on:
114-
branch: master
115-
script: make ci/release ci/publish-image
116-
117-
- name: "Push images to Azure ACR"
118-
if: tag IS present
119-
env:
120-
- AMB_OPER_TAG="$TRAVIS_TAG"
121-
- CLUSTER_REGISTRY="datawire"
122-
- CLUSTER_PROVIDER="azure"
123-
- AZ_RES_GRP="DefaultResourceGroup-EUS"
124-
deploy:
88+
all_branches: true
89+
script: DOCKER_USERNAME="$QUAY_USERNAME" DOCKER_PASSWORD="$QUAY_PASSWORD" REL_REGISTRY="quay.io/datawire" make ci/publish-image
12590
- provider: script
12691
on:
127-
branch: master
128-
env:
129-
script: make ci/cluster-setup ci/release ci/publish-image-cloud/azure
92+
all_branches: true
93+
script: CLUSTER_PROVIDER="azure" CLUSTER_REGISTRY="datawire" AZ_RES_GRP="DefaultResourceGroup-EUS" make ci/cluster-setup ci/publish-image-cloud/azure
13094

13195
#####################################################
13296
# stage 4: publish artifacts
13397
#####################################################
13498
- stage: Publish artifacts
135-
name: "Publish artifacts to GitHub"
136-
if: tag IS present
99+
name: "Publish artifacts"
100+
if: (branch =~ ^v) AND (tag =~ ^v) AND (type != pull_request) AND NOT (commit_message =~ skip-publish)
137101
env:
138-
- AMB_OPER_TAG="$TRAVIS_TAG"
102+
- AMB_OPER_IMAGE_TAG="$TRAVIS_TAG"
103+
- REL_REGISTRY="docker.io/datawire"
139104
deploy:
140105
- provider: script
141106
on:
@@ -151,30 +116,21 @@ jobs:
151116
file_glob: true
152117
file: build/artifacts/*
153118
skip_cleanup: true
154-
155-
- name: "Publish Helm Chart"
156-
if: tag IS present
157-
env:
158-
- AMB_OPER_TAG="$TRAVIS_TAG"
159-
- DOCKER_USERNAME="$QUAY_USERNAME"
160-
- DOCKER_PASSWORD="$QUAY_PASSWORD"
161-
- REL_REGISTRY="quay.io/datawire"
162-
deploy:
163119
# publish helm chart
164120
# NOTE: needs AWS_ACCESS_KEY_ID, AWS_BUCKET and AWS_SECRET_ACCESS_KEY (from keybase)
165121
- provider: script
166122
on:
167-
branch: master
123+
all_branches: true
168124
script: make ci/cluster-setup ci/publish-chart
169125

170126
#####################################################
171127
# stage 5: smoke tests
172128
#####################################################
173129
- stage: Smoke tests
174-
name: "Smoke tests for KIND"
175-
if: tag IS present
130+
name: "Smoke tests"
131+
if: (branch =~ ^v) AND (tag =~ ^v) AND NOT (commit_message =~ skip-smoke)
176132
env:
177-
- AMB_OPER_TAG="$TRAVIS_TAG"
133+
- AMB_OPER_IMAGE_TAG="$TRAVIS_TAG"
178134
deploy:
179135
- provider: script
180136
on:

Makefile

+26-18
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,27 @@ GIT_VERSION = $(shell git describe --dirty --tags --always)
2525
GIT_COMMIT = $(shell git rev-parse HEAD)
2626

2727
# the base name and tag for the operator image
28-
AMB_OPER_BASE_IMAGE ?= ambassador-operator
29-
AMB_OPER_TAG ?= dev
30-
ifeq ($(AMB_OPER_TAG),)
31-
override AMB_OPER_TAG = $(GIT_VERSION)
28+
AMB_OPER_IMAGE_NAME ?= ambassador-operator
29+
AMB_OPER_IMAGE_TAG ?= dev
30+
ifeq ($(AMB_OPER_IMAGE_TAG),)
31+
override AMB_OPER_IMAGE_TAG = $(GIT_VERSION)
3232
endif
3333

3434
# the image name with tag but without registry (ie, "ambassador-operator:dev")
35-
AMB_OPER_IMAGE ?= $(AMB_OPER_BASE_IMAGE):$(AMB_OPER_TAG)
35+
AMB_OPER_IMAGE ?= $(AMB_OPER_IMAGE_NAME):$(AMB_OPER_IMAGE_TAG)
3636
AMB_OPER_ARCHES :="amd64"
3737

3838
# release registry
39-
REL_REGISTRY ?= docker.io/datawire
40-
export REL_REGISTRY
39+
# this registry should be used only for pushing images for release
40+
REL_REGISTRY ?=
4141

4242
# full image name (ie, "docker.io/datawire/ambassador-operator:v1.2.3")
43+
ifeq ($(REL_REGISTRY),)
44+
AMB_OPER_IMAGE_FULL = $(AMB_OPER_IMAGE)
45+
else
4346
AMB_OPER_IMAGE_FULL = $(REL_REGISTRY)/$(AMB_OPER_IMAGE)
47+
endif
48+
export AMB_OPER_IMAGE_FULL
4449

4550
AMB_OPER_PKGS = $(shell go list ./...)
4651
AMB_OPER_SRCS = $(shell find . -name '*.go' ! -path './ci/cluster-providers/*')
@@ -201,7 +206,7 @@ release_builds := \
201206
# collect all the final manifests that should be part of a release.
202207
# can be invoked with a different registry in "REL_REGISTRY"
203208
collect-manifests: $(ARTIFACTS_DIR) gen-crds
204-
$(Q)$(TOP_DIR)/ci/create_manifests.sh $(AMB_OPER_IMAGE) $(ARTIFACTS_DIR)
209+
$(Q)$(TOP_DIR)/ci/create_manifests.sh $(AMB_OPER_IMAGE_FULL) $(ARTIFACTS_DIR)
205210

206211
release-manifests: collect-manifests
207212

@@ -236,10 +241,10 @@ image-build: $(EXE) ## Build images
236241
--path "$(IMAGE_EXTRA_FILE)" --content "$(IMAGE_EXTRA_FILE_CONTENT)" --image $(AMB_OPER_IMAGE) --check ; \
237242
fi
238243

239-
image-push: image-build ## Push images to the registry
244+
image-push: image-build ## Push images to the registry in REL_REGISTRY
240245
$(Q)$(TOP_DIR)/hack/image/push-image-tags.sh $(AMB_OPER_IMAGE) $(AMB_OPER_IMAGE_FULL)
241246

242-
chart-push: ## Push the Helm chart (will need some AWS env vars)
247+
chart-push: ## Push the Helm chart [will need some AWS env vars]
243248
@echo ">>> Preparing Helm chart values with image=$(AMB_OPER_IMAGE_FULL)"
244249
$(Q)mv $(AMB_OPER_CHART_VALS) $(AMB_OPER_CHART_VALS).bak
245250
$(Q)cat $(AMB_OPER_CHART_VALS).bak | sed -e "s|ambassador-operator:dev|$(AMB_OPER_IMAGE_FULL)|g" > $(AMB_OPER_CHART_VALS)
@@ -261,13 +266,11 @@ test: ## Run the Go tests
261266

262267
$(AMB_COVERAGE_FILE): test
263268

264-
e2e: ## Run the e2e tests -- VERBOSE=1, TEST=<some-test.sh>, CLUSTER_KEEP=1
269+
e2e: collect-manifests ## Run the e2e tests [VERBOSE=1 TEST=<some-test.sh> CLUSTER_KEEP=1]
265270
@echo ">>> Running e2e tests"
266-
$(Q)AMB_OPER_IMAGE=$(AMB_OPER_IMAGE) make collect-manifests
267-
$(Q)AMB_OPER_IMAGE=$(AMB_OPER_IMAGE) \
268-
$(TOP_DIR)/tests/e2e/runner.sh \
269-
--image-name=$(AMB_OPER_BASE_IMAGE) \
270-
--image-tag=$(AMB_OPER_TAG) \
271+
$(Q)$(TOP_DIR)/tests/e2e/runner.sh \
272+
--image-name=$(AMB_OPER_IMAGE_NAME) \
273+
--image-tag=$(AMB_OPER_IMAGE_TAG) \
271274
check $(TEST)
272275

273276
##############################
@@ -306,6 +309,8 @@ ci/lint: lint
306309
ci/check-format-gen: format format-sh generate
307310
$(Q)$(TOP_DIR)/hack/tests/check-dirty.sh
308311

312+
ci/manifests: collect-manifests
313+
309314
ci/build: lint build image-build
310315

311316
ci/test: test
@@ -315,15 +320,18 @@ ci/e2e: e2e
315320
ci/all: ci/lint ci/build ci/test ci/e2e
316321

317322
ci/release:
318-
$(Q)AMB_OPER_IMAGE=$(AMB_OPER_IMAGE_FULL) make collect-manifests gen-crds-docs
323+
@echo ">>> Creating a registry in the cloud (with $(CLUSTER_REGISTRY))"
324+
$(Q)make collect-manifests gen-crds-docs
319325

320-
ci/smoke-tests/kind:
326+
ci/smoke-tests/kind: ci/manifests
321327
tests/smoke-tests/kind.sh setup
322328
tests/smoke-tests/kind.sh run
323329
tests/smoke-tests/kind.sh cleanup
324330

325331
ci/publish-image: image-push
326332

333+
# ci/publish-image-cloud creates a cloud with the CLOUD_PROVIDER, gets the DEV_REGISTRY
334+
# and uses it as the REL_REGISTRY, and then it pushes the image to the REL_REGISTRY
327335
ci/publish-image-cloud: clean
328336
$(Q)[ -n "$(CLUSTER_REGISTRY)" ] || { echo "FATAL: no CLUSTER_REGISTRY defined" ; exit 1 ; }
329337
$(Q)[ -n "$(CLUSTER_PROVIDER)" ] || { echo "FATAL: no CLUSTER_PROVIDER defined" ; exit 1 ; }

ci/common.sh

+29-12
Original file line numberDiff line numberDiff line change
@@ -1005,24 +1005,41 @@ amb_inst_check_uninstalled() {
10051005
# Operator
10061006
########################################################################################################################
10071007

1008-
# 'cat' a manifest, replacing the default image (ie, ambassador-operator:dev)
1009-
# by the full image name (ie, docker.io/datawire/ambassador-operator:v1.2.3)
1008+
# get the full image name (ie, docker.io/datawire/ambassador-operator:v1.2.3)
1009+
# an optional argument will force the "development" or "release" image
10101010
get_full_image_name() {
1011-
if [ -n "$OPERATOR_IMAGE" ]; then
1012-
echo "$OPERATOR_IMAGE"
1013-
elif [ -n "$DEV_REGISTRY" ]; then
1014-
echo "$DEV_REGISTRY/$AMB_OPER_IMAGE_NAME:$AMB_OPER_IMAGE_TAG"
1015-
else
1016-
echo "$AMB_OPER_IMAGE_NAME:$AMB_OPER_IMAGE_TAG"
1017-
fi
1011+
local image="$AMB_OPER_IMAGE_NAME:$AMB_OPER_IMAGE_TAG"
1012+
1013+
case $1 in
1014+
"dev" | "development")
1015+
[ -n "$DEV_REGISTRY" ] || abort "no DEV_REGISTRY defined"
1016+
echo "$DEV_REGISTRY/$image"
1017+
;;
1018+
"rel" | "release")
1019+
[ -n "$REL_REGISTRY" ] || abort "no REL_REGISTRY defined"
1020+
echo "$REL_REGISTRY/$image"
1021+
;;
1022+
*)
1023+
if [ -n "$OPERATOR_IMAGE" ]; then
1024+
echo "$OPERATOR_IMAGE"
1025+
elif [ -n "$AMB_OPER_IMAGE_FULL" ]; then
1026+
echo "$AMB_OPER_IMAGE_FULL"
1027+
else
1028+
echo "$image"
1029+
fi
1030+
;;
1031+
esac
10181032
}
10191033

10201034
# 'cat' a manifest, replacing the default image (ie, ambassador-operator:dev)
10211035
# by the full image name (ie, docker.io/datawire/ambassador-operator:v1.2.3)
10221036
cat_setting_image() {
1023-
local full_image=$(get_full_image_name)
1037+
local filename=$1
1038+
local mode=${2:-dev}
1039+
1040+
local full_image="$(get_full_image_name $mode)"
10241041
info "(replacing image ${AMB_OPER_MANIF_DEF_IMAGE} by ${full_image})"
1025-
cat "$1" | sed -e "s|$AMB_OPER_MANIF_DEF_IMAGE|$full_image|g"
1042+
cat "$filename" | sed -e "s|$AMB_OPER_MANIF_DEF_IMAGE|$full_image|g"
10261043
}
10271044

10281045
# oper_uninstall <NS>
@@ -1122,7 +1139,7 @@ oper_install_yaml() {
11221139
oper_install_helm() {
11231140
local namespace="$1"
11241141
helm install ambassador-operator --wait --namespace "$namespace" \
1125-
--set namespace="$namespace",image.name=$(get_full_image_name) \
1142+
--set namespace="$namespace",image.name=$(get_full_image_name dev) \
11261143
deploy/helm/ambassador-operator/
11271144
}
11281145

ci/create_manifests.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ source "$cm_dir/common.sh"
1313
#################################################################################################
1414

1515
# arguments
16-
AMB_OPER_IMAGE=${AMB_OPER_IMAGE:-$1}
16+
AMB_OPER_IMAGE_FULL=${AMB_OPER_IMAGE_FULL:-$1}
1717

1818
# the output directory
1919
ARTIFACTS_DIR=${ARTIFACTS_DIR:-$2}
@@ -36,8 +36,8 @@ helm_crds_manif="$helm_dir/crds/ambassador-installation.yaml"
3636
release_name="ambassador"
3737
namespace="ambassador"
3838
values_yaml="$helm_dir/values.yaml"
39-
full_image=$(get_full_image_name)
40-
args="-n ${namespace} --values $values_yaml --set image.name=${full_image}"
39+
full_image=$AMB_OPER_IMAGE_FULL
40+
args="-n ${namespace} --values $values_yaml --set image.name=${AMB_OPER_IMAGE_FULL}"
4141

4242
namespace_manif=$(
4343
cat <<EOF
@@ -61,7 +61,7 @@ info "Preparing release manifests in $ARTIFACTS_DIR"
6161
[ -f "$values_yaml" ] || abort "no 'values.yaml' found at '$values_yaml'"
6262
[ -n "$ARTIFACTS_DIR" ] || abort "no ARTIFACTS_DIR provided"
6363
[ -d "$ARTIFACTS_DIR" ] || abort "'$ARTIFACTS_DIR' is not a valid directory"
64-
[ -n "$AMB_OPER_IMAGE" ] || abort "no AMB_OPER_IMAGE provided"
64+
[ -n "$AMB_OPER_IMAGE_FULL" ] || abort "no AMB_OPER_IMAGE_FULL provided"
6565

6666
rm -f $ARTIFACTS_DIR/*.yaml
6767
mkdir -p "$(dirname $ARTIFACTS_DIR)"
@@ -77,7 +77,7 @@ cp -f $artifact_crds_manif $helm_crds_manif || abort "could not create $helm_crd
7777

7878
# then we use the Helm chart for generating the standalone manifest, using
7979
# the default values.yaml
80-
info "Rendering Helm chart, using image '${full_image}'..."
80+
info "Rendering Helm chart, using image '${AMB_OPER_IMAGE_FULL}'..."
8181
mkdir -p "$(dirname $tmp_manif)"
8282
helm template $release_name \
8383
$args --set deploymentTool=amb-oper-manifest --skip-crds $helm_dir >$tmp_manif || abort "could not create $tmp_manif"
@@ -104,7 +104,7 @@ done
104104

105105
if [ -n "$VERBOSE" ]; then
106106
info "Showing manifests generated in $ARTIFACTS_DIR:"
107-
for i in ls $ARTIFACTS_DIR/*.yaml; do
107+
for i in $ARTIFACTS_DIR/*.yaml; do
108108
info "... $i"
109109
hl && cat $i && hl
110110
done

0 commit comments

Comments
 (0)