Skip to content

Commit d1c700a

Browse files
Copilotgkorland
andcommitted
chore: refine seed cache workflow details
Co-authored-by: gkorland <753206+gkorland@users.noreply.github.com>
1 parent 7fdcf98 commit d1c700a

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Cache seeded repository clones
5454
uses: actions/cache@v4
5555
with:
56-
path: repositories
56+
path: ${{ github.workspace }}/repositories
5757
key: ${{ runner.os }}-seed-repos-${{ hashFiles('e2e/seed_test_data.py') }}-${{ steps.seed-repo-shas.outputs.graphrag_sdk }}-${{ steps.seed-repo-shas.outputs.flask }}
5858
restore-keys: |
5959
${{ runner.os }}-seed-repos-${{ hashFiles('e2e/seed_test_data.py') }}-

e2e/seed_test_data.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232

3333

3434
def repo_name_from_url(url: str) -> str:
35-
return urlparse(url).path.rstrip("/").split("/")[-1].removesuffix(".git")
35+
parsed_path = urlparse(url).path.rstrip("/")
36+
repo_name = parsed_path.split("/")[-1]
37+
return repo_name.removesuffix(".git")
3638

3739

38-
def clone_repository(url: str, path: Path) -> Path:
40+
def fresh_clone_repository(url: str, path: Path) -> Path:
3941
if path.exists():
42+
# Replace any existing directory before creating a fresh shallow clone.
4043
shutil.rmtree(path)
4144

4245
path.parent.mkdir(parents=True, exist_ok=True)
@@ -57,7 +60,7 @@ def load_project(url: str) -> Project:
5760
logger.info("Using cached repository clone at %s", repo_path)
5861
else:
5962
logger.info("Cloning repository into cache at %s", repo_path)
60-
clone_repository(url, repo_path)
63+
fresh_clone_repository(url, repo_path)
6164

6265
return Project.from_local_repository(repo_path)
6366

tests/test_seed_test_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import e2e.seed_test_data as seed_test_data
44

55

6-
def test_load_project_uses_cached_clone(monkeypatch, tmp_path):
6+
def test_load_project_uses_existing_cached_clone(monkeypatch, tmp_path):
77
repo_path = tmp_path / "GraphRAG-SDK"
88
(repo_path / ".git").mkdir(parents=True)
99

@@ -42,7 +42,7 @@ def fake_clone(url: str, path: Path) -> Path:
4242

4343
monkeypatch.setattr(seed_test_data, "REPOSITORIES_DIR", tmp_path)
4444
monkeypatch.setattr(seed_test_data, "Project", FakeProject)
45-
monkeypatch.setattr(seed_test_data, "clone_repository", fake_clone)
45+
monkeypatch.setattr(seed_test_data, "fresh_clone_repository", fake_clone)
4646

4747
project = seed_test_data.load_project("https://github.com/pallets/flask")
4848

0 commit comments

Comments
 (0)