CircleCI build improvements (#3511)

* Make sure master builds tarball/docker image only when backend and frontend tests pass.

* Build a redash/preview image alongside redash/redash image.

* Fix version variable
This commit is contained in:
Arik Fraimovich 2019-02-28 15:23:47 +02:00 committed by GitHub
parent 549f878c98
commit a93741e64b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 30 deletions

View File

@ -96,9 +96,7 @@ jobs:
- setup_remote_docker - setup_remote_docker
- checkout - checkout
- run: .circleci/update_version - run: .circleci/update_version
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: .circleci/docker_build
- run: docker build -t redash/redash:$(.circleci/docker_tag) .
- run: docker push redash/redash:$(.circleci/docker_tag)
workflows: workflows:
version: 2 version: 2
build: build:
@ -109,21 +107,23 @@ workflows:
- frontend-unit-tests - frontend-unit-tests
- frontend-e2e-tests - frontend-e2e-tests
- build-tarball: - build-tarball:
requires: requires:
- backend-unit-tests - backend-unit-tests
filters: - frontend-unit-tests
tags: - frontend-e2e-tests
only: /v[0-9]+(\.[0-9\-a-z]+)*/ filters:
branches: branches:
only: only:
- master - master
- /release\/.*/ - /release\/.*/
- build-docker-image: - build-docker-image:
requires: requires:
- backend-unit-tests - backend-unit-tests
filters: - frontend-unit-tests
branches: - frontend-e2e-tests
only: filters:
- master branches:
- preview-build only:
- /release\/.*/ - master
- preview-image
- /release\/.*/

17
.circleci/docker_build Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
VERSION=$(jq -r .version package.json)
VERSION_TAG=$VERSION.b$CIRCLE_BUILD_NUM
docker login -u $DOCKER_USER -p $DOCKER_PASS
if [ $CIRCLE_BRANCH = master ] || [ $CIRCLE_BRANCH = preview-image ]
then
docker build -t redash/redash:preview -t redash/preview:$VERSION_TAG .
docker push redash/redash:preview
docker push redash/preview:$VERSION_TAG
else
docker build -t redash/redash:$VERSION_TAG .
docker push redash/redash:$VERSION_TAG
fi
echo "Built: $VERSION_TAG"

View File

@ -1,10 +0,0 @@
#!/bin/bash
if [ $CIRCLE_BRANCH = master ] || [ $CIRCLE_BRANCH = preview-build ]
then
FULL_VERSION='preview'
else
VERSION=$(jq -r .version package.json)
FULL_VERSION=$VERSION.b$CIRCLE_BUILD_NUM
fi
echo $FULL_VERSION