|
5 | 5 | # Local imports
|
6 | 6 | import config
|
7 | 7 | from export import force_single_language
|
| 8 | +from problem import Problem |
8 | 9 | from util import *
|
9 | 10 | import contest
|
10 | 11 |
|
@@ -323,22 +324,33 @@ def copy_skel_dir(problems):
|
323 | 324 |
|
324 | 325 |
|
325 | 326 | # NOTE: This is one of few places that prints to stdout instead of stderr.
|
326 |
| -def create_gitlab_jobs(contest, problems): |
327 |
| - def problem_source_dir(problem): |
328 |
| - return problem.path.resolve().relative_to(Path("..").resolve()) |
| 327 | +def create_gitlab_jobs(contest: str, problems: list[Problem]): |
| 328 | + git_root_path = Path(os.popen("git rev-parse --show-toplevel").read().strip()).resolve() |
| 329 | + |
| 330 | + def problem_source_dir(problem: Problem): |
| 331 | + return problem.path.resolve().relative_to(git_root_path) |
329 | 332 |
|
330 | 333 | header_yml = (config.TOOLS_ROOT / "skel/gitlab_ci/header.yaml").read_text()
|
331 |
| - print(substitute(header_yml, locals())) |
| 334 | + print(header_yml) |
332 | 335 |
|
333 | 336 | contest_yml = (config.TOOLS_ROOT / "skel/gitlab_ci/contest.yaml").read_text()
|
334 |
| - changes = "" |
335 |
| - for problem in problems: |
336 |
| - changes += " - " + str(problem_source_dir(problem)) + "/problem_statement/**/*\n" |
337 |
| - print(substitute(contest_yml, locals())) |
| 337 | + contest_path = Path(".").resolve().relative_to(git_root_path) |
| 338 | + changes = "".join( |
| 339 | + " - " + str(problem_source_dir(problem)) + "/problem_statement/**/*\n" |
| 340 | + for problem in problems |
| 341 | + ) |
| 342 | + print( |
| 343 | + substitute( |
| 344 | + contest_yml, {"contest": contest, "contest_path": str(contest_path), "changes": changes} |
| 345 | + ) |
| 346 | + ) |
338 | 347 |
|
339 | 348 | problem_yml = (config.TOOLS_ROOT / "skel/gitlab_ci/problem.yaml").read_text()
|
340 | 349 | for problem_obj in problems:
|
341 |
| - changesdir = problem_source_dir(problem_obj) |
| 350 | + problem_path = problem_source_dir(problem_obj) |
342 | 351 | problem = problem_obj.name
|
343 | 352 | print("\n")
|
344 |
| - print(substitute(problem_yml, locals()), end="") |
| 353 | + print( |
| 354 | + substitute(problem_yml, {"problem": problem, "problem_path": str(problem_path)}), |
| 355 | + end="", |
| 356 | + ) |
0 commit comments