Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #65 from gnosis/development
Browse files Browse the repository at this point in the history
Feature - Integration of transaction-history-service V1
  • Loading branch information
apanizo authored Sep 6, 2018
2 parents b1b2968 + 72d0f4c commit 3c0e4c0
Show file tree
Hide file tree
Showing 138 changed files with 82,252 additions and 22,728 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build_webpack/
78 changes: 73 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,88 @@
if: (branch = development) OR (branch = master) OR (type = pull_request) OR (tag IS present)
sudo: required
services:
- docker
language: node_js
node_js:
- "8"
- "9"
os:
- linux
env:
- DOCKER_COMPOSE_VERSION=1.22.0
before_install:
# Install custom docker-compose version
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
# Shut down postgres because it blocks our db container's port map to :5432
# it comes enabled by default in docker-compose
- sudo service postgresql stop
# Wait for it to stop
- while sudo lsof -Pi :5432 -sTCP:LISTEN -t; do sleep 1; done
# Needed to deploy pull request and releases
- sudo apt-get -y install python-pip python-dev
- pip install awscli --upgrade --user
before_script:
- yarn global add surge
# Used in the tests of the project
- export NODE_ENV=testing
- git clone https://github.com/gnosis/safe-transaction-history.git
- cd safe-transaction-history
- git checkout develop
- docker-compose build
- docker-compose up -d
# Give some time to docker to enable all services
- sleep 15
- cd ..
after_success:
- cd safe-transaction-history
- docker-compose stop
- cd ..
- |
if [ ${TRAVIS_BRANCH} = "master" ]; then
export NODE_ENV=production;
else
export NODE_ENV=development;
fi
- yarn build-storybook
- yarn build
- cd build_webpack/ && cp index.html 200.html && cd ..
- chmod ugo+x ./config/deploy/deploy.sh
- ./config/deploy/deploy.sh
# Pull Request - Deploy it to a review environment
# Travis doesn't do deploy step with pull requests builds
- ./config/travis/deploy_pull_request.sh
# Releases (tagged commits) - Deploy it to a release environment
- ./config/travis/deploy_release.sh

deploy:
# Development environment
- provider: s3
bucket: $DEV_BUCKET_NAME
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
skip_cleanup: true
local_dir: build_webpack
upload-dir: app
on:
branch: development

# Development environment - Storybook
- provider: s3
bucket: $DEV_BUCKET_NAME
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
skip_cleanup: true
local_dir: build_storybook
upload-dir: storybook
on:
branch: development

# Staging environment
- provider: s3
bucket: $STAGING_BUCKET_NAME
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
skip_cleanup: true
local_dir: build_webpack
upload-dir: current
on:
branch: master
82 changes: 0 additions & 82 deletions config/deploy/deploy.sh

This file was deleted.

44 changes: 44 additions & 0 deletions config/travis/deploy_pull_request.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

function deploy_pull_request {
REVIEW_ENVIRONMENT_DOMAIN='review.gnosisdev.com'

# Pull request name with "pr" prefix
PULL_REQUEST_NAME="pr$TRAVIS_PULL_REQUEST"

# Feature name without all path. Example gnosis/pm-trading-ui -> pm-trading-ui
REPO_NAME=$(basename $TRAVIS_REPO_SLUG)
# Only alphanumeric characters. Example pm-trading-ui -> pmtradingui
REPO_NAME_ALPHANUMERIC=$(echo $REPO_NAME | sed 's/[^a-zA-Z0-9]//g')

# TRAVIS_PULL_REQUEST contains pull request number
REVIEW_FEATURE_FOLDER="$REPO_NAME_ALPHANUMERIC/$PULL_REQUEST_NAME"
# Specific for this project only
REVIEW_FEATURE_STORYBOOK_FOLDER="${REPO_NAME_ALPHANUMERIC}storybook/$PULL_REQUEST_NAME"

# Deploy safe-team project
aws s3 sync build_webpack s3://${REVIEW_BUCKET_NAME}/${REVIEW_FEATURE_FOLDER} --delete
# Deploy safe-team storybook project
aws s3 sync build_storybook s3://${REVIEW_BUCKET_NAME}/${REVIEW_FEATURE_STORYBOOK_FOLDER} --delete
}

function publish_pull_request_urls_in_github {
REVIEW_FEATURE_URL="https://$PULL_REQUEST_NAME--$REPO_NAME_ALPHANUMERIC.$REVIEW_ENVIRONMENT_DOMAIN"
# Specific for this project only
REVIEW_FEATURE_STORYBOOK_URL="https://$PULL_REQUEST_NAME--${REPO_NAME_ALPHANUMERIC}storybook.$REVIEW_ENVIRONMENT_DOMAIN"

# Using the Issues api instead of the PR api
# Done so because every PR is an issue, and the issues api allows to post general comments,
# while the PR api requires that comments are made to specific files and specific commits
GITHUB_PR_COMMENTS=https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments
curl -H "Authorization: token ${GITHUB_API_TOKEN}" --request POST ${GITHUB_PR_COMMENTS} --data '{"body":"Travis automatic deployment:\r\n '${REVIEW_FEATURE_URL}' \r\n \r\n Storybook book automatic deployment: \r\n '${REVIEW_FEATURE_STORYBOOK_URL}'"}'
}

# Only:
# - Pull requests
# - Security env variables are available. PR from forks don't have them.
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "$AWS_ACCESS_KEY_ID" ]
then
deploy_pull_request
publish_pull_request_urls_in_github
fi
22 changes: 22 additions & 0 deletions config/travis/deploy_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Only:
# - Tagged commits
# - Security env variables are available.
if [ -n "$TRAVIS_TAG" ] && [ -n "$AWS_ACCESS_KEY_ID" ]
then
REVIEW_ENVIRONMENT_DOMAIN='review.gnosisdev.com'

# Feature name without all path. Example gnosis/pm-trading-ui -> pm-trading-ui
REPO_NAME=$(basename $TRAVIS_REPO_SLUG)
# Only alphanumeric characters. Example pm-trading-ui -> pmtradingui
REPO_NAME_ALPHANUMERIC=$(echo $REPO_NAME | sed 's/[^a-zA-Z0-9]//g')

# Only alphanumeric characters. Example v1.0.0 -> v100
TRAVIS_TAG_ALPHANUMERIC=$(echo $TRAVIS_TAG | sed 's/[^a-zA-Z0-9]//g')

REVIEW_RELEASE_FOLDER="$REPO_NAME_ALPHANUMERIC/$TRAVIS_TAG_ALPHANUMERIC"

# Deploy safe-team release project
aws s3 sync build_webpack s3://${REVIEW_BUCKET_NAME}/${REVIEW_RELEASE_FOLDER} --delete
fi
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "run-with-testrpc -l 40000000 --noVMErrorsOnRPCResponse true 'node scripts/test.js --env=jsdom'",
"test": "NODE_ENV=test && node scripts/test.js --env=jsdom",
"test-local": "NODE_ENV=test && node scripts/test.js --env=jsdom",
"precommit": "./precommit.sh",
"flow": "flow",
Expand Down Expand Up @@ -128,7 +128,7 @@
"<rootDir>/src/**/?(*.)(spec|test).js?(x)"
],
"testEnvironment": "node",
"testURL": "https://safe-react",
"testURL": "http://localhost:8000",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.(css|scss)$": "<rootDir>/config/jest/cssTransform.js",
Expand Down
Loading

0 comments on commit 3c0e4c0

Please sign in to comment.