|
9 | 9 | - main
|
10 | 10 |
|
11 | 11 | jobs:
|
12 |
| - license-compliance: |
| 12 | + license-check: |
13 | 13 | runs-on: ubuntu-latest
|
14 |
| - |
15 | 14 | steps:
|
16 | 15 | - name: Checkout code
|
17 |
| - uses: actions/checkout@v3 |
| 16 | + uses: actions/checkout@v2 |
18 | 17 |
|
19 | 18 | - name: Set up Python
|
20 |
| - uses: actions/setup-python@v4 |
| 19 | + uses: actions/setup-python@v2 |
21 | 20 | with:
|
22 |
| - python-version: 3.9 |
| 21 | + python-version: '3.8' |
23 | 22 |
|
24 | 23 | - name: Install dependencies
|
25 | 24 | run: |
|
26 |
| - python -m venv venv |
27 |
| - . venv/bin/activate |
| 25 | + python -m pip install --upgrade pip |
28 | 26 | pip install -r requirements.txt
|
29 |
| -
|
30 |
| - - name: Check licenses |
31 |
| - run: | |
32 |
| - . venv/bin/activate |
33 | 27 | pip install pip-licenses
|
34 |
| - pip-licenses --from=mixed --output-file=dependency_licenses.json --format=json |
35 |
| -
|
36 |
| - - name: 'Parse Dependency licenses' |
37 |
| - id: parse-dependency-licenses |
38 |
| - run: | |
39 |
| - dependency_licenses=$(cat dependency_licenses.json) |
40 |
| - echo "::set-output name=dependency-licenses::${dependency_licenses}" |
41 |
| -
|
42 |
| - - name: 'Compare Dependency licenses' |
43 |
| - id: compare-dependency-licenses |
44 |
| - run: | |
45 |
| - dependency_licenses=$(cat dependency_licenses.json) |
46 |
| - echo "Dependency licenses content:" |
47 |
| - echo "${dependency_licenses}" |
48 |
| -
|
49 |
| - permitted_licenses="MIT License,Apache-2.0,BSD,EPL1" # Updated permitted licenses list |
50 |
| -
|
51 |
| - for package_info in $(echo "${dependency_licenses}" | jq -c '.[]'); do |
52 |
| - package_name=$(echo "${package_info}" | jq -r '.Name') |
53 |
| - license=$(echo "${package_info}" | jq -r '.License') |
54 |
| - |
55 |
| - if [[ ! ",${permitted_licenses}," =~ ",${license}," ]]; then |
56 |
| - echo "Error: Package ${package_name} has an unrecognized license: ${license}" |
57 |
| - exit 1 |
58 |
| - fi |
59 |
| - done |
60 |
| -
|
61 |
| - - name: 'Upload Dependency License Report' |
62 |
| - if: always() |
63 |
| - uses: actions/upload-artifact@v2 |
64 |
| - with: |
65 |
| - name: dependency-license-report |
66 |
| - path: dependency_licenses.json |
67 |
| - |
68 |
| - - name: 'Upload License Compliance Results' |
69 |
| - if: always() |
70 |
| - uses: actions/upload-artifact@v2 |
71 |
| - with: |
72 |
| - name: license-compliance-results |
73 |
| - path: license_compliance_results.txt |
74 | 28 |
|
75 |
| - - name: License compliance summary |
76 |
| - run: echo "License compliance check completed. See artifacts for details." |
| 29 | + - name: Run license compliance tests |
| 30 | + run: python -m unittest discover -s tests -p 'test_license_compliance.py' |
0 commit comments