Skip to content

Commit

Permalink
Use Travis stages
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Oct 12, 2017
1 parent 7c0c8e7 commit ae71e06
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 147 deletions.
247 changes: 136 additions & 111 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,130 +23,155 @@ addons:
- python-virtualenv
- google-chrome-stable

matrix:
include:
- env: >
DO_TEST=TRUE
DO_LINT=TRUE
DO_NPM_DEPLOY=TRUE
DO_TRANSIFEX_DEPLOY=TRUE
# Test the examples in white space mode on the pull requests
- env: >
DEVELOPMENT=TRUE
DO_EXAMPLES_TEST=TRUE
EXAMPLES_SPLIT=1/2
DO_DIST_NGEO=TRUE
- env: >
DEVELOPMENT=TRUE
DO_EXAMPLES_TEST=TRUE
EXAMPLES_SPLIT=2/2
DO_DIST_GMF=TRUE
# Deploy the examples in advance mode on the commit on a branch
- env: >
DO_EXAMPLES_DEPLOY=TRUE
GIT_REMOTE_NAME=origin
GITHUB_USERNAME=camptocamp
EXAMPLES_NGEO=TRUE
- env: >
DO_EXAMPLES_DEPLOY=TRUE
GIT_REMOTE_NAME=origin
GITHUB_USERNAME=camptocamp
EXAMPLES_GMF=TRUE
- env: >
DO_EXAMPLES_DEPLOY=TRUE
GIT_REMOTE_NAME=origin
GITHUB_USERNAME=camptocamp
API=TRUE
APPS_GMF=TRUE
allow_failures:
- env: >
DO_EXAMPLES_DEPLOY=TRUE
GIT_REMOTE_NAME=origin
GITHUB_USERNAME=camptocamp
EXAMPLES_NGEO=TRUE
cache:
apt: true
pip: true
directories:
- node_modules

install:
env:
global:
- GIT_REMOTE_NAME=origin
- GITHUB_USERNAME=camptocamp

before_install:
- python3 --version
- /opt/google/chrome/chrome --version
- npm prune
- if [ "${TRAVIS_PULL_REQUEST}" = false ]; then IS_PR=FALSE; else IS_PR=TRUE; fi
- if [ "${TRAVIS_PULL_REQUEST_SLUG}" == "camptocamp/ngeo" ] || [ "${TRAVIS_REPO_SLUG}${TRAVIS_PULL_REQUEST_SLUG}" == "camptocamp/ngeo" ]; then export IS_EXTERNAL=FALSE; else export IS_EXTERNAL=TRUE; fi
- echo $TRAVIS_REPO_SLUG
- echo $TRAVIS_PULL_REQUEST_SLUG
- echo $IS_EXTERNAL

- if [ ${TRAVIS_REPO_SLUG}-${IS_PR} = camptocamp/ngeo-FALSE ]; then openssl aes-256-cbc -K $encrypted_66d875d20fac_key -iv $encrypted_66d875d20fac_iv -in secrets.tar.enc -out secrets.tar -d; fi
- if [ ${TRAVIS_REPO_SLUG}-${IS_PR} = camptocamp/ngeo-FALSE ]; then tar xvf secrets.tar; fi
- if [ ${TRAVIS_REPO_SLUG}-${IS_PR} = camptocamp/ngeo-FALSE ]; then cp .transifexrc $HOME/.transifexrc; fi
- if [ ${TRAVIS_REPO_SLUG}-${IS_PR} = camptocamp/ngeo-FALSE ]; then cp ngeo_deploy_key $HOME/.ssh/id_rsa; fi
- if [ ${TRAVIS_REPO_SLUG}-${IS_PR} = camptocamp/ngeo-FALSE ]; then chmod 600 $HOME/.ssh/id_rsa; fi
- git config --global user.name "Travis"
- git config --global user.email "travis@travis-ci.org"
- /opt/google/chrome/chrome --version
- export CHROME_BIN=/opt/google/chrome/chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- if [ "${IS_PR}" != "FALSE" ]; then git fetch origin ${TRAVIS_BRANCH}:${TRAVIS_BRANCH}; fi

script:
- if [ "`git grep @fileoverview src contribs`" != "" ]; then echo "Using @fileoverview breaks the documentation main page"; FALSE; fi
- if [ "`git grep @example src contribs`" != "" ]; then echo "We don't use @example to have the example in the description"; FALSE; fi
- make git-attributes
- if [ "${DO_LINT}" = TRUE ]; then make eof-newline; fi
- if [ "${DO_LINT}" = TRUE ]; then make lint; fi
- if [ "${DO_LINT}" = TRUE ]; then make check-ngeox; fi
- if [ "${DO_TEST}" = TRUE ]; then make test; fi
install:
- export GIT_BRANCH=${TRAVIS_BRANCH}

- if [ "${DO_EXAMPLES_TEST}-${IS_PR}" = TRUE-TRUE ]; then buildtools/test_examples.py ${EXAMPLES_SPLIT}; fi
- if [ "${DO_DIST_NGEO}-${IS_PR}" = TRUE-TRUE ]; then make dist/ngeo.js; fi
- if [ "${DO_DIST_NGEO}-${IS_PR}" = TRUE-TRUE ]; then make dist/ngeo-debug.js; fi
- if [ "${DO_DIST_GMF}-${IS_PR}" = TRUE-TRUE ]; then make dist/gmf.js; fi
- if [ ${TRAVIS_REPO_SLUG} = camptocamp/ngeo ]; then openssl aes-256-cbc -K $encrypted_66d875d20fac_key -iv $encrypted_66d875d20fac_iv -in secrets.tar.enc -out secrets.tar -d; fi
- if [ ${TRAVIS_REPO_SLUG} = camptocamp/ngeo ]; then tar xvf secrets.tar; fi
- if [ ${TRAVIS_REPO_SLUG} = camptocamp/ngeo ]; then cp .transifexrc $HOME/.transifexrc; fi
- if [ ${TRAVIS_REPO_SLUG} = camptocamp/ngeo ]; then cp ngeo_deploy_key $HOME/.ssh/id_rsa; fi
- if [ ${TRAVIS_REPO_SLUG} = camptocamp/ngeo ]; then chmod 600 $HOME/.ssh/id_rsa; fi
- git fetch origin ${TRAVIS_BRANCH}:${TRAVIS_BRANCH}

- echo $TRAVIS_REPO_SLUG
- echo $TRAVIS_PULL_REQUEST_SLUG
- echo $IS_EXTERNAL
- echo "${DO_EXAMPLES_TEST}-${IS_EXTERNAL}"
- echo "${DO_DIST_NGEO}-${IS_EXTERNAL}"
- echo "${DO_DIST_NGEO}-${IS_EXTERNAL}"
- echo "${DO_DIST_GMF}-${IS_EXTERNAL}"
- if [ "${DO_EXAMPLES_DEPLOY}-${IS_PR}-${IS_EXTERNAL}" = TRUE-TRUE-TRUE ]; then echo 111; fi
- if [ "${DO_EXAMPLES_DEPLOY}-${IS_PR}-${IS_EXTERNAL}" = TRUE-TRUE-TRUE ]; then buildtools/deploy.sh; fi
stages:
- Lint
- Tests
- Build
- Build and publish
- Publish on transifex

- buildtools/travis-check
jobs:
include:
- stage: Lint
install: []
script:
- make eof-newline
- make lint
- make check-ngeox
- make git-attributes
- if [ "`git grep @fileoverview src contribs`" != "" ]; then echo "Using @fileoverview breaks the documentation main page"; false; fi
- if [ "`git grep @example src contribs`" != "" ]; then echo "We don't use @example to have the example in the description"; false; fi

after_success:
- if [ "${DO_TEST}" = TRUE ]; then cat .build/coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls.js; fi
- export GIT_BRANCH=${TRAVIS_BRANCH}
- echo "_auth = ${NPM_AUTH}" > ~/.npmrc
- echo "email = stephane.brunner@camptocamp.com" >> ~/.npmrc
- make .build/python-venv
- .build/python-venv/bin/pip install jsongrep
- export PACKAGE_VERSION=`.build/python-venv/bin/jsongrep -e version package.json`
- stage: Tests
install: []
script:
- export CHROME_BIN=/opt/google/chrome/chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- make test
after_success:
- cat .build/coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls.js

- stage: Build
env:
- JOB=test-examples-1
- DEVELOPMENT=TRUE
script:
- buildtools/test_examples.py 1/2
if: type = pull_request
- stage: Build
env:
- JOB=test-examples-2
- DEVELOPMENT=TRUE
script:
- buildtools/test_examples.py 2/2
if: type = pull_request
- stage: Build
env:
- JOB=build-examples-ngeo
- DEVELOPMENT=TRUE
script:
- make examples-hosted-ngeo
if: type = pull_request
- stage: Build
env:
- JOB=build-examples-gmf
- DEVELOPMENT=TRUE
script:
- make examples-hosted-gmf
if: type = pull_request
- stage: Build
env:
- JOB=build-examples-gmf-apps
- DEVELOPMENT=TRUE
script:
- make .build/node_modules.timestamp
- make examples-hosted-apps
if: type = pull_request
- stage: Build
env:
- JOB=build-api-docs
script:
- make .build/apidoc
if: type = pull_request
- stage: Build
env:
- JOB=build-dist
- DEVELOPMENT=TRUE
script:
- make dist/ngeo.js
- make dist/ngeo-debug.js
- make dist/gmf.js
if: type = pull_request
- stage: Build and publish
env:
- JOB=publish-npm
script:
- make dist/ngeo.js
- make dist/ngeo-debug.js
- make dist/gmf.js
- .build/python-venv/bin/pip install jsongrep
- export PACKAGE_VERSION=`.build/python-venv/bin/jsongrep -e version package.json`
- echo "_auth = ${NPM_AUTH}" > ~/.npmrc
- echo "email = stephane.brunner@camptocamp.com" >> ~/.npmrc
after_success:
- if [ "${PACKAGE_VERSION}" = "${TRAVIS_TAG}" ]; then npm publish; fi
if: tag IS present AND repo = camptocamp/ngeo
- stage: Build and publish
env:
- JOB=publish-examples-ngeo
script:
- buildtools/deploy.sh
if: type = push AND repo = camptocamp/ngeo AND branch IS present
- stage: Build and publish
env:
- JOB=publish-examples-gmf
script:
- buildtools/deploy.sh
if: type = push AND repo = camptocamp/ngeo AND branch IS present
- stage: Build and publish
env:
- JOB=publish-apps-gmf
script:
- buildtools/deploy.sh
if: type = push AND repo = camptocamp/ngeo AND branch IS present
- stage: Build and publish
env:
- JOB=publish-api-docs
script:
- buildtools/deploy.sh
if: type = push AND repo = camptocamp/ngeo AND branch IS present

deploy:
- provider: script
script: buildtools/deploy.sh
skip_cleanup: true
on:
repo: camptocamp/ngeo
all_branches: true
condition: '"${DO_EXAMPLES_DEPLOY}-${IS_PR}" = TRUE-FALSE'
- provider: script
script: npm publish
skip_cleanup: true
on:
repo: camptocamp/ngeo
tags: true
condition: '"${PACKAGE_VERSION}-${DO_NPM_DEPLOY}" = "${TRAVIS_TAG}-TRUE"'
- provider: script
script: make transifex-send
skip_cleanup: true
on:
repo: camptocamp/ngeo
branch: master
condition: '"${DO_TRANSIFEX_DEPLOY}" = TRUE'
- stage: Publish on transifex
install: []
if: type = push AND branch = master AND repo = camptocamp/ngeo
after_success:
- make transifex-send
30 changes: 12 additions & 18 deletions buildtools/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@

make .build/node_modules.timestamp

if [ "${EXAMPLES_NGEO}" == TRUE ]
if [ "${JOB}" == publish-examples-ngeo ]
then
make examples-hosted-ngeo .build/examples-hosted/index.html
fi
if [ "${EXAMPLES_GMF}" == TRUE ]
if [ "${JOB}" == publish-examples-gmf ]
then
make examples-hosted-gmf .build/examples-hosted/contribs/gmf/index.html
fi
if [ "${APPS_GMF}" == TRUE ]
if [ "${JOB}" == publish-apps-gmf ]
then
make examples-hosted-apps
fi
if [ "${API}" == TRUE ]
if [ "${JOB}" == publish-api-docs ]
then
make .build/apidoc
fi

echo ${IS_EXTERNAL}
if [ "${IS_EXTERNAL}" = TRUE ]
then
exit 0
fi

make .build/ngeo-${GITHUB_USERNAME}-gh-pages \
.build/requests.timestamp \
.build/urllib3.timestamp
Expand All @@ -50,50 +44,50 @@ cd -

mkdir -p .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}
cd .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}
if [ "${EXAMPLES_NGEO}" == TRUE ]
if [ "${JOB}" == publish-examples-ngeo ]
then
git rm --ignore-unmatch --quiet --force examples/*.js examples/*.html || true
git rm --ignore-unmatch -r --quiet --force examples/data || true
git rm --ignore-unmatch -r --quiet --force examples/fonts || true
git rm --ignore-unmatch -r --quiet --force examples/lib || true
git rm --ignore-unmatch -r --quiet --force examples/partials || true
fi
if [ "${EXAMPLES_GMF}" == TRUE ]
if [ "${JOB}" == publish-examples-gmf ]
then
git rm --ignore-unmatch --quiet --force examples/contribs/gmf/*.js examples/contribs/gmf/*.html || true
fi
if [ "${APPS_GMF}" == TRUE ]
if [ "${JOB}" == publish-apps-gmf ]
then
git rm --ignore-unmatch -r --quiet --force examples/contribs/gmf/apps || true
git rm --ignore-unmatch -r --quiet --force examples/contribs/gmf/build || true
git rm --ignore-unmatch -r --quiet --force examples/contribs/gmf/fonts || true
git rm --ignore-unmatch -r --quiet --force examples/contribs/gmf/cursors || true
fi
if [ "${API}" == TRUE ]
if [ "${JOB}" == publish-api-docs ]
then
git rm --ignore-unmatch -r --quiet --force apidoc || true
fi
cd -

if [ "${EXAMPLES_NGEO}" == TRUE ]
if [ "${JOB}" == publish-examples-ngeo ]
then
mkdir -p .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/
cp -r .build/examples-hosted/* .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/
fi
if [ "${EXAMPLES_GMF}" == TRUE ]
if [ "${JOB}" == publish-examples-gmf ]
then
mkdir -p .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/contribs/gmf/
cp -r .build/examples-hosted/contribs/gmf/* .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/contribs/gmf/
fi
if [ "${APPS_GMF}" == TRUE ]
if [ "${JOB}" == publish-apps-gmf ]
then
mkdir -p .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/contribs/gmf/
cp -r .build/examples-hosted/contribs/gmf/apps .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/contribs/gmf/
cp -r .build/examples-hosted/contribs/gmf/build .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/contribs/gmf/
cp -r .build/examples-hosted/contribs/gmf/fonts .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/contribs/gmf/
cp -r .build/examples-hosted/contribs/gmf/cursors .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/examples/contribs/gmf/
fi
if [ "${API}" == TRUE ]
if [ "${JOB}" == publish-api-docs ]
then
cp -r .build/apidoc .build/ngeo-${GITHUB_USERNAME}-gh-pages/${GIT_BRANCH}/
fi
Expand Down
18 changes: 0 additions & 18 deletions buildtools/travis-check

This file was deleted.

0 comments on commit ae71e06

Please sign in to comment.