Skip to content

Commit

Permalink
Improve the build system (Closes #614)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreroggeri committed Jan 5, 2019
1 parent b5e38a0 commit 71fea2a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
48 changes: 38 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@
dist: trusty

language: node_js

node_js:
- "8"

cache:
yarn: true
dist: trusty

before_install:
# set up awscli packages
- pip install --user awscli
- mkdir -p ~/$TRAVIS_BUILD_NUMBER
- aws s3 sync s3://agendaodonto-staging-builds/$TRAVIS_BUILD_NUMBER-staging ./dist-staging --expires "$(date -d '+1 hour' --utc +'%Y-%m-%dT%H:%M:%SZ')"
- aws s3 sync s3://agendaodonto-staging-builds/$TRAVIS_BUILD_NUMBER-prod ./dist-prod --expires "$(date -d '+1 hour' --utc +'%Y-%m-%dT%H:%M:%SZ')"

stages:
- test
- name: deploy
if: type = push
- name: quality
if: tag IS blank
- name: deploy staging
if: type = push AND branch = "develop" AND tag IS blank
- name: deploy production
if: type = push AND branch = "develop" AND tag IS present

jobs:
include:
- stage: test
- stage: quality
name: Unit Tests
addons:
chrome: stable
env:
- CHROME_BIN=google-chrome-stable
script:
- ng test --code-coverage=true --watch=false --browsers=ChromeHeadless
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- stage: test
- stage: quality
name: Lint
script: ng lint
- stage: test
script: ng build --aot
- stage: deploy
script: ./scripts/deploy.sh
- stage: quality
name: Build Staging
script:
- ng b -c=staging --aot
- aws s3 sync ./dist s3://agendaodonto-staging-builds/$TRAVIS_BUILD_NUMBER-staging --expires "$(date -d '+1 hour' --utc +'%Y-%m-%dT%H:%M:%SZ')"
- stage: quality
name: Build Prod
if: type = push AND branch = "develop" AND tag IS present
script:
- ng b -c=production --prod=true --aot
- aws s3 sync ./dist s3://agendaodonto-staging-builds/$TRAVIS_BUILD_NUMBER-prod --expires "$(date -d '+1 hour' --utc +'%Y-%m-%dT%H:%M:%SZ')"
- stage: deploy staging
script: ./scripts/deploy.sh staging
- stage: deploy production
script: ./scripts/deploy.sh production
2 changes: 1 addition & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"rules": "database.rules.json"
},
"hosting": {
"public": "dist",
"public": "dist/webapp/",
"rewrites": [
{
"source": "**",
Expand Down
12 changes: 4 additions & 8 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then
exit 1;
fi

if [[ $TRAVIS_BRANCH == "master" ]]; then
if [[ $1 == "production" ]]; then
echo "Deploying to Production"
ng b -c=prod --prod=true
mv dist-prod dist
firebase use --token $FIREBASE_TOKEN agendaodonto-29023
firebase deploy --non-interactive --token $FIREBASE_TOKEN
else
echo "Skipping deploy to production. (Not a tag)"
fi

if [[ $TRAVIS_BRANCH == "develop" ]]; then
if [[ $1 == "staging" ]]; then
echo "Deploying to Staging"
ng b -c=staging --prod=true
mv dist-staging dist
firebase use --token $FIREBASE_TOKEN agendaodontoweb-staging
firebase deploy --non-interactive --token $FIREBASE_TOKEN
else
echo "Skipping deploy to staging. (Not on develop branch)"
fi

0 comments on commit 71fea2a

Please sign in to comment.