Skip to content

Commit d8d272a

Browse files
authored
Merge pull request #2682 from nexB/2653-output-data-format-version
Introduce output data format versioning #2653
2 parents b5f4624 + 661ceea commit d8d272a

File tree

10 files changed

+51
-22
lines changed

10 files changed

+51
-22
lines changed

docs/source/contribute/cut_new_release.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
How to cut a new release:
22
=========================
33

4+
Update version
5+
--------------
6+
47
- Run bumpversion with major, minor or patch to bump the version in
5-
``setup.cfg`` and ``src/scancode_config.py``
8+
``setup.cfg`` and ``src/scancode_config.py``. Note that this is CalVer.
9+
10+
- If scancode output data format is changed, increment manually the major, minor or patch
11+
to bump the version in ``src/scancode_config.py``. Note that this is SemVer.
12+
13+
Tag and publish
14+
---------------
615

716
- Update the CHANGELOG.rst
817

@@ -22,6 +31,9 @@ How to cut a new release:
2231
- Draft a new release in GitHub, using the previous release blurb as a base. Highlight new and
2332
noteworthy changes from the CHANGELOG.rst.
2433

34+
Create Release on GitHub
35+
------------------------
36+
2537
- Run ``etc/release/scancode_release.sh`` locally.
2638

2739
- Upload the release archives created in the ``dist/`` directory to the GitHub release page.
@@ -33,6 +45,9 @@ How to cut a new release:
3345

3446
- publish the release on GitHub
3547

48+
Upload wheels to pypi and Test
49+
------------------------------
50+
3651
- then build and publish the released wheel on Pypi. For this you need your own Pypi credentials
3752
(and get authorized to publish Pypi release: ask @pombredanne) and you need to have the ``twine``
3853
package installed and configured.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cffi==1.14.5
99
chardet==4.0.0
1010
click==8.0.1
1111
colorama==0.4.4
12-
commoncode==21.8.27
12+
commoncode==21.8.31
1313
construct==2.10.67
1414
cryptography==3.4.7
1515
debian-inspector==21.5.25

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ install_requires =
5959
chardet >= 3.0.0
6060
click >= 6.7, !=7.0
6161
colorama >= 0.3.9
62-
commoncode >= 21.8.27
62+
commoncode >= 21.8.31
6363
debian-inspector >= 21.5.25
6464
dparse >= 0.5.1
6565
fasteners

src/scancode/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def print_version(ctx, param, value):
9494
if not value or ctx.resilient_parsing:
9595
return
9696
click.echo('ScanCode version ' + scancode_config.__version__)
97+
click.echo('Output Format version ' + scancode_config.__output_format_version__)
9798
ctx.exit()
9899

99100

@@ -838,6 +839,7 @@ def echo_func(*_args, **_kwargs):
838839
cle.start_timestamp = start_timestamp
839840
cle.tool_name = 'scancode-toolkit'
840841
cle.tool_version = scancode_config.__version__
842+
cle.output_format_version = scancode_config.__output_format_version__
841843
cle.notice = notice
842844
cle.options = pretty_params or {}
843845

src/scancode/cli_test_utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def check_json_scan(
168168
result_file,
169169
regen=False,
170170
remove_file_date=False,
171-
ignore_headers=False
171+
check_headers=False,
172172
):
173173
"""
174174
Check the scan `result_file` JSON results against the `expected_file`
@@ -179,7 +179,7 @@ def check_json_scan(
179179
expectations. But use with caution.
180180
181181
If `remove_file_date` is True, the file.date attribute is removed.
182-
If `ignore_headers` is True, the scan headers attribute is removed.
182+
If `check_headers` is True, the scan headers attribute is not removed.
183183
"""
184184
results = load_json_result(result_file, remove_file_date)
185185
if regen:
@@ -188,7 +188,7 @@ def check_json_scan(
188188

189189
expected = load_json_result(expected_file, remove_file_date)
190190

191-
if ignore_headers:
191+
if not check_headers:
192192
results.pop('headers', None)
193193
expected.pop('headers', None)
194194

@@ -289,6 +289,7 @@ def check_jsonlines_scan(
289289
result_file,
290290
regen=False,
291291
remove_file_date=False,
292+
check_headers=False,
292293
):
293294
"""
294295
Check the scan result_file JSON Lines results against the expected_file
@@ -311,6 +312,10 @@ def check_jsonlines_scan(
311312
expected = json.load(res)
312313

313314
streamline_jsonlines_scan(expected, remove_file_date)
315+
316+
if not check_headers:
317+
results[0].pop('headers', None)
318+
expected[0].pop('headers', None)
314319

315320
expected = json.dumps(expected, indent=2, separators=(',', ': '))
316321
results = json.dumps(results, indent=2, separators=(',', ': '))

src/scancode_config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ def _create_dir(location):
7575
# in case package is not installed or we do not have setutools/pkg_resources
7676
# on hand fall back to this version
7777
__version__ = '21.8.4'
78+
79+
# See https://github.com/nexB/scancode-toolkit/issues/2653 for more information
80+
# on the data format version
81+
__output_format_version__ = '1.0.0'
82+
83+
7884
try:
7985
from pkg_resources import get_distribution, DistributionNotFound
8086
try:

tests/cluecode/test_plugin_filter_clues.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_scan_plugin_filter_clues_for_rule():
4141
args = ['-clieu', '--filter-clues', test_dir, '--json', result_file]
4242
run_scan_click(args)
4343
expected = test_env.get_test_loc('plugin_filter_clues/filtered-expected.json')
44-
check_json_scan(expected, result_file, remove_file_date=True, ignore_headers=True, regen=False)
44+
check_json_scan(expected, result_file, remove_file_date=True, regen=False)
4545

4646

4747
def test_scan_plugin_filter_clues_does_not_filter_incorrectly():
@@ -53,7 +53,7 @@ def test_scan_plugin_filter_clues_does_not_filter_incorrectly():
5353
args = ['-clieu', '--filter-clues', test_dir, '--json', result_file]
5454
run_scan_click(args)
5555
expected = test_env.get_test_loc('plugin_filter_clues/filtered-expected2.json')
56-
check_json_scan(expected, result_file, remove_file_date=True, ignore_headers=True, regen=False)
56+
check_json_scan(expected, result_file, remove_file_date=True, regen=False)
5757

5858

5959
# Regression on types tracked in https://github.com/nexB/typecode/issues/21
@@ -66,4 +66,4 @@ def test_scan_plugin_filter_clues_for_license():
6666
args = ['-clieu', '--filter-clues', test_dir, '--json', result_file]
6767
run_scan_click(args)
6868
expected = test_env.get_test_loc('plugin_filter_clues/filtered-expected3.json')
69-
check_json_scan(expected, result_file, remove_file_date=True, ignore_headers=True, regen=False)
69+
check_json_scan(expected, result_file, remove_file_date=True, regen=False)

tests/scancode/data/help/help.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ Options:
7070
is not treated as findings).
7171

7272
output control:
73-
--full-root Report full, absolute paths.
74-
--strip-root Strip the root directory segment of all paths. The default is to
75-
always include the last directory segment of the scanned path
76-
such that all paths have a common root directory.
73+
--full-root Report full, absolute paths.
74+
--strip-root Strip the root directory segment of all paths. The default is
75+
to always include the last directory segment of the scanned
76+
path such that all paths have a common root directory.
7777

7878
pre-scan:
7979
--ignore <pattern> Ignore files matching <pattern>.

tests/summarycode/test_plugin_consolidate.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ def test_consolidate_component_package_from_json_can_run_twice(self):
4646

4747
result_file = self.get_temp_file('json')
4848
run_scan_click(['--from-json', scan_file, '--consolidate', '--json', result_file])
49-
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True)
49+
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True)
5050

5151
# rerun with result_file from last run
5252
result_file2 = self.get_temp_file('json')
5353
run_scan_click(['--from-json', result_file, '--consolidate', '--json', result_file2])
54-
check_json_scan(expected_file, result_file2, regen=False, remove_file_date=True, ignore_headers=True)
54+
check_json_scan(expected_file, result_file2, regen=False, remove_file_date=True)
5555

5656
def test_consolidate_component_package_from_live_scan(self):
5757
scan_loc = self.get_test_loc('plugin_consolidate/component-package')
5858
result_file = self.get_temp_file('json')
5959
expected_file = self.get_test_loc('plugin_consolidate/component-package-expected.json')
6060
run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file])
61-
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True)
61+
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True)
6262

6363
def test_consolidate_package_always_include_own_manifest_file(self):
6464
scan_loc = self.get_test_loc('plugin_consolidate/package-manifest')
@@ -83,7 +83,7 @@ def test_consolidate_multiple_same_holder_and_license(self):
8383
result_file = self.get_temp_file('json')
8484
expected_file = self.get_test_loc('plugin_consolidate/multiple-same-holder-and-license-expected.json')
8585
run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file])
86-
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True)
86+
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True)
8787

8888
def test_consolidate_origin_summary_license_holder_rollup(self):
8989
scan_loc = self.get_test_loc('plugin_consolidate/license-holder-rollup')
@@ -108,25 +108,25 @@ def test_consolidate_component_package_build_from_live_scan(self):
108108
result_file = self.get_temp_file('json')
109109
expected_file = self.get_test_loc('plugin_consolidate/component-package-build-expected.json')
110110
run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file])
111-
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True)
111+
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True)
112112

113113
def test_consolidate_report_minority_origin_directory(self):
114114
scan_loc = self.get_test_loc('plugin_consolidate/report-subdirectory-with-minority-origin')
115115
result_file = self.get_temp_file('json')
116116
expected_file = self.get_test_loc('plugin_consolidate/report-subdirectory-with-minority-origin-expected.json')
117117
run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file])
118-
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True)
118+
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True)
119119

120120
def test_consolidate_zlib(self):
121121
scan_loc = self.get_test_loc('plugin_consolidate/zlib.json')
122122
result_file = self.get_temp_file('json')
123123
expected_file = self.get_test_loc('plugin_consolidate/zlib-expected.json')
124124
run_scan_click(['--from-json', scan_loc, '--consolidate', '--json', result_file])
125-
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True)
125+
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True)
126126

127127
def test_consolidate_e2fsprogs(self):
128128
scan_loc = self.get_test_loc('plugin_consolidate/e2fsprogs.json')
129129
result_file = self.get_temp_file('json')
130130
expected_file = self.get_test_loc('plugin_consolidate/e2fsprogs-expected.json')
131131
run_scan_click(['--from-json', scan_loc, '--consolidate', '--json', result_file])
132-
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True)
132+
check_json_scan(expected_file, result_file, regen=False, remove_file_date=True)

tests/summarycode/test_score.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def closure_test_function(*args, **kwargs):
5252
test_env.get_test_loc(expected_file),
5353
result_file,
5454
remove_file_date=True,
55-
regen=regen)
55+
regen=regen,
56+
)
5657

5758
test_name = 'test_license_clarity_score_%(test_name)s' % locals()
5859
test_name = python_safe_name(test_name)

0 commit comments

Comments
 (0)