From 4301f296007d64461f096063a16c79c8305224b0 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Mon, 1 Oct 2018 16:26:03 +0200 Subject: [PATCH] .travis.yml: set go_import_path, use deploy feature When pushing a PR to _my_ remote (github.com/ME), travis will send me an email saying that it failed to build, and keeps failing, for every update of the branch[1]. Setting this go_import_path properly should fix the build issue. Furthermore, having successfully tested the package, our .travis.yml used to check if this was a PR (it's not, in the context of a branch pushed to a fork), and did some docker image related tasks. This is done using the deployment feature of travis now.[2] [1]: https://travis-ci.com/srenatus/opa/builds/86468169 [2]: https://docs.travis-ci.com/user/deployment Signed-off-by: Stephan Renatus --- .travis.yml | 20 +++++++++++++------- Makefile | 10 ++++++++++ build/travis-utils.sh | 18 ------------------ 3 files changed, 23 insertions(+), 25 deletions(-) delete mode 100644 build/travis-utils.sh diff --git a/.travis.yml b/.travis.yml index b87bb3a4dc..e08f8cece4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ sudo: required language: go +go_import_path: github.com/open-policy-agent/opa go: - "1.10" env: @@ -8,10 +9,15 @@ env: - secure: Oi8pwShwTKnBVQtb9WoCrZSUZbDWXwO4383S6F8/USUASE/r06Zxws0XombEsy7dlG1YBS/3aLLGe5/5umrYu8XlKa0C5f1k+1ABroxQIDaiOoHJLmCTlCW0mDcbAH+THiKriPnULBnCk9qGCVofWDObPqGIIgeE5tHGm8kdfgx0hmuX5XxbZEDStSTh0eag3MFC0AdLqm4LYMaqHs56om976DmxKiO9FvkDhTSUhXsOjcgXnKoneBbzbf+1RnAr2QvuRaHS8nSZEcFnHiWNjGD/ag6Cvd2T4Aa8r5LasdYr9sx93GDteaZiyJmT4zTce4ote2kzddcEdAfK93ERUPiNXBvf0jMrqaVzbx6yI9EdcNvHRA5LARSxkT7CrOA/BjYeP+HuCjW6BJVmstDR9kFL2GoQSZJtrlI2KvHM6H3WWAMYpOCekaYKlxNa6KFoi/4RZbptJj0X5999G3qccBocfs133YQVgSNLrlBQ0KhXw4yMaO7UU8p1m063ls8VWFupWynagWGCrzWGl5w7S0r1YRVUB9kXrUmkRwqtW0niZfM1fX6BKo5PPfql7n0knhjqwo73n3kBuWxfQzYjOACYN3DFPgj0/qaNWR+AvZpqBAE5PyfxccEfpcWUvp2yrfZGuUWV628qPZLA/vQ33iN0lIndK/bCtoz6oqQq9iw= services: - docker -after_success: -- source ./build/travis-utils.sh -- if is_travis_push_env; then docker login -u $DOCKER_USER -p $DOCKER_PASSWORD; fi -- if is_travis_push_env; then make image-quick; fi -- if is_travis_push_env; then make push; fi -- if is_travis_release_env; then make tag-latest; fi -- if is_travis_release_env; then make push-latest; fi +deploy: + - provider: script + script: make deploy-travis + on: + repo: open-policy-agent/opa + branch: master + - provider: script + script: make release-travis + on: + repo: open-policy-agent/opa + branch: master + tags: true diff --git a/Makefile b/Makefile index eb7c2b446c..17dd803689 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,16 @@ push-latest: docker push $(IMAGE):latest docker push $(IMAGE):latest-debug +.PHONY: docker-login +docker-login: + @docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD} + +.PHONY: deploy-travis +deploy-travis: docker-login image-quick push + +.PHONY: release-travis +release-travis: docker-login tag-latest push-latest + .PHONY: install install: generate $(GO) install -ldflags $(LDFLAGS) diff --git a/build/travis-utils.sh b/build/travis-utils.sh deleted file mode 100644 index 43736720fa..0000000000 --- a/build/travis-utils.sh +++ /dev/null @@ -1,18 +0,0 @@ -# Travis-CI sets TRAVIS_PULL_REQUEST=false when the build is triggered for -# changes pushed into github.com/open-policy-agent/opa. -function is_travis_push_env() { - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then - return 0 - fi - return 1 -} - -# Travis-CI sets TRAVIS_TAG= when the build is triggered for a tag. -# If the tag matches the source version then we can assume this is build is -# for a release. -function is_travis_release_env() { - if [ "$TRAVIS_TAG" = "v$(make version)" ]; then - return 0 - fi - return 1 -}