Skip to content

Commit ba07627

Browse files
authored
Merge pull request #116 from fosslight/develop
Add tox configuration for Windows
2 parents 9ee94ed + 3b1be8c commit ba07627

File tree

6 files changed

+46
-23
lines changed

6 files changed

+46
-23
lines changed

.github/workflows/pull-request.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- os: ubuntu-latest
4141
TARGET: ubuntu
4242
CMD_BUILD: >
43-
tox -e release
43+
tox -e ubuntu
4444
OUT_FILE_NAME: fosslight_bin_ubuntu18
4545
ASSET_MIME: application/octet-stream
4646
- os: windows-latest
@@ -49,6 +49,7 @@ jobs:
4949
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks &&
5050
move dist/cli.exe fosslight_prechecker_windows.exe &&
5151
./fosslight_prechecker_windows.exe
52+
tox -e windows
5253
OUT_FILE_NAME: fosslight_prechecker_windows.exe
5354
ASSET_MIME: application/vnd.microsoft.portable-executable
5455
steps:

src/fosslight_oss_pkg/_parsing_excel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def convert_yml_to_excel(oss_yaml_files, output_file, file_option_on, base_path)
4949
oss_items, _ = parsing_yml(yaml_file, base_path)
5050
for item in oss_items:
5151
items_to_print.extend(item.get_print_array())
52-
if not base_path.endswith("/"):
53-
base_path += "/"
52+
if not base_path.endswith(f"{os.sep}"):
53+
base_path += f"{os.sep}"
5454
yaml_file = yaml_file.replace(base_path, '')
55-
yaml_file = yaml_file.replace('/', '_')
56-
55+
yaml_file = yaml_file.replace(os.sep, '_')
5756
yaml_file_sheet = get_sheet_name(yaml_file, sheet_list)
57+
5858
if yaml_file_sheet:
5959
sheet_list[yaml_file_sheet] = items_to_print
6060
header[yaml_file_sheet] = HEADER_CONTENT
@@ -69,6 +69,6 @@ def convert_yml_to_excel(oss_yaml_files, output_file, file_option_on, base_path)
6969
else:
7070
logger.warning("Nothing is detected to convert so output file is not generated.")
7171
else:
72-
logger.error(f"Error to write excel file : {msg}")
72+
logger.error(f"Fail to write excel file : {msg}")
7373
except Exception as ex:
7474
logger.error(f"Error to write excel file : {ex}")

src/fosslight_prechecker/_precheck.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ def exclude_untracked_files(path):
4040
cmd_result = subprocess.check_output(['git', 'ls-files', '-o'], universal_newlines=True)
4141
cmd_result = cmd_result.split('\n')
4242
cmd_result.remove('')
43-
if not path.endswith("/"):
44-
path += "/"
43+
if not path.endswith(f"{os.sep}"):
44+
path += f"{os.sep}"
4545
cmd_result = [file.replace(path, '', 1) for file in cmd_result]
4646
DEFAULT_EXCLUDE_EXTENSION_FILES.extend(cmd_result)
4747
except Exception as ex:
4848
logger.error(f"Error to get git untracked files : {ex}")
4949

5050

51-
def exclude_gitignore_files(path):
51+
def exclude_gitignore_files(current_path, path):
5252
global DEFAULT_EXCLUDE_EXTENSION_FILES
5353
try:
54-
root_path = VCSStrategyGit.find_root(path)
54+
root_path = VCSStrategyGit.find_root(current_path)
5555
if os.path.isfile(os.path.join(root_path, '.gitignore')):
5656
cmd_result = subprocess.check_output(['git',
5757
'ls-files',
@@ -60,8 +60,8 @@ def exclude_gitignore_files(path):
6060
universal_newlines=True)
6161
cmd_result = cmd_result.split('\n')
6262
cmd_result.remove('')
63-
if not path.endswith("/"):
64-
path += "/"
63+
if not path.endswith(f"{os.sep}"):
64+
path += f"{os.sep}"
6565
cmd_result = [file.replace(path, '', 1) for file in cmd_result]
6666
DEFAULT_EXCLUDE_EXTENSION_FILES.extend(cmd_result)
6767
else:
@@ -80,7 +80,7 @@ def exclude_git_related_files(path):
8080
# Exclude untracked files
8181
exclude_untracked_files(path)
8282
# Exclude ignore files
83-
exclude_gitignore_files(path)
83+
exclude_gitignore_files(current_path, path)
8484

8585
# Restore path
8686
os.chdir(current_path)
@@ -244,14 +244,14 @@ def precheck_for_project(path_to_find, mode='lint'):
244244

245245
# File list that missing license text
246246
missing_license = [str(sub) for sub in set(report.files_without_licenses)]
247-
if not path_to_find.endswith("/"):
248-
path_to_find += "/"
247+
if not path_to_find.endswith(f"{os.sep}"):
248+
path_to_find += f"{os.sep}"
249249
missing_license = [sub.replace(path_to_find, '') for sub in missing_license]
250250

251251
# File list that missing copyright text
252252
missing_copyright = [str(sub) for sub in set(report.files_without_copyright)]
253-
if not path_to_find.endswith("/"):
254-
path_to_find += "/"
253+
if not path_to_find.endswith(f"{os.sep}"):
254+
path_to_find += f"{os.sep}"
255255
missing_copyright = [sub.replace(path_to_find, '') for sub in missing_copyright]
256256
except Exception as ex:
257257
dump_error_msg(f"Error prechecker lint: {ex}", True)

src/fosslight_prechecker/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def main():
4040
parser.add_argument('-o', '--output', help='Output file name', type=str, dest='output', default="")
4141
parser.add_argument('-l', '--license', help="License name to add(used in only 'add' mode)", type=str, dest='license', default="")
4242
parser.add_argument('-c', '--copyright', help="Copyright to add(used in only 'add' mode)", type=str, dest='copyright', default="")
43-
parser.add_argument('--notice', action='store_true', required=False)
43+
parser.add_argument('--notice', help="Show OSS notice", action='store_true', required=False)
4444
try:
4545
args = parser.parse_args()
4646
except SystemExit:

src/fosslight_prechecker/resources/convert_license.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
"apgl3.0": "APGL-3.0",
2727
"agplv3": "AGPL-3.0",
2828
"mit": "MIT",
29+
"epl-1.0": "EPL-1.0",
30+
"epl 1.0": "EPL-1.0",
31+
"epl1.0": "EPL-1.0",
32+
"epl-2.0": "EPL-2.0",
33+
"epl 2.0": "EPL-2.0",
34+
"epl2.0": "EPL-2.0",
2935
"lge": "LicenseRef-LGE_Proprietary_License",
3036
"lge license": "LicenseRef-LGE_Proprietary_License",
3137
"lge proprietary": "LicenseRef-LGE_Proprietary_License",

tox.ini

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Copyright (c) 2021 LG Electronics
22
# SPDX-License-Identifier: GPL-3.0-only
33
[tox]
4-
envlist = test_run
4+
envlist = {ubuntu, windows}
55
skipdist = true
66

77
[testenv]
88
install_command = pip install {opts} {packages}
99
whitelist_externals = cat
1010
cp
1111
rm
12+
cmd
13+
del
14+
copy
1215
setenv =
1316
PYTHONPATH=.
1417

@@ -19,17 +22,30 @@ exclude = .tox/*
1922
[pytest]
2023
filterwarnings = ignore::DeprecationWarning
2124

22-
[testenv:test_run]
25+
[testenv:windows]
26+
commands =
27+
fosslight_prechecker lint -p src -o "test_result\prechecker_result.yaml"
28+
fosslight_prechecker lint -p src -f yaml -o "test_result2\prechecker_result.yaml"
29+
fosslight_prechecker convert -p "tests\convert"
30+
cmd /c del /s/q tests\add_result
31+
cmd /c del /s/q tests\add\LICENSES
32+
cmd /c del /s/q tests\add\LICENSE
33+
cmd /c copy tests\add tests\add_result
34+
fosslight_prechecker add -p "tests\add_result" -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
35+
fosslight_prechecker add -p "tests\add" -l "EPL-1.0"
36+
37+
[testenv:ubuntu]
2338
commands =
2439
fosslight_prechecker lint -p src/ -o "test_result/prechecker_result.yaml"
2540
fosslight_prechecker lint -p src/ -f yaml -o "test_result2/prechecker_result.yaml"
26-
fosslight_prechecker convert -p tests/convert
41+
fosslight_prechecker convert -p "tests/convert"
2742
rm -rf tests/add_result
2843
rm -rf tests/add/LICENSES
2944
rm -rf tests/add/LICENSE
3045
cp -r tests/add tests/add_result
31-
fosslight_prechecker add -p tests/add_result -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
32-
fosslight_prechecker add -p tests/add -l EPL-1.0
46+
fosslight_prechecker add -p "tests/add_result" -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
47+
fosslight_prechecker add -p "tests/add" -l "EPL-1.0"
48+
3349
[testenv:release]
3450
deps =
3551
-r{toxinidir}/requirements-dev.txt

0 commit comments

Comments
 (0)