Skip to content

Commit ea272d3

Browse files
workflows: add license check
Add license check. Based on license check in sdk-nrf. Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 0ba1c56 commit ea272d3

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

.github/workflows/license.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: License Check
2+
3+
on: pull_request
4+
5+
jobs:
6+
license_job:
7+
runs-on: ubuntu-24.04
8+
name: Run license checks on patch series (PR)
9+
steps:
10+
- name: Checkout the code
11+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
12+
with:
13+
path: ncs/nrf-bm
14+
ref: ${{ github.event.pull_request.head.sha }}
15+
fetch-depth: 0
16+
17+
- name: cache-pip
18+
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3
19+
with:
20+
path: ~/.cache/pip
21+
key: ${{ runner.os }}-doc-pip
22+
23+
- name: Install python dependencies
24+
run: |
25+
pip3 install -U pip
26+
pip3 install -U setuptools
27+
export PATH="$HOME/.local/bin:$PATH"
28+
pip3 install -U wheel
29+
pip3 install --user -U west
30+
pip3 show -f west
31+
32+
- name: Prepare west project
33+
working-directory: ncs
34+
run: |
35+
west init -l nrf-bm
36+
west update -o=--depth=1 -n
37+
38+
- name: West zephyr-export
39+
working-directory: ncs
40+
env:
41+
PR_REF: ${{ github.event.pull_request.head.sha }}
42+
run: |
43+
export PATH="$HOME/.local/bin:$PATH"
44+
export PATH="$HOME/bin:$PATH"
45+
west zephyr-export
46+
echo "ZEPHYR_BASE=$(pwd)/zephyr" >> $GITHUB_ENV
47+
# debug
48+
( cd nrf-bm; echo "nrf-bm"; git log --pretty=oneline --max-count=10 )
49+
( cd nrf; echo "nrf"; git log --pretty=oneline --max-count=10 )
50+
( cd zephyr; echo "zephyr"; git log --pretty=oneline --max-count=10 )
51+
52+
- name: Install license check script dependencies
53+
run: |
54+
pip3 install -U -r ncs/nrf/scripts/ci/requirements.txt
55+
56+
- name: Run license checks
57+
id: license_checks
58+
env:
59+
BASE_REF: ${{ github.base_ref }}
60+
ZEPHYR_BASE: ${{ env.ZEPHYR_BASE }}
61+
working-directory: ncs/nrf-bm
62+
if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
63+
run: |
64+
export PATH="$HOME/.local/bin:$PATH"
65+
export PATH="$HOME/bin:$PATH"
66+
${ZEPHYR_BASE}/../nrf/scripts/ci/check_license.py \
67+
--github \
68+
-l ${ZEPHYR_BASE}/../nrf-bm/scripts/ci/license_allow_list.yaml \
69+
-c origin/${BASE_REF}..
70+
71+
- name: Upload results
72+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
73+
continue-on-error: true
74+
if: always() && contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
75+
with:
76+
name: licenses.xml
77+
path: ncs/nrf-bm/licenses.xml
78+
overwrite: true

scripts/ci/license_allow_list.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# List of licenses allowed by the "license_check.py" script.
2+
# Key is a license identifier, value is a regular expression (see Python's
3+
# re.search) that matches the files that are allowed to have the license.
4+
# The value can be multiline string. Each line is a regexp that can optionally
5+
# start with a '!' character to indicate that it is a negative match.
6+
# File paths are relative to west workspace directory.
7+
# Special key "none" match no license. Special key "any" match any license
8+
# including no license.
9+
# You can add a '-' character to the beginning of the license identifier to
10+
# allow specific license, but using it will generate a warning.
11+
12+
# Nordic 5-Clause is always allowed.
13+
LicenseRef-Nordic-5-Clause: ".*"
14+
15+
# Missing license information is allowed in all files except the ones listed below using
16+
# negative match.
17+
none: |
18+
.*
19+
!\.c$
20+
!\.h$
21+
!\.cpp$
22+
!\.a$
23+
!\.py$
24+
25+
# Any license information is allowed in Python scripts, but it will generate a warning.
26+
-any: |
27+
\.py$
28+
29+
# The 'license-texts.yaml' file contains texts of multiple licenses.
30+
# Ignore all detected licenses in that file.
31+
any: |
32+
.*/license-texts.yaml$
33+
^nrf/subsys/nrf_compress/lzma/
34+
35+
# Allow different licenses from external sources
36+
Apache-2.0: |
37+
^nrf-bm/drivers/flash/soc_flash_nrf_rram/
38+
^nrf-bm/subsys/storage/flash_map/

0 commit comments

Comments
 (0)