GithubHelp home page GithubHelp logo

mozilla-github-standards / 61a9144f35b30b93e9539045ef6180ae8cf41179f4f5619a1acdc50f24d2ff61 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla/tardy

0.0 0.0 0.0 11 KB

License: Other

Python 100.00%

61a9144f35b30b93e9539045ef6180ae8cf41179f4f5619a1acdc50f24d2ff61's Introduction

A library for interfacing with Stackato and for automatically updating stackato instances. This is specifically built for Mozilla and Stackato and might not be relevant to you.

This is very much a work in progress.

To install:

pip install tardy

Tardy is a Python library with a command line interface.

  • -f or --file: points to a JSON file that contains configuration. Optional, if not specified uses tardy.json
  • -d or --dump: dumps the contents of the Tardy configuration (which is just a JSON file) that contains a list of all the instances created by Tardy.
  • -t or --test: doesn't actually execute commands, just prints.
  • -g or --git: used when you aren't running Tardy from the source of the project. It will create a .tardy.repos directory and check the source out into that directory. This is used when you have one project that requires two or three other projects.
  • -l or --last: prints out the uuid of the last stackato instance created for that project.
  • -a or --action: one of update, delete, create, restart. Will do:
    • create: creates an instance and stores into the Tardy configuration.
    • update: creates a new instance, maps the urls over to it, then deletes the old one. Doing so changes the name of the instance each time.
    • restart: stops and starts each stackato instance.
    • delete: deletes each stackato instance.
  • -q or --quiet: less output onto the console.

For each stackato instance you want to create, you will need a configuration file:

{
  "stackato": {
    "name": "zippy",
    "pre": [
      "cp lib/config/local-dist.js lib/config/local.js"
    ],
    "git": {
      "repo": "https://github.com/mozilla/zippy.git"
    }
  },
  "git": {
    "name": "zippy",
    "repo": "https://github.com/mozilla/zippy.git"
  }
}
  • stackato: config for stackato
    • pre: a list of commands to run prior to upload to stackato, each command is passed the env variables as dictionary for python strings. The variable URL is also passed, this is the stackato URL instance.
    • git: the git repo of this instance.
  • git: config for git
    • repo: the git repo of this instance.

Examples

Creating an integration test between two services

In this case we have a repo that contains integration tests between two other repos. This will create a unique instance of each repo on stackato and then run the integration tests. Since the instances are unique, multiple people can run this at once:

# Create a zippy instance.
tardy -f zippy.json -a create -g

# Find the last instance of zippy so solitude can find it.
zippy=`tardy -f zippy.json --last`
echo 'Last instance of zippy is at:' $zippy
export ZIPPY=$zippy

# Create a solitude instance, pointing to zippy.
tardy -f solitude.json -a create -g

# Now run the zippy solitude integration tests.
solitude=`tardy -f solitude.json --last`
echo 'Last instance of solitude is at:' $solitude
python zippy-basic.py --url=https://solitude-$solitude.paas.allizom.org

# Get rid of our solitude and zippy instances
tardy -f solitude.json -a delete -g
tardy -f zippy.json -a delete -g

For more see https://github.com/andymckay/solitude-zippy

Updating stackato when unit tests pass

In this case we are checking out a repo and running unit tests on a repo. This will occur on each github commit. If the tests pass then it will update the instance on stackato:

source /opt/rh/python27/enable
set -e

cd $WORKSPACE
VENV=$WORKSPACE/venv

if [ ! -d "$VENV/bin" ]; then
  echo "No virtualenv found.  Making one..."
  virtualenv $VENV --system-site-packages --python=python
  source $VENV/bin/activate
  pip install --upgrade pip
fi

source $VENV/bin/activate
pip install --upgrade tardy

# In this case the jenkins user has stackato credentials to hit the server.
tardy -f tardy.json -a upgrade

Example output:

[master] hello $ tardy -a update -q
hello: Updating
Command: stackato apps --json
hello: New app id: hello
hello: Old app id: tardy-update-hello
Command: stackato apps --json
Command: stackato map tardy-update-hello original-hello.paas.allizom.org
Command: stackato push hello --as=hello --no-prompt --no-start
Command: stackato start hello --no-prompt --no-tail
Command: stackato map hello hello.paas.allizom.org
Command: stackato unmap tardy-update-hello hello.paas.allizom.org
Command: stackato apps --json
Command: stackato delete tardy-update-hello
hello: Note: the app has been renamed to hello

[master] hello $ tardy -a update -q
hello: Updating
Command: stackato apps --json
hello: New application id is: tardy-update-hello
hello: Old application id is: hello
Command: stackato apps --json
Command: stackato map hello original-hello.paas.allizom.org
Command: stackato push hello --as=tardy-update-hello --no-prompt --no-start
Command: stackato start tardy-update-hello --no-prompt --no-tail
Command: stackato map tardy-update-hello hello.paas.allizom.org
Command: stackato unmap hello hello.paas.allizom.org
Command: stackato apps --json
Command: stackato unmap tardy-update-hello tardy-update-hello.paas.allizom.org
Command: stackato delete hello
hello: Note: the app has been renamed to tardy-update-hello

For more see https://github.com/mozilla/zippy

61a9144f35b30b93e9539045ef6180ae8cf41179f4f5619a1acdc50f24d2ff61's People

Contributors

mozilla-github-standards avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.