Skip to content

Commit 59ad8cb

Browse files
Fetch CI for full history and handle sparse checkout for codecov
Signed-off-by: Leander Stephen D'Souza <[email protected]>
1 parent 686c99e commit 59ad8cb

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
steps:
3131
- name: Checkout repository
3232
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33+
with:
34+
fetch-depth: 0
3335

3436
- name: Set up Python ${{ matrix.python-version }}
3537
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0

test/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import yaml
1616

17+
REPO_LINK = 'https://github.com/ros-infrastructure/vcs2l.git'
18+
1719

1820
def to_file_url(path):
1921
return urljoin('file:', pathname2url(path))
@@ -30,7 +32,18 @@ def setup_git_repository(temp_dir):
3032
repo_root = os.path.dirname(os.path.dirname(__file__))
3133
gitrepo_path = os.path.join(temp_dir.name, 'gitrepo')
3234

33-
subprocess.check_call(['git', 'clone', '--branch', 'main', repo_root, gitrepo_path])
35+
commits_count = int(
36+
subprocess.check_output(
37+
['git', 'rev-list', '--count', 'HEAD'], cwd=repo_root
38+
).strip()
39+
)
40+
41+
if commits_count == 1:
42+
repo_root = REPO_LINK # codecov sparsely clones the repo
43+
44+
subprocess.check_call(['git', 'clone', repo_root, gitrepo_path])
45+
# Rename the current branch to main to have a consistent expected output
46+
subprocess.check_call(['git', 'branch', '-m', 'main'], cwd=gitrepo_path)
3447

3548
return gitrepo_path
3649

0 commit comments

Comments
 (0)