Coverage for src / competitive_verifier / github / env.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-03-05 16:00 +0000

1import os 

2import pathlib 

3import re 

4 

5 

6def is_in_github_actions() -> bool: 

7 return os.getenv("GITHUB_ACTIONS", "").lower() == "true" 

8 

9 

10def get_ref_name() -> str | None: 

11 return os.getenv("GITHUB_REF_NAME") 

12 

13 

14def get_repository() -> str | None: 

15 return os.getenv("GITHUB_REPOSITORY") 

16 

17 

18def get_workflow_name() -> str | None: 

19 return os.getenv("GITHUB_WORKFLOW") 

20 

21 

22def get_workflow_ref() -> str | None: 

23 return os.getenv("GITHUB_WORKFLOW_REF") 

24 

25 

26def get_workflow_filename() -> str | None: 

27 ref = get_workflow_ref() 

28 if not ref: 

29 return None 

30 return re.sub(r".*/([^/]+\.yml)@.*$", r"\1", ref) 

31 

32 

33def _optional_path(strpath: str | None) -> pathlib.Path | None: 

34 return pathlib.Path(strpath) if strpath else None 

35 

36 

37def get_step_summary_path() -> pathlib.Path | None: 

38 return _optional_path(os.getenv("GITHUB_STEP_SUMMARY"))