Page MenuHomePhabricator

.travis.yml matrix expansion

Authored By
hashar
Mar 11 2019, 12:28 PM
Size
1 KB
Referenced Files
None
Subscribers
None

.travis.yml matrix expansion

#!/usr/bin/env python3
from pprint import pprint
import yaml
travis = None
with open('.travis.yml') as f:
travis = yaml.safe_load(f)
def parse_vars(assignments):
env = {}
# naive parsing
for assignment in assignments.split():
(variable, value) = assignment.split('=')
env[variable]=value
return env
global_envs = []
# Globals
_globals = {}
for _global in travis['env']['global']:
_globals.update(parse_vars(_global))
#Global matrix
for global_axis in travis['env']['matrix']:
global_env = {}
global_env.update(_globals) # globals are inherited
global_env.update(parse_vars(global_axis))
global_envs.append(global_env)
# Matrix
matrix = []
for voting in ['include', 'allow_failures']:
for axis in travis['matrix'][voting]:
if voting == 'include':
vals = {'00python': axis['python']}
else:
vals = {'00python': axis['python'] + '(failling)'}
vals.update(parse_vars(axis['env']))
matrix.append(vals)
all_envs=[]
for global_env in global_envs:
for mat in matrix:
env = {}
env.update(global_env)
env.update(mat)
all_envs.append(env)
headers = set()
for env in all_envs:
headers.update(set(env.keys()))
headers = sorted(headers)
print('| ', ' | '.join(headers))
print('|--' * len(headers))
for env in all_envs:
for header in headers:
print('| %s ' % env.get(header), end='')
print()

File Metadata

Mime Type
text/x-python
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7172140
Default Alt Text
.travis.yml matrix expansion (1 KB)