forked from bioconda/bioconda-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulate-travis.py
executable file
·84 lines (63 loc) · 2.57 KB
/
simulate-travis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
import os
import platform
import sys
import yaml
import subprocess as sp
import shlex
import argparse
usage = """
This script simulates a travis-ci run on the local machine by using the current
values in .travis.yml. It is intended to be run in the top-level directory of
the bioconda-recipes repository.
Any additional arguments to this script are interpreted as arguments to be
passed to `bioconda-utils build`. For example, to build a single recipe (or
glob of recipes):
simulate-travis.py --packages mypackagename bioconductor-*
or modify the log level:
simulate-travis.py --packages mypackagename --loglevel=debug
Notes
-----
Any environmental variables will be passed to `scripts/travis-run.sh` and will
override any defaults detected in .travis.yml. Currently the only variables
useful to modify are TRAVIS_OS_NAME and BIOCONDA_UTILS_TAG. For example you
can set TRAVIS_OS_NAME to "linux" while running on a Mac to build packages in
a docker container:
TRAVIS_OS_NAME=linux ./simulate-travis.py
Or specify a different commit of `bioconda_utils`:
BIOCONDA_UTILS_TAG=63543b34 ./simulate-travis.py
"""
ap = argparse.ArgumentParser(usage=usage)
args, extra = ap.parse_known_args()
# Read in the current .travis.yml to ensure we're getting the right vars.
# Mostly we care about the bioconda-utils git tag.
travis_config = yaml.load(open('.travis.yml'))
env = {}
for var in travis_config['env']['global']:
if isinstance(var, dict) and list(var.keys()) == ['secure']:
continue
name, value = var.split('=', 1)
env[name] = value
# SUBDAG is set by travis-ci according to the matrix in .travis.yml, so here we
# force it to just use one. The default is to run two parallel jobs, but here
# we set SUBDAGS to 1 so we only run a single job.
#
# See https://docs.travis-ci.com/user/speeding-up-the-build for more.
env['SUBDAGS'] = '1'
env['SUBDAG'] = '0'
# These are set by the travis-ci environment; here we only set the variables
# used by bioconda-utils.
#
# See https://docs.travis-ci.com/user/environment-variables for more.
if platform.system() == 'Darwin':
env['TRAVIS_OS_NAME'] = 'osx'
else:
env['TRAVIS_OS_NAME'] = 'linux'
env['TRAVIS_BRANCH'] = 'false'
env['TRAVIS_PULL_REQUEST'] = 'false'
# Any additional arguments from the command line are added here.
env['BIOCONDA_UTILS_ARGS'] += ' ' + ' '.join(extra)
env['BIOCONDA_UTILS_ARGS'] = ' '.join(shlex.split(env['BIOCONDA_UTILS_ARGS']))
# Override with whatever's in the shell environment
env.update(os.environ)
sp.run(['scripts/travis-run.sh'], env=env, universal_newlines=True, check=True)