Skip to content

Commit 7559643

Browse files
authored
feat/license tests workflow (#22)
authored-by: jarbasai <jarbasai@mailfence.com>
1 parent f5e9694 commit 7559643

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 license',
13+
'psutil': 'BSD3'
14+
}
15+
# explicitly allow these packages that would fail otherwise
16+
whitelist = []
17+
18+
# validation flags
19+
allow_nonfree = False
20+
allow_viral = False
21+
allow_unknown = False
22+
allow_unlicense = True
23+
allow_ambiguous = False
24+
25+
pkg_name = "ovos_utils"
26+
27+
28+
class TestLicensing(unittest.TestCase):
29+
@classmethod
30+
def setUpClass(self):
31+
licheck = LicenseChecker(pkg_name,
32+
license_overrides=license_overrides,
33+
whitelisted_packages=whitelist,
34+
allow_ambiguous=allow_ambiguous,
35+
allow_unlicense=allow_unlicense,
36+
allow_unknown=allow_unknown,
37+
allow_viral=allow_viral,
38+
allow_nonfree=allow_nonfree)
39+
print("Package", pkg_name)
40+
print("Version", licheck.version)
41+
print("License", licheck.license)
42+
print("Transient Requirements (dependencies of dependencies)")
43+
pprint(licheck.transient_dependencies)
44+
self.licheck = licheck
45+
46+
def test_license_compliance(self):
47+
print("Package Versions")
48+
pprint(self.licheck.versions)
49+
50+
print("Dependency Licenses")
51+
pprint(self.licheck.licenses)
52+
53+
self.licheck.validate()

0 commit comments

Comments
 (0)