Skip to content

Commit 593c4f1

Browse files
committed
feat: add support for real external repos
1 parent 3b6e908 commit 593c4f1

8 files changed

Lines changed: 230 additions & 173 deletions

File tree

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,6 @@ services/libs/tinybird/.diff_tmp
199199
# claude code rules
200200
CLAUDE.md
201201

202-
# git integration test repository (dynamically created)
203-
services/apps/git_integration/src/test/fixtures/test-repo/
202+
# git integration test repositories & output
203+
services/apps/git_integration/src/test/repos/
204+
services/apps/git_integration/src/test/outputs/custom/

services/apps/git_integration/Makefile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,15 @@ lock_deps: check_setup ## Generate/update uv.lock file
111111

112112
##@ 🧪 Testing
113113

114-
test: check_setup ## Run tests (test=file repo=path expected=path)
114+
test: check_setup ## Run tests (test=file repo=name expected=file)
115115
@echo "🧪 Running tests..."
116116
@TEST_FILE="$(if $(test),src/test/$(test),src/test/)"; \
117-
PYTEST_ARGS="-v --ignore=src/test/legacy"; \
118117
if [ -n "$(repo)" ]; then \
119-
export TEST_GIT_REPO="$(repo)"; \
120-
echo "📁 Using external repository: $(repo)"; \
121-
PYTEST_ARGS="$$PYTEST_ARGS --repo=$(repo)"; \
118+
export TEST_REPO_NAME="$(repo)"; \
119+
echo "📁 Using repository: $(repo)"; \
122120
fi; \
123121
if [ -n "$(expected)" ]; then \
124-
export TEST_EXPECTED_OUTPUT="$(expected)"; \
122+
export TEST_EXPECTED_FILE="$(expected)"; \
125123
echo "📄 Using expected output: $(expected)"; \
126-
PYTEST_ARGS="$$PYTEST_ARGS --expected=$(expected)"; \
127124
fi; \
128-
uv run pytest $$TEST_FILE $$PYTEST_ARGS
125+
uv run pytest $$TEST_FILE -v

services/apps/git_integration/src/test/README.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ test/
2121
## Running Tests
2222

2323
```bash
24-
make test # Run all tests
25-
make test test=test_activity_extraction.py # Specific test
26-
make test repo=/path/to/repo # Test external repo
27-
make test expected=/path/to/expected.json # Custom baseline
24+
make test # Run all tests
25+
make test test=test_activity_extraction.py # Specific test
26+
make test repo=insights # Test different repo (from repos/)
27+
make test expected=insights_expected.json # Custom baseline (from fixtures/)
28+
make test repo=insights expected=insights_expected.json # Combined
2829
```
2930

31+
**Note:** `repo` and `expected` arguments are relative to `repos/` and `fixtures/` directories respectively.
32+
3033
## How It Works
3134

3235
1. **Test repository** created from `test_repo_seed.json` with various commit scenarios
@@ -44,19 +47,44 @@ make test expected=/path/to/expected.json # Custom baseline
4447
## Updating Baseline
4548

4649
1. Run tests: `make test`
47-
2. Review `fixtures/actual_output.json`
48-
3. If correct: `cp fixtures/actual_output.json fixtures/expected_activities.json`
49-
4. Re-run to validate
50+
2. Review `outputs/test-repo_actual.json`
51+
3. If correct: `cp outputs/test-repo_actual.json outputs/test-repo_expected.json`
52+
4. Commit the expected file to git
53+
5. Re-run to validate
5054

5155
## Adding Test Cases
5256

5357
Edit `fixtures/test_repo_seed.json`, rebuild repo, update baseline:
5458

5559
```bash
56-
cd src/test/fixtures
57-
rm -rf test-repo
58-
python3 build_test_repo.py
60+
cd src/test
61+
rm -rf repos/test-repo
62+
python3 fixtures/build_test_repo.py
5963
cd ../..
6064
make test
61-
cp fixtures/actual_output.json fixtures/expected_activities.json
65+
cp src/test/outputs/test-repo_actual.json src/test/outputs/test-repo_expected.json
66+
git add src/test/outputs/test-repo_expected.json
67+
```
68+
69+
## Testing External Repositories
70+
71+
To test with a real repository:
72+
73+
```bash
74+
# Clone repo into repos/ directory
75+
cd src/test/repos
76+
git clone https://github.com/yourorg/yourrepo.git insights
77+
78+
# Run test to generate output (first run will skip validation)
79+
cd ../../..
80+
make test repo=insights
81+
# Output saved to: outputs/custom/insights_actual.json
82+
83+
# Review output and create baseline
84+
cp src/test/outputs/custom/insights_actual.json src/test/outputs/custom/insights_expected.json
85+
86+
# Future runs automatically validate against the baseline
87+
make test repo=insights
6288
```
89+
90+
**Note:** Custom repo baselines are in `outputs/custom/` which is gitignored. They're for local validation only.

services/apps/git_integration/src/test/fixtures/build_test_repo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def main():
118118

119119
# Default paths
120120
seed_file = script_dir / "test_repo_seed.json"
121-
repo_path = script_dir / "test-repo"
121+
repos_dir = script_dir.parent / "repos"
122+
repos_dir.mkdir(exist_ok=True)
123+
repo_path = repos_dir / "test-repo"
122124

123125
# Allow overriding from command line
124126
if len(sys.argv) > 1:
Lines changed: 0 additions & 1 deletion
This file was deleted.

services/apps/git_integration/src/test/fixtures/actual_output.json renamed to services/apps/git_integration/src/test/outputs/test-repo_actual.json

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[
22
{
33
"type": "authored-commit",
4-
"timestamp": "2025-10-11T15:10:54+01:00",
5-
"sourceId": "926867559ef212a6514e4224d3a3bdc4bd16a60f",
4+
"timestamp": "2025-10-12T16:15:49+01:00",
5+
"sourceId": "d38f1a8036c1b3177d94682f226a9fe6cb387240",
66
"sourceParentId": "",
77
"platform": "git",
88
"channel": "https://github.com/test/repo.git",
@@ -38,9 +38,9 @@
3838
},
3939
{
4040
"type": "committed-commit",
41-
"timestamp": "2025-10-11T15:10:54+01:00",
42-
"sourceId": "349c7a5ee345d2fe94cc1567fe6aca572b2476c9",
43-
"sourceParentId": "926867559ef212a6514e4224d3a3bdc4bd16a60f",
41+
"timestamp": "2025-10-12T16:15:49+01:00",
42+
"sourceId": "4619a3b615c79fe4be0de4a82150318898d8ea49",
43+
"sourceParentId": "d38f1a8036c1b3177d94682f226a9fe6cb387240",
4444
"platform": "git",
4545
"channel": "https://github.com/test/repo.git",
4646
"body": "Merge pull request from external contributor\n\nThis commit was authored by a contributor but committed by a maintainer.\n\nSigned-off-by: Linda Contributor <linda@external.com>",
@@ -75,9 +75,9 @@
7575
},
7676
{
7777
"type": "signed-off-commit",
78-
"timestamp": "2025-10-11T15:10:54+01:00",
79-
"sourceId": "bcc5123471f938972da018e2d329b149a22c063f",
80-
"sourceParentId": "926867559ef212a6514e4224d3a3bdc4bd16a60f",
78+
"timestamp": "2025-10-12T16:15:49+01:00",
79+
"sourceId": "a321f844e34e4c4b2bd6b2997681fcf2dd5f47f5",
80+
"sourceParentId": "d38f1a8036c1b3177d94682f226a9fe6cb387240",
8181
"platform": "git",
8282
"channel": "https://github.com/test/repo.git",
8383
"body": "Merge pull request from external contributor\n\nThis commit was authored by a contributor but committed by a maintainer.\n\nSigned-off-by: Linda Contributor <linda@external.com>",
@@ -112,8 +112,8 @@
112112
},
113113
{
114114
"type": "authored-commit",
115-
"timestamp": "2025-10-11T15:10:54+01:00",
116-
"sourceId": "fd0f51ccba332b675dd8c9068a47dc1086cdabfa",
115+
"timestamp": "2025-10-12T16:15:49+01:00",
116+
"sourceId": "12b4d83852e06c5b3fa0e339c395bad0ee65200f",
117117
"sourceParentId": "",
118118
"platform": "git",
119119
"channel": "https://github.com/test/repo.git",
@@ -149,8 +149,8 @@
149149
},
150150
{
151151
"type": "authored-commit",
152-
"timestamp": "2025-10-11T15:10:54+01:00",
153-
"sourceId": "921152f8e4363752b02dbbb4cac7399712cf7e0a",
152+
"timestamp": "2025-10-12T16:15:49+01:00",
153+
"sourceId": "afd82faba62589717df9e3c32172b310b68f808b",
154154
"sourceParentId": "",
155155
"platform": "git",
156156
"channel": "https://github.com/test/repo.git",
@@ -186,9 +186,9 @@
186186
},
187187
{
188188
"type": "signed-off-commit",
189-
"timestamp": "2025-10-11T15:10:54+01:00",
190-
"sourceId": "e11357f09a4959c3fd5a45de80e897b2df738275",
191-
"sourceParentId": "921152f8e4363752b02dbbb4cac7399712cf7e0a",
189+
"timestamp": "2025-10-12T16:15:49+01:00",
190+
"sourceId": "2bcde409c58ed7a5620b3f1a8c18c0572067eb62",
191+
"sourceParentId": "afd82faba62589717df9e3c32172b310b68f808b",
192192
"platform": "git",
193193
"channel": "https://github.com/test/repo.git",
194194
"body": "Fix typo in config\n\nSigned-off-by: Ivan <ivan@example.com>>\nReviewed-by: Jane <<jane@example.com>",
@@ -223,9 +223,9 @@
223223
},
224224
{
225225
"type": "reviewed-commit",
226-
"timestamp": "2025-10-11T15:10:54+01:00",
227-
"sourceId": "5bd45e0207d4f516ab62489efbe094fc1d3d0ab9",
228-
"sourceParentId": "921152f8e4363752b02dbbb4cac7399712cf7e0a",
226+
"timestamp": "2025-10-12T16:15:49+01:00",
227+
"sourceId": "97ea4072257c1e377a60803c810c7e3af5d051af",
228+
"sourceParentId": "afd82faba62589717df9e3c32172b310b68f808b",
229229
"platform": "git",
230230
"channel": "https://github.com/test/repo.git",
231231
"body": "Fix typo in config\n\nSigned-off-by: Ivan <ivan@example.com>>\nReviewed-by: Jane <<jane@example.com>",
@@ -260,8 +260,8 @@
260260
},
261261
{
262262
"type": "authored-commit",
263-
"timestamp": "2025-10-11T15:10:54+01:00",
264-
"sourceId": "70c7554ca3e16e23e8a9c9ed2d5209f3f8765b85",
263+
"timestamp": "2025-10-12T16:15:49+01:00",
264+
"sourceId": "28c2ba317c4e202c25cd684a0c181f54c37d78a0",
265265
"sourceParentId": "",
266266
"platform": "git",
267267
"channel": "https://github.com/test/repo.git",
@@ -297,9 +297,9 @@
297297
},
298298
{
299299
"type": "signed-off-commit",
300-
"timestamp": "2025-10-11T15:10:54+01:00",
301-
"sourceId": "e4ac113ea10077bfadd1c5fd6f07c41587a429de",
302-
"sourceParentId": "70c7554ca3e16e23e8a9c9ed2d5209f3f8765b85",
300+
"timestamp": "2025-10-12T16:15:49+01:00",
301+
"sourceId": "9a5760b9f9e05e54acac8c29eb555bc51014a8a1",
302+
"sourceParentId": "28c2ba317c4e202c25cd684a0c181f54c37d78a0",
303303
"platform": "git",
304304
"channel": "https://github.com/test/repo.git",
305305
"body": "Update documentation\n\nUpdated the README with new instructions.\n\nReviewed-By: No Email Here\nSigned-off-by: Henry Docs <henry@example.com>",
@@ -334,8 +334,8 @@
334334
},
335335
{
336336
"type": "authored-commit",
337-
"timestamp": "2025-10-11T15:10:53+01:00",
338-
"sourceId": "e5469933e34fe23cec629a2a5dbe67aa9c57604d",
337+
"timestamp": "2025-10-12T16:15:49+01:00",
338+
"sourceId": "4df11752fae718f054a20d22bec2078c1d1f08fa",
339339
"sourceParentId": "",
340340
"platform": "git",
341341
"channel": "https://github.com/test/repo.git",
@@ -371,9 +371,9 @@
371371
},
372372
{
373373
"type": "reviewed-commit",
374-
"timestamp": "2025-10-11T15:10:53+01:00",
375-
"sourceId": "521a4cee6d20872f571ffe210dca154e404bf0b2",
376-
"sourceParentId": "e5469933e34fe23cec629a2a5dbe67aa9c57604d",
374+
"timestamp": "2025-10-12T16:15:49+01:00",
375+
"sourceId": "11b4c273bc98507e605d6f3af0dfb273e24649f1",
376+
"sourceParentId": "4df11752fae718f054a20d22bec2078c1d1f08fa",
377377
"platform": "git",
378378
"channel": "https://github.com/test/repo.git",
379379
"body": "Refactor authentication module\n\nRemoved old code and added new implementation.\n\nReviewed-by: Alice Developer <alice@example.com>",
@@ -408,8 +408,8 @@
408408
},
409409
{
410410
"type": "authored-commit",
411-
"timestamp": "2025-10-11T15:10:53+01:00",
412-
"sourceId": "e32d015ec39dc86dd24cfad1ab93934bcd3ca8e6",
411+
"timestamp": "2025-10-12T16:15:49+01:00",
412+
"sourceId": "eacba0e12f931b0cc6b551f4680e41c024b02afe",
413413
"sourceParentId": "",
414414
"platform": "git",
415415
"channel": "https://github.com/test/repo.git",
@@ -445,9 +445,9 @@
445445
},
446446
{
447447
"type": "co-authored-commit",
448-
"timestamp": "2025-10-11T15:10:53+01:00",
449-
"sourceId": "917658b6d3fb727b7e2a654ce99cf41d3579146a",
450-
"sourceParentId": "e32d015ec39dc86dd24cfad1ab93934bcd3ca8e6",
448+
"timestamp": "2025-10-12T16:15:49+01:00",
449+
"sourceId": "60a829c7b43c060ee991a6a4601cd9e0ae7058ea",
450+
"sourceParentId": "eacba0e12f931b0cc6b551f4680e41c024b02afe",
451451
"platform": "git",
452452
"channel": "https://github.com/test/repo.git",
453453
"body": "Implement new feature together\n\nThis feature was developed in pair programming session.\n\nCo-authored-by: Eve Pair <eve@example.com>\nSigned-off-by: Frank Lead <frank@example.com>",
@@ -482,9 +482,9 @@
482482
},
483483
{
484484
"type": "signed-off-commit",
485-
"timestamp": "2025-10-11T15:10:53+01:00",
486-
"sourceId": "1e55fb609bae5cdf007ab55e014239ca2f68b6b8",
487-
"sourceParentId": "e32d015ec39dc86dd24cfad1ab93934bcd3ca8e6",
485+
"timestamp": "2025-10-12T16:15:49+01:00",
486+
"sourceId": "ea096a751ec8751d06c82a861a2f769a105bb762",
487+
"sourceParentId": "eacba0e12f931b0cc6b551f4680e41c024b02afe",
488488
"platform": "git",
489489
"channel": "https://github.com/test/repo.git",
490490
"body": "Implement new feature together\n\nThis feature was developed in pair programming session.\n\nCo-authored-by: Eve Pair <eve@example.com>\nSigned-off-by: Frank Lead <frank@example.com>",
@@ -519,8 +519,8 @@
519519
},
520520
{
521521
"type": "authored-commit",
522-
"timestamp": "2025-10-11T15:10:53+01:00",
523-
"sourceId": "acc01577ba8be1160fb23e9d72c7b8150ccc8d68",
522+
"timestamp": "2025-10-12T16:15:49+01:00",
523+
"sourceId": "c73621865a578ddcc419f976382ef701efa33da4",
524524
"sourceParentId": "",
525525
"platform": "git",
526526
"channel": "https://github.com/test/repo.git",
@@ -556,9 +556,9 @@
556556
},
557557
{
558558
"type": "signed-off-commit",
559-
"timestamp": "2025-10-11T15:10:53+01:00",
560-
"sourceId": "818805fe817b288da27436a78f44b37019e58c04",
561-
"sourceParentId": "acc01577ba8be1160fb23e9d72c7b8150ccc8d68",
559+
"timestamp": "2025-10-12T16:15:49+01:00",
560+
"sourceId": "5d4675a0cabb19b066b94873a1f4b8f7caf805e7",
561+
"sourceParentId": "c73621865a578ddcc419f976382ef701efa33da4",
562562
"platform": "git",
563563
"channel": "https://github.com/test/repo.git",
564564
"body": "Fix critical security vulnerability\n\nThis patch addresses a security issue in the authentication module.\n\nSigned-off-by: Charlie Developer <charlie@example.com>\nReviewed-by: Alice Developer <alice@example.com>\nTested-by: David Tester <david@example.com>",
@@ -593,9 +593,9 @@
593593
},
594594
{
595595
"type": "reviewed-commit",
596-
"timestamp": "2025-10-11T15:10:53+01:00",
597-
"sourceId": "e48f0ca76d0686c9e7f3b39f3679c70d4d63d1f2",
598-
"sourceParentId": "acc01577ba8be1160fb23e9d72c7b8150ccc8d68",
596+
"timestamp": "2025-10-12T16:15:49+01:00",
597+
"sourceId": "eb1fb44cc5fb7cdaf526ef9268956b7158936887",
598+
"sourceParentId": "c73621865a578ddcc419f976382ef701efa33da4",
599599
"platform": "git",
600600
"channel": "https://github.com/test/repo.git",
601601
"body": "Fix critical security vulnerability\n\nThis patch addresses a security issue in the authentication module.\n\nSigned-off-by: Charlie Developer <charlie@example.com>\nReviewed-by: Alice Developer <alice@example.com>\nTested-by: David Tester <david@example.com>",
@@ -630,9 +630,9 @@
630630
},
631631
{
632632
"type": "tested-commit",
633-
"timestamp": "2025-10-11T15:10:53+01:00",
634-
"sourceId": "a5b68a98e8f886ec3afba6436a5a3bb033718d4a",
635-
"sourceParentId": "acc01577ba8be1160fb23e9d72c7b8150ccc8d68",
633+
"timestamp": "2025-10-12T16:15:49+01:00",
634+
"sourceId": "9e230ef529e800d109a7374d8fd4182322508e3d",
635+
"sourceParentId": "c73621865a578ddcc419f976382ef701efa33da4",
636636
"platform": "git",
637637
"channel": "https://github.com/test/repo.git",
638638
"body": "Fix critical security vulnerability\n\nThis patch addresses a security issue in the authentication module.\n\nSigned-off-by: Charlie Developer <charlie@example.com>\nReviewed-by: Alice Developer <alice@example.com>\nTested-by: David Tester <david@example.com>",
@@ -667,8 +667,8 @@
667667
},
668668
{
669669
"type": "authored-commit",
670-
"timestamp": "2025-10-11T15:10:53+01:00",
671-
"sourceId": "4b3cddebae5f2613fe74c9b6804da097217a3389",
670+
"timestamp": "2025-10-12T16:15:49+01:00",
671+
"sourceId": "4fec97a2520ab0aae9454ef0c060d0f1dfc6aa4d",
672672
"sourceParentId": "",
673673
"platform": "git",
674674
"channel": "https://github.com/test/repo.git",
@@ -704,9 +704,9 @@
704704
},
705705
{
706706
"type": "signed-off-commit",
707-
"timestamp": "2025-10-11T15:10:53+01:00",
708-
"sourceId": "3ac5517fd7c7a2926af07025df5d02c069c9679e",
709-
"sourceParentId": "4b3cddebae5f2613fe74c9b6804da097217a3389",
707+
"timestamp": "2025-10-12T16:15:49+01:00",
708+
"sourceId": "e52dc2b2ec76720ce7c8233613d110da5378b014",
709+
"sourceParentId": "4fec97a2520ab0aae9454ef0c060d0f1dfc6aa4d",
710710
"platform": "git",
711711
"channel": "https://github.com/test/repo.git",
712712
"body": "Add configuration file\n\nThis commit adds the main configuration file for the project.\n\nSigned-off-by: Bob Reviewer <bob@example.com>",
@@ -741,8 +741,8 @@
741741
},
742742
{
743743
"type": "authored-commit",
744-
"timestamp": "2025-10-11T15:10:53+01:00",
745-
"sourceId": "e1f6976446341f5d80f5ac5fcea607a47c6362c4",
744+
"timestamp": "2025-10-12T16:15:49+01:00",
745+
"sourceId": "2aaf02cef5d7a0fd7f916eb5b64456c4e82a7e58",
746746
"sourceParentId": "",
747747
"platform": "git",
748748
"channel": "https://github.com/test/repo.git",

0 commit comments

Comments
 (0)