1
0
Fork 0
mirror of https://github.com/JasonN3/build-container-installer.git synced 2025-12-25 10:57:55 +01:00

change script

This commit is contained in:
Jason N. 2024-04-01 08:49:01 -04:00
parent 76edeb887c
commit f8f448e94f
5 changed files with 149 additions and 29 deletions

View file

@ -1,9 +1,9 @@
REPO_TESTS=$(filter-out README.md Makefile,$(shell ls))
REPO_TESTS=$(filter-out README.md Makefile,$(wildcard *))
all: $(REPO_TESTS)
$(REPO_TESTS):
chmod +x $*
./$*
chmod +x $@
./$@
.PHONY: $(REPO_TESTS)

108
test/repo/vars.py Executable file
View file

@ -0,0 +1,108 @@
#!/usr/bin/env python
makefile = open('../../Makefile.inputs', 'r')
makefile_lines = makefile.readlines()
vars = {}
outputs = {}
errors = 0
for line in makefile_lines:
if line.startswith('#'):
makefile_lines.remove(line)
continue
parts = line.split('=', 1)
if parts[0].startswith('export'):
var_name = parts[0].strip().split(' ')[1].lower()
else:
var_name = parts[0].strip().lower()
vars[var_name] = {'default_value': parts[1].strip(), 'makefile': True}
action = open('../../action.yml', 'r')
action_lines = action.readlines()
at_inputs = False
at_outputs = False
for line in action_lines:
if not at_inputs:
if line.strip() == 'inputs:':
at_inputs = True
continue
else:
if line.startswith(' '):
parts = line.strip().split(':', 1)
if parts[0] == 'description':
vars[var_name]['description'] = parts[1].strip()
if parts[0] == 'deprecationMessage':
vars[var_name]['deprecated'] = True
if parts[0] == 'default':
if 'default' in vars[var_name]:
if vars[var_name]['default_value'] != parts[1].strip().strip('"'):
print("ERROR: Default value for " + var_name + " in action.yml does not match Makefile")
errors += 1
else:
vars[var_name]['default_value'] = parts[1].strip().strip('"')
elif line.startswith(' '):
var_name = line.strip().strip(':').lower()
if var_name in vars:
vars[var_name][action] = True
else:
print("WARNING: " + var_name + " found in action.yml but not Makefile")
vars[var_name] = {}
vars[var_name]['action'] = True
else:
at_inputs = False
if not at_outputs:
if line.strip() == 'outputs:':
at_outputs = True
continue
else:
if line.startswith(' '):
parts = line.strip().split(':', 1)
if parts[0] == 'description':
outputs[var_name]['description'] = parts[1].strip()
if parts[0] == 'deprecationMessage':
outputs[var_name]['deprecated'] = True
if parts[0] == 'default':
outputs[var_name]['default_value'] = parts[1].strip().strip('"')
elif line.startswith(' '):
var_name = line.strip().strip(':').lower()
outputs[var_name] = {}
else:
at_outputs = False
readme = open('../../README.md', 'r')
readme_lines = readme.readlines()
at_inputs = False
skip_header = True
at_outputs = False
for line in readme_lines:
if not at_inputs:
if line.strip() == '### Inputs':
at_inputs = True
continue
else:
if skip_header:
if line.startswith('| -----'):
skip_header = False
continue
else:
if not line.startswith('|'):
at_inputs = False
continue
parts = line.split('|')
var_name = parts[1].strip().lower()
if not var_name in vars:
print("ERROR: " + var_name + " is not listed in action.yml or Makefile")
vars[var_name] = {}
vars[var_name]
var_description = parts[2].strip()
var_default_value = parts[3].strip()
var_action = parts[4].strip()
var_makefile = parts[5].strip()

22
test/repo/vars.sh → test/repo/vars_copy.sh Normal file → Executable file
View file

@ -1,6 +1,22 @@
#!/bin/bash
exit 0
makefile = open('../../Makefile.inputs', 'r')
makefile_lines = makefile.readlines()
vars = []
for line in makefile_lines:
if line.startswith('#'):
makefile_lines.remove(line)
parts = line.split('=', 1)
vars += { parts[0]: parts[1] }
print(vars)
vars=()
default_values=()
while read -r line
do
@ -8,11 +24,7 @@ do
then
vars+=$(echo $line | cut -d= -f1 | tr [:upper:] [:lower:])
fi
if [[ $line =~ ^########## ]]
then
break
fi
done < ../../Makefile
done < ../../Makefile.inputs
result=0