Skip to content

Commit

Permalink
Update Circle CI for our workflow
Browse files Browse the repository at this point in the history
- Use new master / rc release release strategy (#440)
- Migrate Circle CI 2.0 (#488, #502)

# Conflicts:
#	.circleci/config.yml
  • Loading branch information
robotblake authored and jezdez committed Mar 25, 2019
1 parent fb382fd commit e79b5ea
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 19 deletions.
52 changes: 45 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
name: Copy Test Results
command: |
mkdir -p /tmp/test-results/unit-tests
docker cp tests:/app/coverage.xml ./coverage.xml
docker cp tests:/app/coverage.xml ./coverage.xml
docker cp tests:/app/junit.xml /tmp/test-results/unit-tests/results.xml
- store_test_results:
path: /tmp/test-results
Expand Down Expand Up @@ -96,15 +96,37 @@ jobs:
steps:
- setup_remote_docker
- checkout
- run: .circleci/update_version
- run: .circleci/docker_build
- run: .circleci/update_version "master"
- run: .circleci/docker_build "master"
build-docker-image-rc:
docker:
- image: circleci/buildpack-deps:xenial
steps:
- setup_remote_docker
- checkout
- run: .circleci/update_version "rc"
- run: .circleci/docker_build "rc"
build-docker-image-tag:
docker:
- image: circleci/buildpack-deps:xenial
steps:
- setup_remote_docker
- checkout
- run: .circleci/update_version "$CIRCLE_TAG"
- run: .circleci/docker_build "rc"
# Create alias from tag to "latest":
- run: docker tag $DOCKERHUB_REPO:$CIRCLE_TAG $DOCKERHUB_REPO:latest
- run: docker push $DOCKERHUB_REPO:latest
workflows:
version: 2
build:
jobs:
- python-flake8-tests
- legacy-python-flake8-tests
- backend-unit-tests
- backend-unit-tests:
filters:
tags:
only: /^m[0-9]+(\.[0-9]+)?$/
- frontend-unit-tests
- frontend-e2e-tests
- build-tarball:
Expand All @@ -116,7 +138,6 @@ workflows:
branches:
only:
- master
- /release\/.*/
- build-docker-image:
requires:
- backend-unit-tests
Expand All @@ -126,5 +147,22 @@ workflows:
branches:
only:
- master
- preview-image
- /release\/.*/
- build-docker-image-rc:
requires:
- backend-unit-tests
- frontend-unit-tests
- frontend-e2e-tests
filters:
branches:
only:
- release
- build-docker-image-tag:
requires:
- backend-unit-tests
- frontend-unit-tests
- frontend-e2e-tests
filters:
branches:
ignore: /.*/
tags:
only: /^m[0-9]+(\.[0-9]+)?$/
14 changes: 3 additions & 11 deletions .circleci/docker_build
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
#!/bin/bash
VERSION=$(jq -r .version package.json)
VERSION_TAG=$VERSION.b$CIRCLE_BUILD_NUM
VERSION_TAG="$1"

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
docker build -t $DOCKERHUB_REPO:$VERSION_TAG .
docker push $DOCKERHUB_REPO:$VERSION_TAG

echo "Built: $VERSION_TAG"
5 changes: 4 additions & 1 deletion .circleci/update_version
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
MOZILLA_VERSION="$1"
bin/dockerflow-version "$MOZILLA_VERSION"

VERSION=$(jq -r .version package.json)
FULL_VERSION=$VERSION+b$CIRCLE_BUILD_NUM
FULL_VERSION=$VERSION+b$CIRCLE_BUILD_NUM+"-"+$MOZILLA_VERSION

sed -ri "s/^__version__ = '([A-Za-z0-9.-]*)'/__version__ = '$FULL_VERSION'/" redash/__init__.py
sed -i "s/dev/$CIRCLE_SHA1/" client/app/version.json
13 changes: 13 additions & 0 deletions bin/dockerflow-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -eo pipefail

VERSION="$1"

printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
"$CIRCLE_SHA1" \
"$VERSION" \
"$CIRCLE_PROJECT_USERNAME" \
"$CIRCLE_PROJECT_REPONAME" \
"$CIRCLE_BUILD_URL" \
> version.json

0 comments on commit e79b5ea

Please sign in to comment.