def get_travis_files_content(full_name, github_token, config): """ Return the content of the files that will be committed to the repo. """ info = { 'GIT_NAME': GIT_NAME, 'GIT_EMAIL': GIT_EMAIL, 'GH_TOKEN': github_token } user_pages = github_utils.is_user_pages(full_name) travis_files = [ { 'name': SCRIPT, 'content': travis_utils.get_script_contents(SCRIPT, config), 'message': ( 'Add build and deploy script (via Statiki).\n\n[skip ci]' ), }, { 'name': '.travis.yml', 'content': travis_utils.get_yaml_contents( full_name, SCRIPT, info, user_pages ), 'message': 'Add .travis.yml (via Statiki).', }, ] return travis_files
def test_should_get_yaml_contents_for_unknown_repo(self): # When git_info = { 'GH_TOKEN': GH_TOKEN, 'GIT_NAME': 'Travis CI', 'GIT_EMAIL': '*****@*****.**' } script_name = 'bazooka.sh' contents = travis_utils.get_yaml_contents( 'punchagan/unknown', script_name, git_info, user_pages=True ) # Then data = yaml.load(contents) self.assertIn('deploy', data['branches']['only'])
def create_travis_config(path, repo, gh_token): """ Add .travis.yml. """ travis_yml = join(path, '.travis.yml') if exists(travis_yml): print('%s already exists. Nothing to do.' % travis_yml) return info = dict(GIT_NAME=GIT_NAME, GIT_EMAIL=GIT_EMAIL, GH_TOKEN=gh_token) content = travis_utils.get_yaml_contents(repo, SCRIPT, info) with open(travis_yml, 'w') as f: f.write(content) print('%s created. Add and commit to the git repo.' % travis_yml)
def test_should_get_yaml_contents(self): # Given git_user_info = { 'GH_TOKEN': GH_TOKEN, 'GIT_NAME': 'Travis CI', 'GIT_EMAIL': '*****@*****.**' } script_name = 'fabfile.py' # When contents = travis_utils.get_yaml_contents( THIS_REPO, script_name, git_user_info ) # Then data = yaml.load(contents) self.assertIn('install', data) self.assertIn('script', data) self.assertIn('secure', data['env']['global']) self.assertIn('fab -f %s main' % script_name, data['script'])