-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Run License Tests | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
license_tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
- name: Install Build Tools | ||
run: | | ||
python -m pip install build wheel | ||
- name: Install System Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt install python3-dev swig libssl-dev | ||
- name: Install core repo | ||
run: | | ||
pip install . | ||
- name: Install licheck | ||
run: | | ||
pip install git+https://github.com/NeonJarbas/lichecker | ||
- name: Install test dependencies | ||
run: | | ||
pip install pytest pytest-timeout pytest-cov | ||
- name: Test Licenses | ||
run: | | ||
pytest test/license_tests.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import unittest | ||
from pprint import pprint | ||
|
||
from lichecker import LicenseChecker | ||
|
||
# these packages dont define license in setup.py | ||
# manually verified and injected | ||
license_overrides = { | ||
"kthread": "MIT", | ||
'yt-dlp': "Unlicense", | ||
'pyxdg': 'GPL-2.0', | ||
'ptyprocess': 'ISC license', | ||
'psutil': 'BSD3' | ||
} | ||
# explicitly allow these packages that would fail otherwise | ||
whitelist = [ | ||
'idna' # BSD-like | ||
] | ||
|
||
# validation flags | ||
allow_nonfree = False | ||
allow_viral = False | ||
allow_unknown = False | ||
allow_unlicense = True | ||
allow_ambiguous = False | ||
|
||
pkg_name = "json_database" | ||
|
||
|
||
class TestLicensing(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(self): | ||
licheck = LicenseChecker(pkg_name, | ||
license_overrides=license_overrides, | ||
whitelisted_packages=whitelist, | ||
allow_ambiguous=allow_ambiguous, | ||
allow_unlicense=allow_unlicense, | ||
allow_unknown=allow_unknown, | ||
allow_viral=allow_viral, | ||
allow_nonfree=allow_nonfree) | ||
print("Package", pkg_name) | ||
print("Version", licheck.version) | ||
print("License", licheck.license) | ||
print("Transient Requirements (dependencies of dependencies)") | ||
pprint(licheck.transient_dependencies) | ||
self.licheck = licheck | ||
|
||
def test_license_compliance(self): | ||
print("Package Versions") | ||
pprint(self.licheck.versions) | ||
|
||
print("Dependency Licenses") | ||
pprint(self.licheck.licenses) | ||
|
||
self.licheck.validate() |