Skip to content

Commit

Permalink
Make travis file use build stages
Browse files Browse the repository at this point in the history
  • Loading branch information
bkgoksel committed Mar 13, 2019
1 parent 84750ed commit d5d9c39
Showing 1 changed file with 72 additions and 61 deletions.
133 changes: 72 additions & 61 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,72 @@
language: python
sudo: required
services:
- docker
env:
- CODALAB_USERNAME=codalab CODALAB_PASSWORD=testpassword CI=false
python:
- 3.6
- 2.7
before_install:
- docker --version
- chmod +x ./docker/build_images.sh
- chmod +x ./scripts/upload_to_pypi.sh
install:
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install sqlalchemy; fi
# add packages required by tests (mock and nose are on Travis VM by default)
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install pyyaml psutil; fi
- sudo apt-get update
- sudo apt-get install -y sshpass python-virtualenv
- sudo apt-get install -y libmysqlclient-dev
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./setup.sh server; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./venv/bin/pip install --upgrade setuptools; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./venv/bin/pip install --upgrade pip; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then virtualenv -p python3.6 venv; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then ./venv/bin/pip install --upgrade black==18.9b0; fi
before_script:
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then mysql -e "CREATE DATABASE codalab_bundles;"; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./codalab/bin/cl config server/engine_url mysql://root@localhost:3306/codalab_bundles; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./codalab/bin/cl config cli/default_address http://localhost:2900; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./scripts/create-root-user.py $CODALAB_PASSWORD; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./codalab/bin/cl server; fi &
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./codalab/bin/cl bundle-manager; fi &
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then printf "$CODALAB_USERNAME\n$CODALAB_PASSWORD\n" > /home/travis/.codalab/root.password; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then chmod 600 /home/travis/.codalab/root.password; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then sleep 15; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install ./worker; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then cl-worker --server http://127.0.0.1:2900 --work-dir /home/travis/.codalab/worker-scratch --password-file /home/travis/.codalab/root.password --verbose; fi &
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then printf "$CODALAB_USERNAME\n$CODALAB_PASSWORD\n" | sshpass -p "" ./codalab/bin/cl work; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./codalab/bin/cl upload -c stuff; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then printf "$CODALAB_USERNAME\n$CODALAB_PASSWORD\n" | sshpass -p "" ./codalab/bin/cl rm ^; fi
script:
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then ./venv/bin/black . --check; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./venv/bin/python test-cli.py default; fi
after_success: echo "skipped"
deploy:
# Build docker images using tag if it's a version tag (we're releasing)
# Otherwise if we're on master or staging build named images
- provider: script
# Remove first char of tag (v) to get version number from tag
script: if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./scripts/travis_deploy.sh ${$TRAVIS_TAG:1} release; fi
on:
branch: release
# only build on valid semver tags
tags: true
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+
- provider: script
# Build with branch name if not releasing
script: if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then ./scripts/travis_deploy.sh $TRAVIS_BRANCH branch; fi
on:
# only build for master and staging for debugging
branch: master
jobs:
include:
- stage: functionality
language: python
sudo: required
services:
- docker
env:
- CODALAB_USERNAME=codalab CODALAB_PASSWORD=testpassword CI=false
python: 2.7
before_install:
- docker --version
install:
- pip install sqlalchemy
# add packages required by tests (mock and nose are on Travis VM by default)
- pip install pyyaml psutil
- sudo apt-get update
- sudo apt-get install -y sshpass python-virtualenv
- sudo apt-get install -y libmysqlclient-dev
- ./setup.sh server
- ./venv/bin/pip install --upgrade setuptools
- ./venv/bin/pip install --upgrade pip
before_script:
- mysql -e "CREATE DATABASE codalab_bundles;"
- ./codalab/bin/cl config server/engine_url mysql://root@localhost:3306/codalab_bundles
- ./codalab/bin/cl config cli/default_address http://localhost:2900
- ./scripts/create-root-user.py $CODALAB_PASSWORD
- ./codalab/bin/cl server &
- ./codalab/bin/cl bundle-manager &
- printf "$CODALAB_USERNAME\n$CODALAB_PASSWORD\n" > /home/travis/.codalab/root.password
- chmod 600 /home/travis/.codalab/root.password
- sleep 15
- pip install ./worker
- cl-worker --server http://127.0.0.1:2900 --work-dir /home/travis/.codalab/worker-scratch --password-file /home/travis/.codalab/root.password --verbose &
- printf "$CODALAB_USERNAME\n$CODALAB_PASSWORD\n" | sshpass -p "" ./codalab/bin/cl work
- ./codalab/bin/cl upload -c stuff
- printf "$CODALAB_USERNAME\n$CODALAB_PASSWORD\n" | sshpass -p "" ./codalab/bin/cl rm ^
script:
- ./venv/bin/python test-cli.py default
- stage: style
language: python
python: 3.6
install: pip install --upgrade black==18.9b0
script: black . --check
- stage: deploy
script: echo "Deploying"
language: python
sudo: required
services:
- docker
env:
- CODALAB_USERNAME=codalab CODALAB_PASSWORD=testpassword CI=false
python:
- 2.7
after_success: echo "skipped"
deploy:
# Build docker images using tag if it's a version tag (we're releasing)
# Otherwise if we're on master or staging build named images
- provider: script
# Remove first char of tag (v) to get version number from tag
script: ./scripts/travis_deploy.sh ${$TRAVIS_TAG:1} release
on:
branch: release
# only build on valid semver tags
tags: true
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+
- provider: script
# Build with branch name if not releasing
script: ./scripts/travis_deploy.sh $TRAVIS_BRANCH branch
on:
# only build for master and staging for debugging
branch: master

0 comments on commit d5d9c39

Please sign in to comment.