Skip to content

Commit

Permalink
Automate deployment (#546)
Browse files Browse the repository at this point in the history
Introduce configuration to allow build servers provided by the Travis CI
service to execute the test generation tool and commit the resultant
files to the canonical upstream repository.

Enabling this workflow required additional administrative work:

1. Create an account with TravisCI
2. Install the `travis` command-line utility
3. Create a "deploy key" and an encrypted version using the command
   `./make.py github_deploy_key_enc`
4. Register the deploy key with the project's GitHub account
5. Check the encrypted deploy key to the repository
6. Configure the TravisCI service to automatically build this project
  • Loading branch information
jugglinmike authored and leobalter committed Apr 10, 2017
1 parent da764ca commit bcb7651
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*~
*.pyc
console/TestCases
github-deploy-key
github-deploy-key.pub
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: python
install: pip install pyyaml
script: ./make.py
after_success: |
if [ $TRAVIS_EVENT_TYPE != "push" -o $TRAVIS_BRANCH != "master" ]; then
echo This job is not running against a commit that has been merged to master.
echo Skipping deployment.
exit 0
fi
openssl aes-256-cbc \
-K $encrypted_7b3e5998334d_key \
-iv $encrypted_7b3e5998334d_iv \
-in github-deploy-key.enc \
-out github-deploy-key \
-d
chmod 600 github-deploy-key
eval "$(ssh-agent -s)"
ssh-add github-deploy-key
rm github-deploy-key
git config --global user.email "[email protected]"
git config --global user.name "Test262 Automation Script"
# The repository on TravisCI is a shallow clone, so the `master` branch must
# be retrieved explicitly, and a local branch created from the `FETCH_HEAD`
# git reference
git fetch origin master
git branch master FETCH_HEAD
./make.py deploy
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,5 @@ To remove all generated files:
The executable located at `tools/generation/generator.py` offers additional control over the generation procedure.

./tools/generation/generator.py --help

Tests expressed with this convention are built automatically following the source files' acceptance into the project. Patches should **not** include assets built from these sources.
Binary file added github-deploy-key.enc
Binary file not shown.
28 changes: 28 additions & 0 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

OUT_DIR = os.environ.get('OUT_DIR') or 'test'
SRC_DIR = os.environ.get('SRC_DIR') or 'src'
UPSTREAM = os.environ.get('UPSTREAM') or '[email protected]:tc39/test262.git'
MAINTAINER = os.environ.get('MAINTAINER') or '[email protected]'

def shell(*args):
sp = subprocess.Popen(list(args), stdout=subprocess.PIPE)
Expand Down Expand Up @@ -46,6 +48,32 @@ def build():
def clean():
shell(sys.executable, 'tools/generation/generator.py', 'clean', OUT_DIR)

@target('clean', 'build')
def deploy():
shell('git', 'add', '--all', OUT_DIR)
shell('git', 'commit', '--message', '"Re-build from source"')
shell('git', 'push', UPSTREAM, 'master')
shell('git', 'checkout', '-')

# Generate a deploy key for use in a continuous integration system, allowing
# for automated deployment in response to merge events.
@target()
def github_deploy_key():
shell('ssh-keygen',
'-t', 'rsa',
'-b', '4096',
'-C', MAINTAINER,
'-f', 'github-deploy-key')

# Encrypt the deploy key so that it may be included in the repository (to be
# decrypted by the continuous integration server during automated deployment)
# This requires the "travis" Ruby gem
# Source: https://docs.travis-ci.com/user/encrypting-files/
@target('github_deploy_key')
def github_deploy_key_enc():
shell('travis', 'login')
shell('travis', 'encrypt-file', 'github-deploy-key')

if len(sys.argv) == 1:
targets['build']()

Expand Down

0 comments on commit bcb7651

Please sign in to comment.