Skip to content

Commit afd4025

Browse files
Merge branch 'develop' into add-license-detection
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
2 parents 5b0efe4 + 9f91bf5 commit afd4025

File tree

68,409 files changed

+291206
-176164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68,409 files changed

+291206
-176164
lines changed

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,20 @@ tcl
9595
/00-*.txt
9696
/z-todo-licenses-*
9797

98+
# Extra ignores from licensedb
99+
*.pyc
100+
*.db
101+
.installed.cfg
102+
parts
103+
develop-eggs
104+
eggs
105+
downloads
106+
.settings
107+
TAGS
108+
Procfile
109+
local.cfg
110+
geckodriver.log
111+
var
112+
.metaflow
113+
selenium
114+
/dist/

CHANGELOG.rst

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,49 @@ License detection:
4646
matches in a larger license detecion. This remove a larger number of false
4747
positive or ambiguous license detections.
4848

49-
5049
- The data structure of the JSON output has changed for licenses. We now
5150
return match details once for each matched license expression rather than
5251
once for each license in a matched expression. There is a new top-level
5352
"license_references" attribute that contains the data details for each
5453
detected license only once. This data can contain the reference license text
5554
as an option.
5655

56+
- There is a new "scancode-reindex-licenses" command that replace the
57+
"scancode --reindex-licenses" command line option which has been
58+
removed. This new command supports simpler reindexing using custom
59+
license texts and license rules contributed by plugins or stored in an
60+
additional directory. The "--reindex-licenses-for-all-languages" CLI option
61+
is also moved to the "scancode-reindex-licenses" command as an option
62+
"--all-languages".
63+
64+
- We can now detect licenses using custom license texts and license rules.
65+
These can be provided as a one off in a directory or packaged as a plugin
66+
for consistent reuse and deployment. There is an option "--additional-directory"
67+
with the "scancode-reindex-licenses" command and also a new "--only-builtin"
68+
option to only use the builtin licenses to build the cache.
69+
70+
- Scancode LICENSE and RULE files now also contain their data as YAML frontmatter,
71+
which previously used to be in their respective YAML files. This reduces number of
72+
files in those directories, 'rules' and 'licenses' to half. Git line history is
73+
preserved for the files.
74+
75+
- A new command line option "--get-license-data" is added to dump license data in
76+
JSON, YAML and HTML formats, and also generates a local index and a static website
77+
to view the data. This will essentially be an API/way to get scancode license data
78+
as opposed to just reading the files.
79+
80+
81+
Package detection:
82+
~~~~~~~~~~~~~~~~~~~~~
83+
84+
- Code for parsing a Maven POM, npm package.json, freebsd manifest and haxelib
85+
JSON have been separated into two functions: one that creates a PackageData
86+
object from the parsed Resource, and another that calls the previous function
87+
and yields the PackageData. This was done such that we can use the package
88+
manifest data parsing code outside of the scancode-toolkit context in other
89+
libraries.
90+
91+
5792
v31.2.1 - 2022-10-05
5893
----------------------------------
5994

azure-pipelines.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
--ignore=tests/licensedcode/test_detection_datadriven2.py \
3434
--ignore=tests/licensedcode/test_detection_datadriven3.py \
3535
--ignore=tests/licensedcode/test_detection_datadriven4.py \
36+
--ignore=tests/licensedcode/test_additional_license.py \
3637
tests/licensedcode
3738
3839
license_datadriven1_2: |
@@ -78,6 +79,18 @@ jobs:
7879
venv/bin/pytest -n 3 -vvs --test-suite=all \
7980
tests/licensedcode/test_zzzz_cache.py
8081
82+
# this test runs in isolation because it modifies the actual
83+
# license index with additional licenses provided by a plugin
84+
# and we use the special --test-suite=plugins marker for these
85+
# tests
86+
additional_license_combined: |
87+
venv/bin/pip install tests/licensedcode/data/additional_licenses/additional_plugin_1/
88+
venv/bin/pip install tests/licensedcode/data/additional_licenses/additional_plugin_2/
89+
venv/bin/scancode-reindex-licenses \
90+
--additional-directory tests/licensedcode/data/additional_licenses/additional_dir/
91+
venv/bin/pytest -vvs --test-suite=plugins \
92+
tests/licensedcode/test_additional_license.py
93+
8194
- template: etc/ci/azure-posix.yml
8295
parameters:
8396
job_name: ubuntu18_cpython

conftest.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
################################################################################
3939
SLOW_TEST = 'scanslow'
4040
VALIDATION_TEST = 'scanvalidate'
41+
PLUGINS_TEST = 'scanplugins'
4142

4243

4344
def pytest_configure(config):
@@ -53,8 +54,14 @@ def pytest_configure(config):
5354
': Mark a ScanCode test as a validation test, super slow, long running test.',
5455
)
5556

57+
config.addinivalue_line(
58+
'markers',
59+
PLUGINS_TEST +
60+
': Mark a ScanCode test as a special CI test to tests installing additional plugins.',
61+
)
62+
5663

57-
TEST_SUITES = 'standard', 'all', 'validate'
64+
TEST_SUITES = ('standard', 'all', 'validate', 'plugins',)
5865

5966

6067
def pytest_addoption(parser):
@@ -72,9 +79,11 @@ def pytest_addoption(parser):
7279
help='Select which test suite to run: '
7380
'"standard" runs the standard test suite designed to run reasonably fast. '
7481
'"all" runs "standard" and "slow" (long running) tests. '
75-
'"validate" runs all the tests. '
82+
'"validate" runs all the tests, except the "plugins" tests. '
83+
'"plugins" runs special plugins tests. Needs extra setup, and is used only in the CI. '
7684
'Use the @pytest.mark.scanslow marker to mark a test as "slow" test. '
7785
'Use the @pytest.mark.scanvalidate marker to mark a test as a "validate" test.'
86+
'Use the @pytest.mark.scanplugins marker to mark a test as a "plugins" test.'
7887
)
7988

8089
################################################################################
@@ -87,13 +96,19 @@ def pytest_collection_modifyitems(config, items):
8796
test_suite = config.getvalue('test_suite')
8897
run_everything = test_suite == 'validate'
8998
run_slow_test = test_suite in ('all', 'validate')
99+
run_only_plugins = test_suite == 'plugins'
90100

91101
tests_to_run = []
92102
tests_to_skip = []
93103

94104
for item in items:
95105
is_validate = bool(item.get_closest_marker(VALIDATION_TEST))
96106
is_slow = bool(item.get_closest_marker(SLOW_TEST))
107+
is_plugins = bool(item.get_closest_marker(PLUGINS_TEST))
108+
109+
if is_plugins and not run_only_plugins:
110+
tests_to_skip.append(item)
111+
continue
97112

98113
if is_validate and not run_everything:
99114
tests_to_skip.append(item)

docs/source/cli-reference/core-options.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,6 @@ Comparing Progress Message Options
6969

7070
----
7171

72-
``--reindex-licenses`` Option
73-
-----------------------------
74-
75-
ScanCode maintains a license index to search for and detect licenses. When Scancode is
76-
configured for the first time, a license index is built and used in every scan thereafter.
77-
78-
This ``--reindex-licenses`` option rebuilds the license index. Running a scan with this option
79-
displays the following message to the terminal in addition to what it normally shows::
80-
81-
Checking and rebuilding the license index...
82-
83-
..
84-
[ToDo] Research and Write Better
85-
86-
----
87-
8872
``--from-json`` Option
8973
----------------------
9074

0 commit comments

Comments
 (0)