Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/scancode_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: ScanCode_update_test

on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:

jobs:
test_scancode:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Install latest ScanCode version
run: |
pip install scancode-toolkit

- name: Run ScanCode on test files
run: |
scancode -l --json-pp results.json path_to_test_files
continue-on-error: true

- name: Verify license detection count
run: |
python check_license_count.py results.json
continue-on-error: true

- name: Create Pull Request if test passes
if: success()
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b update-scancode
git commit -am "Update to latest ScanCode version"
git push origin update-scancode
gh pr create --title "Update ScanCode version" --body "Automatically created PR to update ScanCode version"
51 changes: 51 additions & 0 deletions check_license_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys
import json
import os

def check_license_count(json_file, threshold):
try:
with open(json_file, 'r', encoding='utf-8') as f:
data = json.load(f)

total_count = 0
licenses = {}
# Extract license information from the 'license_detections'
for detection in data.get('license_detections', []):
license_expression = detection['license_expression']
detection_count = detection['detection_count']
licenses[license_expression] = detection_count
total_count += detection_count

print(f"Detected licenses: {licenses}")
print(f"Total number of detected licenses: {total_count}")

if total_count >= threshold:
print(f"License detection meets the threshold ({threshold}). Test passed!")
sys.exit(0) # Exit with success
else:
print(f"License detection is below the threshold ({threshold}). Test failed.")
sys.exit(1) # Exit with failure

except Exception as e:
print(f"Error occurred: {str(e)}")
sys.exit(1)

if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python check_license_count.py <path_to_json_file> [threshold]")
sys.exit(1)

json_file = sys.argv[1]

# Use an environment variable for threshold if available, or default to 3
threshold = int(os.getenv('LICENSE_THRESHOLD', 3))

# If a threshold is provided as an argument, override the default
if len(sys.argv) > 2:
try:
threshold = int(sys.argv[2])
except ValueError:
print("Threshold must be an integer.")
sys.exit(1)

check_license_count(json_file, threshold)
73 changes: 73 additions & 0 deletions src/fosslight_source.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Metadata-Version: 2.1
Name: fosslight-source
Version: 2.0.0
Summary: FOSSLight Source Scanner
Home-page: https://github.com/fosslight/fosslight_source_scanner
Download-URL: https://github.com/fosslight/fosslight_source_scanner
Author: LG Electronics
License: Apache-2.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyparsing
Requires-Dist: scancode-toolkit==32.0.*,>=32.0.2
Requires-Dist: scanoss
Requires-Dist: XlsxWriter
Requires-Dist: fosslight_util>=2.0.0
Requires-Dist: PyYAML
Requires-Dist: wheel>=0.38.1
Requires-Dist: intbitset
Requires-Dist: fosslight_binary>=5.0.0
Requires-Dist: typecode-libmagic; sys_platform != "darwin"

<!--
Copyright (c) 2021 LG Electronics
SPDX-License-Identifier: Apache-2.0
-->
<p align='right'>
<a href="https://fosslight.org/fosslight-guide/scanner/2_source.html">
[Korean]
</a>
</p>

# FOSSLight Source Scanner

<img src="https://img.shields.io/pypi/l/fosslight_source" alt="FOSSLight Source Scanner is released under the Apache-2.0 License." /> <img src="https://img.shields.io/pypi/v/fosslight_source" alt="Current python package version." /> <img src="https://img.shields.io/pypi/pyversions/fosslight_source" /> [![REUSE status](https://api.reuse.software/badge/github.com/fosslight/fosslight_source_scanner)](https://api.reuse.software/info/github.com/fosslight/fosslight_source_scanner) [![Guide](http://img.shields.io/badge/-doc-blue?style=flat-square&logo=github&link=https://fosslight.org/fosslight-guide-en/scanner/2_source.html)](https://fosslight.org/fosslight-guide-en/scanner/2_source.html)
</p>

```note
Detect the license for the source code.
Use Source Code Scanner and process the scanner results.
```

**FOSSLight Source Scanner** uses source code scanners, [ScanCode][sc] and [SCANOSS][scanoss]. [ScanCode][sc] detects copyright and license phrases contained in the file and [SCANOSS][scanoss] searches OSS Name, OSS Version, download location, copyright and license information from [OSSKB][osskb]. Some files (ex- build script), binary files, directory and files in specific directories (ex-test) are excluded from the result. And removes words such as "-only" and "-old-style" from the license name to be printed. The output result is generated in spreadsheet format.


[sc]: https://github.com/nexB/scancode-toolkit
[scanoss]: https://github.com/scanoss/scanoss.py
[osskb]: https://osskb.org/


## 📖 User Guide

We describe the user guide in the FOSSLight guide page.
Please see the [**User Guide**](https://fosslight.org/fosslight-guide-en/scanner/2_source.html) for more information on how to install and run it.


## 👏 Contributing Guide

We always welcome your contributions.
Please see the [CONTRIBUTING guide](https://fosslight.org/fosslight-guide-en/learn/1_contribution.html) for how to contribute.


## 📄 License

FOSSLight Source Scanner is Apache-2.0, as found in the [LICENSE][l] file.

[l]: https://github.com/fosslight/fosslight_source_scanner/blob/main/LICENSE
Expand Down
21 changes: 21 additions & 0 deletions src/fosslight_source.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
LICENSE
MANIFEST.in
README.md
requirements.txt
setup.py
src/fosslight_source/__init__.py
src/fosslight_source/_help.py
src/fosslight_source/_license_matched.py
src/fosslight_source/_parsing_scancode_file_item.py
src/fosslight_source/_parsing_scanoss_file.py
src/fosslight_source/_scan_item.py
src/fosslight_source/cli.py
src/fosslight_source/run_scancode.py
src/fosslight_source/run_scanoss.py
src/fosslight_source/run_spdx_extractor.py
src/fosslight_source.egg-info/PKG-INFO
src/fosslight_source.egg-info/SOURCES.txt
src/fosslight_source.egg-info/dependency_links.txt
src/fosslight_source.egg-info/entry_points.txt
src/fosslight_source.egg-info/requires.txt
src/fosslight_source.egg-info/top_level.txt
1 change: 1 addition & 0 deletions src/fosslight_source.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions src/fosslight_source.egg-info/entry_points.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[console_scripts]
fosslight_source = fosslight_source.cli:main
run_scancode = fosslight_source.run_scancode:main
12 changes: 12 additions & 0 deletions src/fosslight_source.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pyparsing
scancode-toolkit==32.0.*,>=32.0.2
scanoss
XlsxWriter
fosslight_util>=2.0.0
PyYAML
wheel>=0.38.1
intbitset
fosslight_binary>=5.0.0

[:sys_platform != "darwin"]
typecode-libmagic
1 change: 1 addition & 0 deletions src/fosslight_source.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fosslight_source
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ filterwarnings = ignore::DeprecationWarning
[testenv:test_run]
deps =
-r{toxinidir}/requirements-dev.txt
scancode-toolkit # ScanCode를 test_run 환경에 추가

commands =
rm -rf test_scan
fosslight_source -p tests/test_files -j -m -o test_scan
fosslight_source -p tests -e test_files/test cli_test.py -j -m -o test_scan2
scancode -l --json-pp results.json tests/test_files # ScanCode 실행
python check_license_count.py results.json 3 # License 카운트 체크

[testenv:release]
deps =
Expand All @@ -50,4 +53,4 @@ commands =

[testenv:flake8]
deps = flake8
commands = flake8
commands = flake8 # Flake8 검사 실행
Loading