Separate source repos from workspace clones
This commit is contained in:
@@ -2,14 +2,41 @@
|
|||||||
|
|
||||||
Launcher do workspace `rv`.
|
Launcher do workspace `rv`.
|
||||||
|
|
||||||
- `workspace.json` trzyma sciezki workspace i tools
|
- `workspace.json` trzyma sciezki repo oryginalnych, workspace i tools
|
||||||
- `workspace.py` listuje serie i karty
|
- `workspace.py` listuje serie i karty
|
||||||
- szczegolowy opis przelacznikow skryptu jest w `doc/workspace.md`
|
- szczegolowy opis przelacznikow skryptu jest w `doc/workspace.md`
|
||||||
- model tokenow i synchronizacji repo <-> store jest w `doc/tokens.md`
|
- model tokenow i synchronizacji repo <-> store jest w `doc/tokens.md`
|
||||||
|
|
||||||
|
## Model katalogow
|
||||||
|
|
||||||
|
Repo oryginalne trzymamy poza workspace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/dev/rv/repos
|
||||||
|
```
|
||||||
|
|
||||||
|
Workspace sluzy do klonow roboczych i cwiczen:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/dev/workspace/rv
|
||||||
|
```
|
||||||
|
|
||||||
|
Typowy uklad:
|
||||||
|
|
||||||
|
```text
|
||||||
|
~/dev/rv/repos/rv-launcher
|
||||||
|
~/dev/rv/repos/rv32i-hazard3-env
|
||||||
|
~/dev/workspace/rv/tools/rv-launcher
|
||||||
|
~/dev/workspace/rv/tools/rv32i-hazard3-env
|
||||||
|
~/dev/workspace/rv/series/<seria>/<karta>
|
||||||
|
```
|
||||||
|
|
||||||
|
Launcher szuka `rv32i-hazard3-env` najpierw w workspace, a jesli nie znajdzie
|
||||||
|
klona roboczego, moze uzyc repo oryginalnego z `~/dev/rv/repos`.
|
||||||
|
|
||||||
## Przygotowanie katalogu
|
## Przygotowanie katalogu
|
||||||
|
|
||||||
Docelowy katalog:
|
Repo treningowe launchera trzymaj pod:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
~/dev/workspace/rv/tools/rv-launcher
|
~/dev/workspace/rv/tools/rv-launcher
|
||||||
@@ -188,7 +215,8 @@ student_branch u1
|
|||||||
|
|
||||||
## Wariant alternatywny: `git clone`
|
## Wariant alternatywny: `git clone`
|
||||||
|
|
||||||
Jesli celem nie jest cwiczenie `remote add` i `fetch`, mozna tez uzyc:
|
Jesli celem nie jest cwiczenie `remote add` i `fetch`, repo treningowe mozna
|
||||||
|
tez sklonowac klasycznie:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p ~/dev/workspace/rv/tools
|
mkdir -p ~/dev/workspace/rv/tools
|
||||||
|
|||||||
+32
-8
@@ -2,15 +2,44 @@
|
|||||||
|
|
||||||
Plik opisuje przelaczniki i liste komend skryptu `workspace.py`.
|
Plik opisuje przelaczniki i liste komend skryptu `workspace.py`.
|
||||||
|
|
||||||
|
## Model katalogow
|
||||||
|
|
||||||
|
Repo oryginalne trzymamy poza workspace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/dev/rv/repos
|
||||||
|
```
|
||||||
|
|
||||||
|
Workspace sluzy do klonow roboczych i cwiczen:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
~/dev/workspace/rv
|
||||||
|
```
|
||||||
|
|
||||||
|
Typowy uklad:
|
||||||
|
|
||||||
|
```text
|
||||||
|
~/dev/rv/repos/rv-launcher
|
||||||
|
~/dev/rv/repos/rv32i-hazard3-env
|
||||||
|
~/dev/workspace/rv/tools/rv-launcher
|
||||||
|
~/dev/workspace/rv/tools/rv32i-hazard3-env
|
||||||
|
~/dev/workspace/rv/series/<seria>/<karta>
|
||||||
|
```
|
||||||
|
|
||||||
|
`workspace.py` czyta karty z `series_root` w workspace. Tool repo
|
||||||
|
`rv32i-hazard3-env` wybiera najpierw z workspace, a potem z fallbacku
|
||||||
|
`~/dev/rv/repos` lub `~/dev/rv/tools`, jesli taki klon roboczy jeszcze nie
|
||||||
|
istnieje.
|
||||||
|
|
||||||
## Pobranie repo i przelaczenie galezi
|
## Pobranie repo i przelaczenie galezi
|
||||||
|
|
||||||
Jesli trzymasz tool repo pod:
|
Repo treningowe launchera trzymaj pod:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
~/dev/workspace/rv/tools/rv-launcher
|
~/dev/workspace/rv/tools/rv-launcher
|
||||||
```
|
```
|
||||||
|
|
||||||
to podstawowy bootstrap wyglada tak:
|
Podstawowy bootstrap wyglada tak:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir -p ~/dev/workspace/rv/tools
|
mkdir -p ~/dev/workspace/rv/tools
|
||||||
@@ -19,12 +48,6 @@ git clone http://77.90.8.171:3001/edu-tools/rv-launcher.git
|
|||||||
cd rv-launcher
|
cd rv-launcher
|
||||||
```
|
```
|
||||||
|
|
||||||
Jesli w Twoim workspace narzedzia sa poza `rv/`, analogiczny katalog to:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
~/dev/workspace/tools/rv-launcher
|
|
||||||
```
|
|
||||||
|
|
||||||
### Autoryzacja
|
### Autoryzacja
|
||||||
|
|
||||||
Masz dwie drogi.
|
Masz dwie drogi.
|
||||||
@@ -155,6 +178,7 @@ Typowy format:
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
config_path<TAB>...
|
config_path<TAB>...
|
||||||
|
original_root<TAB>...
|
||||||
workspace_root<TAB>...
|
workspace_root<TAB>...
|
||||||
series_root<TAB>...
|
series_root<TAB>...
|
||||||
socket_root<TAB>...
|
socket_root<TAB>...
|
||||||
|
|||||||
+4
-2
@@ -1,12 +1,14 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
|
"original_root": "~/dev/rv/repos",
|
||||||
"workspace_root": "~/dev/workspace/rv",
|
"workspace_root": "~/dev/workspace/rv",
|
||||||
"series_root": "~/dev/workspace/rv/series",
|
"series_root": "~/dev/workspace/rv/series",
|
||||||
"socket_root": "~/dev/workspace/rv/sockets",
|
"socket_root": "~/dev/workspace/rv/sockets",
|
||||||
"token_file": "~/dev/workspace/rv/tokens/tokens.json",
|
"token_file": "~/dev/workspace/rv/tokens/tokens.json",
|
||||||
"tools_root_candidates": [
|
"tools_root_candidates": [
|
||||||
"~/dev/workspace/tools/rv32i-hazard3-env",
|
"~/dev/workspace/rv/tools/rv32i-hazard3-env",
|
||||||
"~/dev/workspace/rv/tools/rv32i-hazard3-env"
|
"~/dev/rv/repos/rv32i-hazard3-env",
|
||||||
|
"~/dev/rv/tools/rv32i-hazard3-env"
|
||||||
],
|
],
|
||||||
"git": {
|
"git": {
|
||||||
"base_url": "http://77.90.8.171:3001",
|
"base_url": "http://77.90.8.171:3001",
|
||||||
|
|||||||
+9
-1
@@ -36,6 +36,7 @@ class GitConfig:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class WorkspaceConfig:
|
class WorkspaceConfig:
|
||||||
config_path: Path
|
config_path: Path
|
||||||
|
original_root: Path
|
||||||
workspace_root: Path
|
workspace_root: Path
|
||||||
series_root: Path
|
series_root: Path
|
||||||
socket_root: Path
|
socket_root: Path
|
||||||
@@ -50,6 +51,7 @@ def load_config(config_path: Path) -> WorkspaceConfig:
|
|||||||
raw = json.loads(config_path.read_text(encoding="utf-8"))
|
raw = json.loads(config_path.read_text(encoding="utf-8"))
|
||||||
base_dir = config_path.parent
|
base_dir = config_path.parent
|
||||||
|
|
||||||
|
original_root = expand_path(raw.get("original_root", "~/dev/rv/repos"), base_dir)
|
||||||
workspace_root = expand_path(raw.get("workspace_root", "~/dev/workspace/rv"), base_dir)
|
workspace_root = expand_path(raw.get("workspace_root", "~/dev/workspace/rv"), base_dir)
|
||||||
series_root = expand_path(raw.get("series_root", str(workspace_root / "series")), base_dir)
|
series_root = expand_path(raw.get("series_root", str(workspace_root / "series")), base_dir)
|
||||||
socket_root = expand_path(raw.get("socket_root", str(workspace_root / "sockets")), base_dir)
|
socket_root = expand_path(raw.get("socket_root", str(workspace_root / "sockets")), base_dir)
|
||||||
@@ -57,7 +59,11 @@ def load_config(config_path: Path) -> WorkspaceConfig:
|
|||||||
|
|
||||||
candidate_values = raw.get("tools_root_candidates")
|
candidate_values = raw.get("tools_root_candidates")
|
||||||
if not candidate_values:
|
if not candidate_values:
|
||||||
candidate_values = [raw.get("tools_root", "~/dev/workspace/tools/rv32i-hazard3-env")]
|
candidate_values = [
|
||||||
|
raw.get("tools_root", str(workspace_root / "tools" / "rv32i-hazard3-env")),
|
||||||
|
str(original_root / "rv32i-hazard3-env"),
|
||||||
|
"~/dev/rv/tools/rv32i-hazard3-env",
|
||||||
|
]
|
||||||
tools_root_candidates = [expand_path(value, base_dir) for value in candidate_values]
|
tools_root_candidates = [expand_path(value, base_dir) for value in candidate_values]
|
||||||
|
|
||||||
tools_root = next((path for path in tools_root_candidates if path.exists()), tools_root_candidates[0])
|
tools_root = next((path for path in tools_root_candidates if path.exists()), tools_root_candidates[0])
|
||||||
@@ -75,6 +81,7 @@ def load_config(config_path: Path) -> WorkspaceConfig:
|
|||||||
|
|
||||||
return WorkspaceConfig(
|
return WorkspaceConfig(
|
||||||
config_path=config_path,
|
config_path=config_path,
|
||||||
|
original_root=original_root,
|
||||||
workspace_root=workspace_root,
|
workspace_root=workspace_root,
|
||||||
series_root=series_root,
|
series_root=series_root,
|
||||||
socket_root=socket_root,
|
socket_root=socket_root,
|
||||||
@@ -998,6 +1005,7 @@ def run_tmux_container(config: WorkspaceConfig, args: argparse.Namespace) -> Non
|
|||||||
|
|
||||||
def print_config(config: WorkspaceConfig) -> None:
|
def print_config(config: WorkspaceConfig) -> None:
|
||||||
print(f"config_path\t{config.config_path}")
|
print(f"config_path\t{config.config_path}")
|
||||||
|
print(f"original_root\t{config.original_root}")
|
||||||
print(f"workspace_root\t{config.workspace_root}")
|
print(f"workspace_root\t{config.workspace_root}")
|
||||||
print(f"series_root\t{config.series_root}")
|
print(f"series_root\t{config.series_root}")
|
||||||
print(f"socket_root\t{config.socket_root}")
|
print(f"socket_root\t{config.socket_root}")
|
||||||
|
|||||||
Reference in New Issue
Block a user