|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 |
| -from glob import glob |
4 | 3 | import os
|
5 | 4 | import typing as t
|
| 5 | +from glob import glob |
6 | 6 |
|
7 | 7 | import pkg_resources
|
8 |
| - |
9 | 8 | from tutor import fmt
|
10 | 9 | from tutor import hooks as tutor_hooks
|
11 | 10 | from tutor.hooks import priorities
|
12 | 11 | from tutor.types import Config, get_typed
|
| 12 | + |
13 | 13 | from .__about__ import __version__, __version_suffix__
|
14 |
| -from .hooks import MFE_ATTRS_TYPE, MFE_APPS |
| 14 | +from .hooks import MFE_APPS, MFE_ATTRS_TYPE |
15 | 15 |
|
16 | 16 | config = {
|
17 | 17 | "defaults": {
|
|
24 | 24 | }
|
25 | 25 |
|
26 | 26 |
|
27 |
| -# If the package version suffix is set (for instance, in the nightly branch) use the "heads" Github refs API endpoint by default. |
28 |
| -def gh_refs_path() -> str: |
29 |
| - return "heads" if __version_suffix__ else "tags" |
| 27 | +def get_github_refs_path(name: str) -> str: |
| 28 | + """ |
| 29 | + Generate a URL to access refs in heads (nightly) or tags (stable) via Github API. |
| 30 | + Args: |
| 31 | + name (str): Consisted of the repository owner and the repository name, as a string in 'owner/repo' format. |
| 32 | +
|
| 33 | + Returns: |
| 34 | + str: A string URL to the Github API, pointing to heads if version_suffix is set, tags otherwise. |
| 35 | +
|
| 36 | + """ |
| 37 | + |
| 38 | + return f"https://api.github.com/repos/{name}/git/refs/{'heads' if __version_suffix__ else 'tags'}" |
30 | 39 |
|
31 | 40 |
|
32 | 41 | CORE_MFE_APPS: dict[str, MFE_ATTRS_TYPE] = {
|
33 | 42 | "authn": {
|
34 | 43 | "repository": "https://github.com/openedx/frontend-app-authn",
|
35 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-authn/git/refs/" + gh_refs_path(), |
| 44 | + "refs": get_github_refs_path("openedx/frontend-app-authn"), |
36 | 45 | "port": 1999,
|
37 | 46 | },
|
38 | 47 | "account": {
|
39 | 48 | "repository": "https://github.com/openedx/frontend-app-account",
|
40 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-account/git/refs/" + gh_refs_path(), |
| 49 | + "refs": get_github_refs_path("openedx/frontend-app-account"), |
41 | 50 | "port": 1997,
|
42 | 51 | },
|
43 | 52 | "communications": {
|
44 | 53 | "repository": "https://github.com/openedx/frontend-app-communications",
|
45 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-communications/git/refs/" + gh_refs_path(), |
| 54 | + "refs": get_github_refs_path("openedx/frontend-app-communications"), |
46 | 55 | "port": 1984,
|
47 | 56 | },
|
48 | 57 | "course-authoring": {
|
49 | 58 | "repository": "https://github.com/openedx/frontend-app-course-authoring",
|
50 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-course-authoring/git/refs/" + gh_refs_path(), |
| 59 | + "refs": get_github_refs_path("openedx/frontend-app-course-authoring"), |
51 | 60 | "port": 2001,
|
52 | 61 | },
|
53 | 62 | "discussions": {
|
54 | 63 | "repository": "https://github.com/openedx/frontend-app-discussions",
|
55 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-discussions/git/refs/" + gh_refs_path(), |
| 64 | + "refs": get_github_refs_path("openedx/frontend-app-discussions"), |
56 | 65 | "port": 2002,
|
57 | 66 | },
|
58 | 67 | "gradebook": {
|
59 | 68 | "repository": "https://github.com/openedx/frontend-app-gradebook",
|
60 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-gradebook/git/refs/" + gh_refs_path(), |
| 69 | + "refs": get_github_refs_path("openedx/frontend-app-gradebook"), |
61 | 70 | "port": 1994,
|
62 | 71 | },
|
63 | 72 | "learning": {
|
64 | 73 | "repository": "https://github.com/openedx/frontend-app-learning",
|
65 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-learning/git/refs/" + gh_refs_path(), |
| 74 | + "refs": get_github_refs_path("openedx/frontend-app-learning"), |
66 | 75 | "port": 2000,
|
67 | 76 | },
|
68 | 77 | "ora-grading": {
|
69 | 78 | "repository": "https://github.com/openedx/frontend-app-ora-grading",
|
70 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-ora-grading/git/refs/" + gh_refs_path(), |
| 79 | + "refs": get_github_refs_path("openedx/frontend-app-ora-grading"), |
71 | 80 | "port": 1993,
|
72 | 81 | },
|
73 | 82 | "profile": {
|
74 | 83 | "repository": "https://github.com/openedx/frontend-app-profile",
|
75 |
| - "refs": "https://api.github.com/repos/openedx/frontend-app-profile/git/refs/" + gh_refs_path(), |
| 84 | + "refs": get_github_refs_path("openedx/frontend-app-profile"), |
76 | 85 | "port": 1995,
|
77 | 86 | },
|
78 | 87 | }
|
@@ -161,7 +170,9 @@ def is_mfe_enabled(mfe_name: str) -> bool:
|
161 | 170 |
|
162 | 171 |
|
163 | 172 | @tutor_hooks.Filters.COMPOSE_MOUNTS.add()
|
164 |
| -def _mount_frontend_apps(volumes, path_basename): |
| 173 | +def _mount_frontend_apps( |
| 174 | + volumes: list[tuple[str, str]], path_basename: str |
| 175 | +) -> list[tuple[str, str]]: |
165 | 176 | """
|
166 | 177 | If the user mounts any repo named frontend-app-APPNAME, then make sure
|
167 | 178 | it's available in the APPNAME service container. This is only applicable
|
|
0 commit comments