diff --git a/.github/workflows/scripts/filter_git_diff.py b/.github/workflows/scripts/filter_git_diff.py new file mode 100644 index 0000000..f85eeab --- /dev/null +++ b/.github/workflows/scripts/filter_git_diff.py @@ -0,0 +1,37 @@ +# At the moment this script will only filter out the easystack files +# Next step could be to filter out other subpaths +# by using the GITHUB action environment variables and argsparse. + +# Can also distiguish between modified, added, ... files +# That information is in the string that is generated by git diff +# For filtering easystacks this was however not necessary +# since we want to check both added and modified files + +import os + +diff = os.getenv('CHANGED') +env_file = os.getenv('GITHUB_ENV') + +diff_list = diff.split('\n') + +diff_filter_path = 'easystacks' + +diff_filtered = '' + +for line in diff_list: + status = line.split('\t')[0] + file = line.split('\t')[1] + if file.startswith(diff_filter_path): + # Ignoring the status assigned to the file + diff_filtered += file + ' ' + +if diff_filtered != '': + # Todo: Can only handle 1 level paths now + # I we want to pass multi-level paths this will need to be updated + # Name of the env_var can change based on the file or path + env_var = 'CHANGED_' + diff_filter_path.upper() + set_var = env_var + "=" + diff_filtered + + # This adds the environment variable to the github action environment + with open(env_file, 'a') as file: + file.write(set_var) diff --git a/.github/workflows/scripts/parse_missing-installations-output.py b/.github/workflows/scripts/parse_missing-installations-output.py new file mode 100644 index 0000000..a5d42ca --- /dev/null +++ b/.github/workflows/scripts/parse_missing-installations-output.py @@ -0,0 +1,23 @@ +import os +import re + +missing = os.environ['missing'] +missing = missing.split('\n') +missing_cuda = [] +missing_cpu = [] +for ec in missing: + if re.search('CUDA', ec): + missing_cuda.append(ec) + else: + missing_cpu.append(ec) +if len(missing_cpu) != 0 and len(missing_cuda) != 0: + print(f'Please open a seperate pr for these dependencies: {missing_cpu}') + os.write(2, b'Error: CPU dependencies for CUDA build must be build in a seperate pr') + exit(1) +elif len(missing_cuda) != 0: + # TODO: Make this set the accelorator label? + print(f'Have fun installing the following gpu builds: {missing_cuda}') +elif len(missing_cpu) != 0: + print(f'Have fun installing the following gpu builds: {missing_cpu}') +else: + print('no missing modules')