forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18ab395
commit 23091c2
Showing
3 changed files
with
140 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,130 @@ | ||
version: 2.0 | ||
# These environment variables must be set in CircleCI UI | ||
# | ||
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo> | ||
# DOCKER_USER | ||
# DOCKER_PASS | ||
# | ||
|
||
version: 2 | ||
jobs: | ||
unit-tests: | ||
environment: | ||
COMPOSE_FILE: .circleci/docker-compose.circle.yml | ||
COMPOSE_PROJECT_NAME: redash | ||
build: | ||
docker: | ||
- image: circleci/buildpack-deps:xenial | ||
- image: docker:18.02.0-ce | ||
working_directory: ~/mozilla/redash | ||
steps: | ||
- setup_remote_docker | ||
- checkout | ||
- setup_remote_docker | ||
- run: | ||
name: Build Docker Images | ||
command: | | ||
set -x | ||
docker-compose up -d | ||
sleep 10 | ||
- run: | ||
name: Create Test Database | ||
command: docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests;" | ||
- run: | ||
name: Run Tests | ||
command: docker-compose run --name tests redash tests --junitxml=junit.xml tests/ | ||
- run: | ||
name: Copy Test Results | ||
command: | | ||
mkdir -p /tmp/test-results/unit-tests | ||
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 | ||
- store_artifacts: | ||
path: coverage.xml | ||
build-tarball: | ||
command: docker build -t app:build . | ||
no_output_timeout: 20m | ||
|
||
test: | ||
docker: | ||
- image: circleci/node:8 | ||
- image: circleci/node:6.14.3-stretch | ||
- image: redis | ||
- image: circleci/postgres:10-alpine-postgis | ||
working_directory: ~/mozilla/redash | ||
steps: | ||
- checkout | ||
- run: npm install | ||
- run: npm run build | ||
- run: .circleci/update_version | ||
- run: .circleci/pack | ||
- 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/artifacts/ | ||
build-docker-image: | ||
docker: | ||
- image: circleci/buildpack-deps:xenial | ||
steps: | ||
- setup_remote_docker | ||
- checkout | ||
- run: .circleci/update_version | ||
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS | ||
- run: docker build -t redash/redash:$(.circleci/docker_tag) . | ||
- run: docker push redash/redash:$(.circleci/docker_tag) | ||
integration-tests: | ||
working_directory: ~/redash | ||
machine: true | ||
environment: | ||
REDASH_SERVER_URL : "http://127.0.0.1:5000/" | ||
DOCKER_IMAGE: mozilla/redash-ui-tests | ||
path: /tmp/test-reports/ | ||
destination: tr1 | ||
- store_test_results: | ||
path: /tmp/test-reports/ | ||
|
||
deploy-master: | ||
machine: | ||
enable: true | ||
working_directory: ~/mozilla/redash | ||
steps: | ||
- checkout | ||
- run: | ||
name: Install Docker Compose | ||
command: | | ||
set -x | ||
pip install --upgrade pip | ||
pip install docker-compose>=1.18 | ||
docker-compose --version | ||
- run: | ||
name: Pull redash images | ||
name: Deploy to Dockerhub | ||
no_output_timeout: 20m | ||
command: | | ||
set -x | ||
docker-compose -f docker-compose.yml up --no-start | ||
sleep 10 | ||
- run: | ||
name: Pull redash-ui-tests | ||
command: docker pull "${DOCKER_IMAGE}":latest | ||
./bin/deploy "master" | ||
deploy-rc: | ||
machine: | ||
enable: true | ||
working_directory: ~/mozilla/redash | ||
steps: | ||
- checkout | ||
- run: | ||
name: Setup redash instance | ||
name: Deploy to Dockerhub | ||
no_output_timeout: 20m | ||
command: | | ||
set -x | ||
docker-compose run --rm --user root server create_db | ||
docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests" | ||
docker-compose run --rm --user root server /app/manage.py users create_root root@example.com "rootuser" --password "IAMROOT" --org default | ||
docker-compose run --rm --user root server /app/manage.py ds new "ui-tests" --type "url" --options '{"title": "uitests"}' | ||
docker-compose run -d -p 5000:5000 --user root server | ||
docker-compose start postgres | ||
docker-compose run --rm --user root server npm install | ||
docker-compose run --rm --user root server npm run build | ||
./bin/deploy "rc" | ||
deploy-milestone: | ||
machine: | ||
enable: true | ||
working_directory: ~/mozilla/redash | ||
steps: | ||
- checkout | ||
- run: | ||
name: Run tests | ||
name: Deploy milestone to Dockerhub | ||
no_output_timeout: 20m | ||
command: | | ||
set -x | ||
docker run --net="host" --env REDASH_SERVER_URL="${REDASH_SERVER_URL}" "${DOCKER_IMAGE}" | ||
- store_artifacts: | ||
path: report.html | ||
./bin/deploy "$CIRCLE_TAG" | ||
./bin/alias "$CIRCLE_TAG" "latest" | ||
workflows: | ||
version: 2 | ||
integration_tests: | ||
build-test-deploy: | ||
jobs: | ||
- integration-tests: | ||
- build: | ||
filters: | ||
branches: | ||
only: master | ||
build: | ||
jobs: | ||
- unit-tests | ||
- build-tarball: | ||
requires: | ||
- unit-tests | ||
filters: | ||
tags: | ||
only: /v[0-9]+(\.[0-9\-a-z]+)*/ | ||
branches: | ||
only: | ||
- master | ||
- /release\/.*/ | ||
- build-docker-image: | ||
requires: | ||
- unit-tests | ||
filters: | ||
branches: | ||
only: | ||
- /release\/.*/ | ||
tags: | ||
only: /.*/ | ||
branches: | ||
ignore: | ||
- gh-pages | ||
|
||
- test: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
ignore: | ||
- gh-pages | ||
|
||
- deploy-master: | ||
requires: | ||
- test | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
|
||
- deploy-rc: | ||
requires: | ||
- test | ||
filters: | ||
branches: | ||
only: | ||
- release | ||
|
||
- deploy-milestone: | ||
requires: | ||
- test | ||
filters: | ||
tags: | ||
only: /^m[0-9]+(\.[0-9]+)?$/ | ||
branches: | ||
ignore: /.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
[ ! -z $DOCKERHUB_REPO ] && [ $# -eq 2 ] | ||
|
||
VERSION="$1" | ||
ALIAS="$2" | ||
|
||
docker login -u $DOCKER_USER -p $DOCKER_PASS | ||
docker tag $DOCKERHUB_REPO:$VERSION $DOCKERHUB_REPO:$ALIAS | ||
docker push $DOCKERHUB_REPO:$ALIAS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
[ ! -z $DOCKERHUB_REPO ] && [ $# -eq 1 ] | ||
|
||
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 | ||
|
||
docker login -u $DOCKER_USER -p $DOCKER_PASS | ||
docker build -t $DOCKERHUB_REPO:$VERSION . | ||
docker push $DOCKERHUB_REPO:$VERSION |