Skip to content

Commit 9c875b5

Browse files
authored
Merge pull request #743 from aboutcode-org/fix-ci-bug
Update CRAN, Swift and composer
2 parents 46113fc + 2461881 commit 9c875b5

File tree

5 files changed

+38
-60
lines changed

5 files changed

+38
-60
lines changed

minecode_pipelines/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
#
99

1010

11-
VERSION = "0.0.1b22"
11+
VERSION = "0.0.1b23"

minecode_pipelines/pipes/composer.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
get_checkpoint_from_file,
3333
update_checkpoints_in_github,
3434
)
35-
from scanpipe.pipes.federatedcode import commit_changes
36-
from scanpipe.pipes.federatedcode import push_changes
37-
from minecode_pipelines import VERSION
35+
from scanpipe.pipes.federatedcode import commit_and_push_changes
3836
from minecode_pipelines.utils import cycle_from_index, grouper
3937

4038
PACKAGE_BATCH_SIZE = 100
@@ -89,23 +87,15 @@ def mine_and_publish_composer_purls(packages, cloned_data_repo, cloned_config_re
8987
purl_files.append(purl_file_full_path)
9088
purls.append(str(base_purl))
9189

92-
if purl_files:
93-
commit_changes(
94-
repo=cloned_data_repo,
95-
files_to_commit=purl_files,
96-
purls=purls,
97-
mine_type="packageURL",
98-
tool_name="pkg:composer/minecode-pipelines",
99-
tool_version=VERSION,
100-
)
101-
push_changes(repo=cloned_data_repo)
102-
103-
settings_data = {
104-
"date": str(datetime.now()),
105-
"start_index": start_index + (batch_index + 1) * PACKAGE_BATCH_SIZE,
106-
}
107-
update_checkpoints_in_github(
108-
checkpoint=settings_data,
109-
cloned_repo=cloned_config_repo,
110-
path=COMPOSER_CHECKPOINT_PATH,
111-
)
90+
if purls and purl_files:
91+
commit_and_push_changes(repo=cloned_data_repo, files_to_commit=purl_files, purls=purls)
92+
93+
settings_data = {
94+
"date": str(datetime.now()),
95+
"start_index": start_index + (batch_index + 1) * PACKAGE_BATCH_SIZE,
96+
}
97+
update_checkpoints_in_github(
98+
checkpoint=settings_data,
99+
cloned_repo=cloned_config_repo,
100+
path=COMPOSER_CHECKPOINT_PATH,
101+
)

minecode_pipelines/pipes/cran.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/aboutcode-org/scancode.io for support and download.
2222

23-
from aboutcode.hashid import get_package_purls_yml_file_path, get_core_purl
24-
from scanpipe.pipes.federatedcode import commit_changes
25-
from scanpipe.pipes.federatedcode import push_changes
26-
from minecode_pipelines import VERSION
23+
from aboutcode.hashid import get_package_purls_yml_file_path
24+
from aboutcode.hashid import get_core_purl
25+
from scanpipe.pipes.federatedcode import commit_and_push_changes
2726
from minecode_pipelines.miners.cran import extract_cran_packages
2827
from minecode_pipelines.pipes import write_data_to_yaml_file
2928
from minecode_pipelines.utils import grouper
3029

31-
PACKAGE_BATCH_SIZE = 1000
30+
PACKAGE_BATCH_SIZE = 100
3231

3332

3433
def mine_and_publish_cran_packageurls(cloned_data_repo, db_path, logger):
@@ -38,7 +37,7 @@ def mine_and_publish_cran_packageurls(cloned_data_repo, db_path, logger):
3837
"""
3938
packages_to_sync = list(extract_cran_packages(db_path))
4039

41-
for package_batch in grouper(packages_to_sync, PACKAGE_BATCH_SIZE):
40+
for package_batch in grouper(n=PACKAGE_BATCH_SIZE, iterable=packages_to_sync):
4241
purl_files = []
4342
base_purls = []
4443

@@ -62,12 +61,8 @@ def mine_and_publish_cran_packageurls(cloned_data_repo, db_path, logger):
6261

6362
# After finishing the batch, commit & push if there’s something to save
6463
if purl_files and base_purls:
65-
commit_changes(
64+
commit_and_push_changes(
6665
repo=cloned_data_repo,
6766
files_to_commit=purl_files,
6867
purls=base_purls,
69-
mine_type="packageURL",
70-
tool_name="pkg:pypi/minecode-pipelines",
71-
tool_version=VERSION,
7268
)
73-
push_changes(repo=cloned_data_repo)

minecode_pipelines/pipes/swift.py

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
from aboutcode.hashid import get_core_purl
2929
from packageurl import PackageURL
3030

31-
from minecode_pipelines.miners.swift import fetch_git_tags_raw, get_tags_and_commits_from_git_output
31+
from minecode_pipelines.miners.swift import fetch_git_tags_raw
32+
from minecode_pipelines.miners.swift import get_tags_and_commits_from_git_output
3233
from minecode_pipelines.miners.swift import split_org_repo
3334

3435
from minecode_pipelines.pipes import update_checkpoints_in_github
@@ -38,9 +39,7 @@
3839
from minecode_pipelines.pipes import get_checkpoint_from_file
3940
from scanpipe.pipes.federatedcode import clone_repository
4041

41-
from scanpipe.pipes.federatedcode import commit_changes
42-
from scanpipe.pipes.federatedcode import push_changes
43-
from minecode_pipelines import VERSION
42+
from scanpipe.pipes.federatedcode import commit_and_push_changes
4443
from minecode_pipelines.utils import cycle_from_index
4544

4645
PACKAGE_BATCH_SIZE = 100
@@ -49,7 +48,7 @@
4948
MINECODE_DATA_SWIFT_REPO = os.environ.get(
5049
"MINECODE_DATA_SWIFT_REPO", "https://github.com/aboutcode-data/minecode-data-swift-test"
5150
)
52-
MINECODE_SWIFT_INDEX_REPO = "https://github.com/SwiftPackageIndex/"
51+
MINECODE_SWIFT_INDEX_REPO = "https://github.com/SwiftPackageIndex/PackageList"
5352

5453

5554
def store_swift_packages(package_repo_url, tags_and_commits, cloned_data_repo):
@@ -133,16 +132,13 @@ def mine_and_publish_swift_packageurls(logger):
133132
counter += 1
134133

135134
if counter >= PACKAGE_BATCH_SIZE:
136-
commit_changes(
137-
repo=cloned_data_repo,
138-
files_to_commit=purl_files,
139-
purls=purls,
140-
mine_type="packageURL",
141-
tool_name="pkg:pypi/minecode-pipelines",
142-
tool_version=VERSION,
143-
)
135+
if purls and purl_files:
136+
commit_and_push_changes(
137+
repo=cloned_data_repo,
138+
files_to_commit=purl_files,
139+
purls=purls,
140+
)
144141

145-
push_changes(repo=cloned_data_repo)
146142
purl_files = []
147143
purls = []
148144
counter = 0
@@ -161,14 +157,11 @@ def mine_and_publish_swift_packageurls(logger):
161157
path=SWIFT_CHECKPOINT_PATH,
162158
)
163159

164-
commit_changes(
165-
repo=cloned_data_repo,
166-
files_to_commit=purl_files,
167-
purls=purls,
168-
mine_type="packageURL",
169-
tool_name="pkg:pypi/minecode-pipelines",
170-
tool_version=VERSION,
171-
)
160+
if purls and purl_files:
161+
commit_and_push_changes(
162+
repo=cloned_data_repo,
163+
files_to_commit=purl_files,
164+
purls=purls,
165+
)
172166

173-
push_changes(repo=cloned_data_repo)
174167
return [swift_index_repo, cloned_data_repo, cloned_config_repo]

pyproject-minecode_pipelines.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "flot.buildapi"
44

55
[project]
66
name = "minecode_pipelines"
7-
version = "0.0.1b22"
7+
version = "0.0.1b23"
88
description = "A library for mining packageURLs and package metadata from ecosystem repositories."
99
readme = "minecode_pipelines/README.rst"
1010
license = { text = "Apache-2.0" }
@@ -60,7 +60,7 @@ mine_swift = "minecode_pipelines.pipelines.mine_swift:MineSwift"
6060
mine_composer = "minecode_pipelines.pipelines.mine_composer:MineComposer"
6161

6262
[tool.bumpversion]
63-
current_version = "0.0.1b22"
63+
current_version = "0.0.1b23"
6464
allow_dirty = true
6565

6666
files = [

0 commit comments

Comments
 (0)