Skip to content
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

Add more assignment tests in docker #261

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 45 additions & 45 deletions .github/scripts/assignments_test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,51 @@ def get_directories(basedir):

pipeline_failed = False
for category_dir in get_directories(home_dir):
#for assignment_dir in get_directories(category_dir):
assignment_dir = random.choice(get_directories(category_dir));
# Remove the contents of the output directory.
os.system(f'rm -r {output_dir}')

# Remove the contents of the test directory.
os.system(f'rm -r {test_dir}/*')

# Write environment file
with open(f'{test_dir}/.env', 'w') as envfile:
envfile.write('TASK_MODE=FULL_WITH_HINTS')

# Copy the assignment to the test folder.
os.chdir(assignment_dir)
os.system(f'cp ./config/Configuration.java {test_dir}/test.txt')
os.system(f'cp ./solution/*.java {test_dir}/solution.txt')
os.system(f'cp ./src/main/java/delft/*.java {test_dir}/library.txt')
# Copy resources
os.system('find . -type f | ' +
'grep -i -v "^\./src/" | grep -i -v "\./config/Configuration.java" | ' +
'grep -i -v "^\./pom.xml$" | grep -i -v "^\./solution/" | grep -i -v "^\./README.md$" | ' +
'xargs -i cp --parents {} ' + f'{test_dir}/')

# Switch to Docker directory
os.chdir(docker_dir)

# Run `andy` on the current assignment.
output = os.popen('make github-ci.test').read()

re_score = re.search('Final grade: [0-9]+', output)
score = int(re_score.group().split()[2]) if re_score else -1
re_andy_version = re.search('Andy v.+', output)
andy_version = re_andy_version.group() if re_andy_version else "Unknown Andy version"

# Print the score for the assignment.
print(f'{andy_version} | {assignment_dir.split("/")[-2]}/{assignment_dir.split("/")[-1]}: {score}/100')

# Update the `pipeline_failed` variable.
if score != 100:
print(output)
pipeline_failed = True

if expected_andy_version not in andy_version:
print(f'Error: Unexpected Andy version {andy_version}, expected {expected_andy_version}')
pipeline_failed = True
for assignment_dir in random.choices(get_directories(category_dir), k=4):
# Remove the contents of the output directory.
os.system(f'rm -r {output_dir}')

# Remove the contents of the test directory.
os.system(f'rm -r {test_dir}/*')

# Write environment file
with open(f'{test_dir}/.env', 'w') as envfile:
envfile.write('TASK_MODE=FULL_WITH_HINTS')

# Copy the assignment to the test folder.
os.chdir(assignment_dir)
os.system(f'cp ./config/Configuration.java {test_dir}/test.txt')
os.system(f'cp ./solution/*.java {test_dir}/solution.txt')
os.system(f'cp ./src/main/java/delft/*.java {test_dir}/library.txt')
# Copy resources
os.system('find . -type f | ' +
'grep -i -v "^\./src/" | grep -i -v "\./config/Configuration.java" | ' +
'grep -i -v "^\./pom.xml$" | grep -i -v "^\./solution/" | grep -i -v "^\./README.md$" | ' +
'xargs -i cp --parents {} ' + f'{test_dir}/')

# Switch to Docker directory
os.chdir(docker_dir)

# Run `andy` on the current assignment.
output = os.popen('make github-ci.test').read()

re_score = re.search('Final grade: [0-9]+', output)
score = int(re_score.group().split()[2]) if re_score else -1
re_andy_version = re.search('Andy v.+', output)
andy_version = re_andy_version.group() if re_andy_version else "Unknown Andy version"

# Print the score for the assignment.
print(f'{andy_version} | {assignment_dir.split("/")[-2]}/{assignment_dir.split("/")[-1]}: {score}/100')

# Update the `pipeline_failed` variable.
if score != 100:
print(output)
pipeline_failed = True

if expected_andy_version not in andy_version:
print(f'Error: Unexpected Andy version {andy_version}, expected {expected_andy_version}')
pipeline_failed = True

if pipeline_failed:
sys.exit('Some assignments do not have 100/100.')
Loading