From ca4f80e9b9bf4a54e4b84daa9963a611718112db Mon Sep 17 00:00:00 2001 From: Cojocaru Alexandru-Gabriel Date: Mon, 7 Aug 2023 11:26:40 +0300 Subject: [PATCH 1/2] 4 tests --- .github/scripts/assignments_test_docker.py | 89 +++++++++++----------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/.github/scripts/assignments_test_docker.py b/.github/scripts/assignments_test_docker.py index 336080d31..74e882582 100644 --- a/.github/scripts/assignments_test_docker.py +++ b/.github/scripts/assignments_test_docker.py @@ -21,51 +21,50 @@ 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.') From 3dbf430d4658ed4d589ea849a2684fe8c24b48e9 Mon Sep 17 00:00:00 2001 From: Cojocaru Alexandru-Gabriel Date: Mon, 7 Aug 2023 12:38:26 +0300 Subject: [PATCH 2/2] Rerun pipeline --- .github/scripts/assignments_test_docker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/assignments_test_docker.py b/.github/scripts/assignments_test_docker.py index 74e882582..5808dbf60 100644 --- a/.github/scripts/assignments_test_docker.py +++ b/.github/scripts/assignments_test_docker.py @@ -22,6 +22,7 @@ def get_directories(basedir): pipeline_failed = False for category_dir in get_directories(home_dir): 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}')