Skip to content

Commit cb7c0ff

Browse files
committed
LICENSE tests
1 parent 74f89cc commit cb7c0ff

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

.github/workflows/license_tests.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Run License Tests
2+
on:
3+
push:
4+
workflow_dispatch:
5+
6+
jobs:
7+
license_tests:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
with:
12+
ref: ${{ github.head_ref }}
13+
- name: Setup Python
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: 3.8
17+
- name: Install Build Tools
18+
run: |
19+
python -m pip install build wheel
20+
- name: Install System Dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt install python3-dev swig libssl-dev
24+
- name: Install core repo
25+
run: |
26+
pip install .
27+
- name: Install licheck
28+
run: |
29+
pip install git+https://github.com/NeonJarbas/lichecker
30+
- name: Install test dependencies
31+
run: |
32+
pip install pytest pytest-timeout pytest-cov
33+
- name: Test Licenses
34+
run: |
35+
pytest test/license_tests.py

test/license_tests.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import unittest
2+
from pprint import pprint
3+
4+
from lichecker import LicenseChecker
5+
6+
# these packages dont define license in setup.py
7+
# manually verified and injected
8+
license_overrides = {
9+
"kthread": "MIT",
10+
'yt-dlp': "Unlicense",
11+
'pyxdg': 'GPL-2.0',
12+
'ptyprocess': 'ISC',
13+
'psutil': 'BSD3',
14+
'setuptools': "MIT",
15+
'typing-extensions': "PSFL",
16+
'PyAudio': "MIT"
17+
}
18+
# explicitly allow these packages that would fail otherwise
19+
whitelist = [
20+
'idna', # BSD-like
21+
'python-dateutil', # 'Simplified BSD'
22+
'pycryptodomex', # 'BSD, Public Domain',
23+
]
24+
25+
# validation flags
26+
allow_nonfree = False
27+
allow_viral = False
28+
allow_unknown = False
29+
allow_unlicense = True
30+
allow_ambiguous = False
31+
32+
pkg_name = "hivemind_webchat"
33+
34+
35+
class TestLicensing(unittest.TestCase):
36+
@classmethod
37+
def setUpClass(self):
38+
licheck = LicenseChecker(pkg_name,
39+
license_overrides=license_overrides,
40+
whitelisted_packages=whitelist,
41+
allow_ambiguous=allow_ambiguous,
42+
allow_unlicense=allow_unlicense,
43+
allow_unknown=allow_unknown,
44+
allow_viral=allow_viral,
45+
allow_nonfree=allow_nonfree)
46+
print("Package", pkg_name)
47+
print("Version", licheck.version)
48+
print("License", licheck.license)
49+
print("Transient Requirements (dependencies of dependencies)")
50+
pprint(licheck.transient_dependencies)
51+
self.licheck = licheck
52+
53+
def test_license_compliance(self):
54+
print("Package Versions")
55+
pprint(self.licheck.versions)
56+
57+
print("Dependency Licenses")
58+
pprint(self.licheck.licenses)
59+
60+
self.licheck.validate()

0 commit comments

Comments
 (0)