Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image building/pushing back to Travis #835

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build/
examples/dev.yaml

# Unencrypted credentials
heptio-images-ee4b0474b93e.json
heptio-images-c14f11347d8b.json

# Dynamic Dockerfiles
Dockerfile-amd64
Expand Down
51 changes: 22 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
sudo: required
language: go
go:
- "1.12"

- '1.12'
services:
- docker

- docker
install: true

script:
- VERBOSE=true make test int
- ./travis-ci.sh

script:
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST, BRANCH=$BRANCH"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these 2 for clarity; very unintuitive how $TRAVIS_BRANCH won't be the PRs branch. See the issues/article I linked to elsewhere on this PR.

- VERBOSE=true make test int
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these changes are due to the fact that the travis cli tool edits/rewrites the .travis.yml file. So it is probably just a serialization improvement even if both are technically valid.

- ./travis-ci.sh
before_install:
# Download and install Kind
- curl -L https://github.com/kubernetes-sigs/kind/releases/download/v0.4.0/kind-linux-amd64 --output kind && chmod +x kind
- ./kind create cluster --config kind-config.yaml
- export KUBECONFIG="$(./kind get kubeconfig-path --name="kind")"
- curl -L https://github.com/golang/dep/releases/download/v0.5.3/dep-linux-amd64 --output dep && chmod +x dep

- curl -L https://github.com/kubernetes-sigs/kind/releases/download/v0.4.0/kind-linux-amd64
--output kind && chmod +x kind
- ./kind create cluster --config kind-config.yaml
- export KUBECONFIG="$(./kind get kubeconfig-path --name="kind")"
- curl -L https://github.com/golang/dep/releases/download/v0.5.3/dep-linux-amd64 --output
dep && chmod +x dep
before_deploy:
# Install gcloud cli here so it gets cached
- if [ ! -d ${HOME}/google-cloud-sdk ]; then
curl https://sdk.cloud.google.com | bash /dev/stdin --disable-prompts;
fi

- if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash
/dev/stdin --disable-prompts; fi
deploy:
- provider: script
skip_cleanup: true
script: ./travis-deploy.sh
on:
repo: heptio/sonobuoy
all_branches: true

- provider: script
skip_cleanup: true
script: ./travis-deploy.sh
on:
repo: heptio/sonobuoy
all_branches: true
env:
secure: AsGb+4LLxBE9fo8eJMfuwUK3QTt61TC+HDP+GbzRaYPB27usaSouAvqeLJI2jxDU/oNaDlNarb3A43gZIqbZe+0uT8jdrqnv5pGmX4CooNm52zF4QEQrFpERvfFAdbUKkZ11NLXav3S0iLVb8/iWopF0/yvt7h0ohBzNX/tMs7vYeZ5KbKUF8v7Uwg3VmjIHsvfSmtaEvWPi3302O/lo5J1tB6TH8b/bAXWweU8GKmQnQKES/+tUern+zOT0S47/fyRbvG6KbLdttol9k7KbzWZxG2iHcC65ogmdHD2azZmLyL8s5khDkA2rO4ovnOqse2kxmxn7da7y8k93vWaN1y98RpXw4H6brsH15BzoGoYBaMLg/Kn/JbTkSxPkPr/+6WGJ6lFeGgvArkwCXVyRPpecSH55+kvKmD8wxGnXaQp086cNKBiZYgN4C+T/8XXO011CxgjzLCsyyqr2KGI7c1VXvdiDt+fjVUeE/ftbHFdHH8Oc809U+6sa+6UWFxDcg3fsyIDKqUAh+cOYdjL+8+OpNWiV8p7/Yu+QntbfMuRmkyQz9boYZU58uzFGe0B87nu0Y9O6nIKJWu07nPiPP11CU3iv2aYDfg2y1wvyvk5rWSgnBnD82nHf7ip2/bykbsajK2fcX1sIA/3c7NzWtKauxnfTXLxxqBRbZFkOuoE=

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
Binary file added heptio-images-c14f11347d8b.json.enc
Binary file not shown.
Binary file removed heptio-images-ee4b0474b93e.json.enc
Binary file not shown.
14 changes: 13 additions & 1 deletion travis-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ function goreleaser() {
curl -sL https://git.io/goreleaser | bash
}

if [ ! -z "$TRAVIS_TAG" ]; then
function gcr_push() {
openssl aes-256-cbc -K $encrypted_222a2009ef6d_key -iv $encrypted_222a2009ef6d_iv -in heptio-images-c14f11347d8b.json.enc -out heptio-images-c14f11347d8b.json -d
gcloud auth activate-service-account --key-file heptio-images-c14f11347d8b.json
# https://github.com/travis-ci/travis-ci/issues/9905
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue was closed. Do we still need to do the unset below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/shrug

I was just adding back the exact code that we previously had done this work. Let's just leave it (if it works) since this is all probably temporary anyways.

Copy link
Contributor

@zubron zubron Aug 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is all probably temporary anyways

That is a very good point. Ignore that comment then :)

unset GIT_HTTP_USER_AGENT
IMAGE_BRANCH="$BRANCH" DOCKER="gcloud docker -- " make container push
}

if [ ! -z "$TRAVIS_TAG" ]; then
if [ "$(./sonobuoy version --short)" != "$TRAVIS_TAG" ]; then
echo "sonobuoy version does not match tagged version!" >&2
echo "sonobuoy short version is $(./sonobuoy version --short)" >&2
Expand All @@ -23,4 +30,9 @@ if [ ! -z "$TRAVIS_TAG" ]; then
fi

goreleaser --skip-validate
gcr_push
fi

if [ "$BRANCH" == "master" ]; then
gcr_push
fi