Collects only the solution file path which got added in the current pull request. This will only be triggered if the script is ran from GitHub Actions.
()
| 56 | |
| 57 | |
| 58 | def added_solution_file_path() -> list[pathlib.Path]: |
| 59 | """Collects only the solution file path which got added in the current |
| 60 | pull request. |
| 61 | |
| 62 | This will only be triggered if the script is ran from GitHub Actions. |
| 63 | """ |
| 64 | solution_file_paths = [] |
| 65 | headers = { |
| 66 | "Accept": "application/vnd.github.v3+json", |
| 67 | "Authorization": "token " + os.environ["GITHUB_TOKEN"], |
| 68 | } |
| 69 | files = httpx.get(get_files_url(), headers=headers, timeout=10).json() |
| 70 | for file in files: |
| 71 | filepath = pathlib.Path.cwd().joinpath(file["filename"]) |
| 72 | if ( |
| 73 | filepath.suffix != ".py" |
| 74 | or filepath.name.startswith(("_", "test")) |
| 75 | or not filepath.name.startswith("sol") |
| 76 | ): |
| 77 | continue |
| 78 | solution_file_paths.append(filepath) |
| 79 | return solution_file_paths |
| 80 | |
| 81 | |
| 82 | def collect_solution_file_paths() -> list[pathlib.Path]: |
no test coverage detected