Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/cb_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import argparse
import json
import os
import shutil
from pathlib import Path

Expand Down Expand Up @@ -142,6 +143,7 @@ def run_health(artifact_dir: str, repo: str, name: str) -> int:


def main(argv=None) -> int:
os.environ.setdefault("CODEBOARDING_SOURCE", "github_action")
p = argparse.ArgumentParser(description=__doc__)
sub = p.add_subparsers(dest="cmd", required=True)

Expand Down
17 changes: 17 additions & 0 deletions tests/test_cb_engine.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Smoke tests for scripts/cb_engine.py — verify it calls the engine API correctly,
using stub modules so no real engine venv is needed."""

import os
import sys
import tempfile
import types
import unittest
from contextlib import redirect_stderr
from io import StringIO
from pathlib import Path
from unittest.mock import patch

sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import cb_engine # noqa: E402
Expand Down Expand Up @@ -92,6 +94,21 @@ def test_main_parses_depth_as_int(self):
])
self.assertEqual(rf.calls[0]["depth_level"], 2)

def test_main_sets_github_action_source(self):
rf = _Rec()
self._install(run_full=rf)
with patch.dict(os.environ, {}, clear=True):
cb_engine.main([
"base",
"--repo", "/repo",
"--out", "/out",
"--name", "myrepo",
"--run-id", "rid-base",
"--depth", "2",
"--source-sha", "abc123",
])
self.assertEqual(os.environ["CODEBOARDING_SOURCE"], "github_action")

def test_main_rejects_invalid_depth(self):
for depth in ("0", "4", "x"):
with self.subTest(depth=depth):
Expand Down
Loading