Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
Use gh auth token for growth metrics
zhifu gaofab7d8de52dc
diff --git a/scripts/collect_growth_metrics.py b/scripts/collect_growth_metrics.pyindex 6b997fe44..dd310ca93 100755--- a/scripts/collect_growth_metrics.py+++ b/scripts/collect_growth_metrics.py@@ -11,6 +11,7 @@ import argparseimport datetime as dtimport jsonimport os+import subprocessimport sysimport urllib.errorimport urllib.request@@ -62,6 +63,20 @@ def github_headers() -> Dict[str, str]:"User-Agent": "funasr-growth-metrics",}token = os.environ.get("GITHUB_TOKEN")+ if not token:+ try:+ completed = subprocess.run(+ ["gh", "auth", "token"],+ check=True,+ stdout=subprocess.PIPE,+ stderr=subprocess.DEVNULL,+ text=True,+ timeout=5,+ )+ except (OSError, subprocess.SubprocessError):+ token = None+ else:+ token = completed.stdout.strip()if token:headers["Authorization"] = f"Bearer {token}"return headers@@ -547,4 +562,4 @@ def main() -> int:if __name__ == "__main__":- raise SystemExit(main())+ raise SystemExit(main())\ No newline at end of filediff --git a/tests/test_collect_growth_metrics.py b/tests/test_collect_growth_metrics.pyindex 1159de7b9..94d712c36 100644--- a/tests/test_collect_growth_metrics.py+++ b/tests/test_collect_growth_metrics.py@@ -1,6 +1,7 @@import importlib.utilimport ioimport json+import subprocessimport sysfrom datetime import date, datetime, timezonefrom contextlib import redirect_stdout@@ -21,6 +22,21 @@ def test_default_integration_prs_include_sglang_omni_fun_asr():assert "sgl-project/sglang-omni#898" in module.DEFAULT_INTEGRATION_PRS+def test_github_headers_falls_back_to_gh_auth_token(monkeypatch):+ module = load_growth_metrics_module()+ monkeypatch.delenv("GITHUB_TOKEN", raising=False)++ def fake_run(args, **kwargs):+ assert args == ["gh", "auth", "token"]+ return subprocess.CompletedProcess(args=args, returncode=0, stdout="cli-token\n")++ monkeypatch.setattr(module.subprocess, "run", fake_run)++ headers = module.github_headers()++ assert headers["Authorization"] == "Bearer cli-token"++def test_default_integration_prs_include_high_visibility_external_queue():module = load_growth_metrics_module()@@ -622,4 +638,4 @@ def test_main_outputs_integrations_json(monkeypatch):integration = payload["integrations"][0]assert integration["pr"] == "ray-project/ray#64053"assert integration["checks"]["state"] == "success"- assert integration["next_action"] == "request review"+ assert integration["next_action"] == "request review"\ No newline at end of file