-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] introduce run_gha #749
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, great! This can even exist next to #743 (which lacks matrix selection)
|
||
args, extra_env = parse_extra_args(argv[1:]) | ||
|
||
path, args = find_config_file(args, ['.github/workflows/main.yml','.github/workflows/main.yaml']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about passing the yaml file as an argument?
m = [] | ||
g = '' | ||
if isinstance(env, dict): | ||
for l in env['strategy']['matrix']['include']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could even compose the actual matrix
path, args = find_config_file(args, ['.github/workflows/main.yml','.github/workflows/main.yaml']) | ||
config = read_yaml(path) | ||
global_env, job_envs = read_env(config['jobs']['industrial_ci']) | ||
allow_failures = read_allow_failures(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not supported by GHA (?)
def read_allow_failures(config): | ||
try: | ||
af = config['matrix']['allow_failures'] | ||
except: | ||
return list() | ||
return list(x['env'] for x in af) | ||
|
||
def read_num_include(config): | ||
try: | ||
return len(config['matrix']['include']) | ||
except: | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are Travis-specific
def print_help(cmd): | ||
print(""" | ||
Usage: %s [PATH] [RANGE*] [-- [ENV[=VALUE]*]] | ||
|
||
Parses the travis config in the given path or in the current working directory and runs all specified tests sequentially | ||
If no range is given, the list of jobs will get printed. | ||
|
||
The number of tests can be reduced by specifying one or more ranges: | ||
* single job: 1 (only first) | ||
* range: 2-3 (only second and third) | ||
* open start, only as first range: -4 (jobs 1 to 4) | ||
* open end, only as last range: 7- (job 7 and all following jobs) | ||
* open range: - (all jobs) | ||
|
||
Complex examples for a matrix wih 12 jobs: | ||
|
||
* -4 7 8: runs jobs 1 2 3 4 7 8 | ||
* 1 7-9: runs jobs 1 7 8 9 | ||
* 1 7-9 11-: runs jobs 1 7 8 9 11 12 | ||
* -: runs all jobs | ||
|
||
The jobs will be run in clean environments. | ||
Only DOCKER_PORT, SSH_AUTH_SOCK, and TERM will be kept. | ||
Additional variable names can be passed at the end. | ||
|
||
""" % cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is run_travis-specific
if len(args) == 0: | ||
if(len(global_env) > 0): | ||
print('Globals: %s' % str(highlight_diff(global_env))) | ||
jobs = len(job_envs) | ||
digits = len(str(jobs)) | ||
for i in range(jobs): | ||
print('Job %s%s: %s' % ( str(i+1).rjust(digits), | ||
' (allow_failures)' if job_envs[i] in allow_failures else '', | ||
highlight_diff(job_envs[i]) if job_envs[i] is not None else "<unsupported job from 'include' section>")) | ||
print("run all with %s -" % sys.argv[0]) | ||
sys.exit(0) | ||
|
||
ranges = parse_ranges(args, -1) | ||
|
||
run_ci = [os.path.join(scripts_dir, "run_ci"), os.path.dirname(path), filter_env(global_env)] | ||
run_ci_diff = [os.path.join(scripts_dir, "run_ci"), os.path.dirname(path), highlight_diff(global_env, 44)] | ||
|
||
bash = ['env', '-i'] +list(map(gen_env, ['DOCKER_PORT', 'HOME', 'PATH', 'SSH_AUTH_SOCK', 'TERM'])) + ['bash','-e'] | ||
|
||
selection = set(apply_ranges(ranges, len(job_envs))) | ||
|
||
for i in selection: | ||
if job_envs[i] is None: | ||
print("\033[1;43mSkipped job %d, because jobs from 'include' section are not supported\033[1;m" %(i+1,)) | ||
continue | ||
cmd = ' '.join(run_ci + [filter_env(job_envs[i])] + list(map(gen_env, extra_env))) | ||
cmd_diff = ' '.join(run_ci_diff + [highlight_diff(job_envs[i], 44)] + list(map(gen_env, extra_env))) | ||
print('\033[1;44mRunning job %d%s: %s\033[1;m' %(i+1, ' (allow_failures)' if job_envs[i] in allow_failures else '', cmd_diff)) | ||
|
||
proc = subprocess.Popen(bash, stdin=subprocess.PIPE) | ||
proc.communicate(cmd.encode()) | ||
if proc.returncode: | ||
print('\033[1;41mFailed job %d: %s\033[1;m' %(i+1, cmd)) | ||
if job_envs[i] not in allow_failures: | ||
sys.exit(proc.returncode) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken this is common for both.
Or at least it could be broken into smaller chunks to be reused.
In some place "True"/"False" need to be rewritten to true/false, but I am not sure where. Probably in |
this picks up PR #582 and makes use of #717
can probably still be harmonized even further...feedback welcome