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

[Bug 1473091] Migrate mozilla/redash to circleci 2.0 #488

Merged
merged 2 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
123 changes: 123 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# These environment variables must be set in CircleCI UI
#
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo>
# DOCKER_USER
# DOCKER_PASS
#

version: 2
jobs:
build:
docker:
- image: docker:18.02.0-ce
working_directory: ~/mozilla/redash
steps:
- checkout
- setup_remote_docker
- run: |
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' "$CIRCLE_SHA1" "$CIRCLE_TAG" "$CIRCLE_PROJECT_USERNAME" "$CIRCLE_PROJECT_REPONAME" "$CIRCLE_BUILD_URL" > version.json
- run:
command: docker build -t app:build .
no_output_timeout: 20m
Copy link

Choose a reason for hiding this comment

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

I'm trying to understand the purpose of the build job and can't find an equivalent in the old config. It's run for every tag and all branches except gh-pages IIUC. Is this just to make sure the image build succeeds?

Could we remove the writing of the version.json since it was abstracted away in the bin/deploy script for the other jobs?

Copy link
Author

Choose a reason for hiding this comment

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

Yes it's just to ensure that the image builds properly. I will remove the version.json for the build step

Copy link

Choose a reason for hiding this comment

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

Gotcha, thanks!


test:
docker:
- image: circleci/node:6.14.3-stretch
- image: redis
- image: circleci/postgres:10-alpine-postgis
working_directory: ~/mozilla/redash
steps:
- checkout
- run: mkdir -p /tmp/test-reports/pytest
- run: sudo apt-get update
- run: sudo apt-get install -y python-pip python-dev
- run: sudo apt-get install -y redis-tools redis-server
- run: sudo pip install --upgrade setuptools
- run: sudo pip install -r requirements_dev.txt
- run: sudo pip install -r requirements.txt
- run: sudo npm install
- run: sudo npm run build
- run:
command: pytest --junitxml=/tmp/test-reports/pytest/junit.xml tests/
environment:
REDASH_REDIS_URL: redis://localhost:6379/0
REDASH_DATABASE_URL: "postgresql://postgres@localhost/postgres"
- store_artifacts:
path: /tmp/test-reports/
destination: tr1
- store_test_results:
path: /tmp/test-reports/

deploy:
docker:
- image: docker:18.02.0-ce
working_directory: ~/mozilla/redash
steps:
- checkout
- setup_remote_docker
- run:
name: Deploy to Dockerhub
no_output_timeout: 20m
command: |
# Deploy master
if [ "${CIRCLE_BRANCH}" == "master" ]; then
./bin/deploy "master"
else
# Deploy a release tag...
./bin/deploy "rc"
fi
Copy link

Choose a reason for hiding this comment

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

Could we split the deploy job into two jobs deploy-master and deploy-rc (and update the workflows below) instead of having the shell script with the condition? That would make it more obvious in the Circle UI what's happening.

Copy link
Author

Choose a reason for hiding this comment

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

sure

Copy link

Choose a reason for hiding this comment

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

Thanks!


deploy-milestone:
docker:
- image: docker:18.02.0-ce
working_directory: ~/mozilla/redash
steps:
- checkout
- setup_remote_docker
- run:
name: Deploy milestone to Dockerhub
no_output_timeout: 20m
command: |
./bin/deploy "$CIRCLE_TAG"
./bin/alias "$CIRCLE_TAG" "latest"


workflows:
version: 2
build-test-deploy:
jobs:
- build:
filters:
tags:
only: /.*/
branches:
ignore:
- gh-pages

- test:
filters:
tags:
only: /.*/
branches:
ignore:
- gh-pages

- deploy:
requires:
- test
filters:
tags:
only: /.*/
branches:
only:
- master
- release

- deploy-milestone:
requires:
- test
filters:
tags:
only: /^m[0-9]+(\.[0-9]+)?$/
branches:
ignore: /.*/
2 changes: 1 addition & 1 deletion bin/alias
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ set -eo pipefail
VERSION="$1"
ALIAS="$2"

docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker tag $DOCKERHUB_REPO:$VERSION $DOCKERHUB_REPO:$ALIAS
docker push $DOCKERHUB_REPO:$ALIAS
2 changes: 1 addition & 1 deletion bin/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build
"$CIRCLE_BUILD_URL" \
> version.json

docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker build -t $DOCKERHUB_REPO:$VERSION .
docker push $DOCKERHUB_REPO:$VERSION
40 changes: 0 additions & 40 deletions circle.yml

This file was deleted.