-
Notifications
You must be signed in to change notification settings - Fork 1.3k
113 lines (102 loc) · 3.69 KB
/
license-reusable.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#
# You can call this workflow in your repository. See the example caller workflow:
#
# --------------------------------------------------------------------------------------
# name: My License Check Caller
# on: pull_request
# jobs:
# call-workflow:
# uses: nrfconnect/sdk-nrf/.github/workflows/license-reusable.yml@main
# with:
# path: my_module_path
# license_allow_list: my_module_path/license_allow_list.yaml
# # You can find more details about the inputs below.
# --------------------------------------------------------------------------------------
name: Reusable License Check
on:
workflow_call:
inputs:
path:
# Required path to your module relative to west workspace.
type: string
required: true
license_allow_list:
# Optional path to your custom license allow list file relative to west workspace.
# By default, the list form the "sdk-nrf" repository is used. For details about
# format of the list, see "scripts/ci/license_allow_list.yaml" in the
# "sdk-nrf" repository.
type: string
default: nrf/scripts/ci/license_allow_list.yaml
jobs:
license_job:
runs-on: ubuntu-24.04
name: Run license checks on patch series (PR)
steps:
- name: Checkout sources
uses: nrfconnect/action-checkout-west-update@main
with:
git-fetch-depth: 0
git-ref: ${{ github.event.pull_request.head.sha }}
path: ncs/${{ inputs.path }}
west-update-args: '-n zephyr bsim'
- name: cache-pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-doc-pip
- name: Install python dependencies
run: |
pip3 install -U pip
pip3 install -U setuptools
export PATH="$HOME/.local/bin:$PATH"
pip3 install -U wheel
pip3 install --user -U west
pip3 show -f west
- name: Git rebase
env:
BASE_REF: ${{ github.base_ref }}
working-directory: ncs/${{ inputs.path }}
run: |
git remote -v
git branch
git rebase origin/${BASE_REF}
# debug
git log --pretty=oneline | head -n 10
- name: West zephyr-export
working-directory: ncs
env:
PR_REF: ${{ github.event.pull_request.head.sha }}
run: |
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/bin:$PATH"
west zephyr-export
echo "ZEPHYR_BASE=$(pwd)/zephyr" >> $GITHUB_ENV
# debug
( cd ${{ inputs.path }}; echo "${{ inputs.path }}"; git log --pretty=oneline --max-count=10 )
( cd nrf; echo "nrf"; git log --pretty=oneline --max-count=10 )
( cd zephyr; echo "zephyr"; git log --pretty=oneline --max-count=10 )
- name: Install license check script dependencies
run: |
pip3 install -U -r ncs/nrf/scripts/ci/requirements.txt
- name: Run license checks
id: license_checks
env:
BASE_REF: ${{ github.base_ref }}
ZEPHYR_BASE: ${{ env.ZEPHYR_BASE }}
working-directory: ncs/${{ inputs.path }}
if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
run: |
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/bin:$PATH"
${ZEPHYR_BASE}/../nrf/scripts/ci/check_license.py \
--github \
-l ${ZEPHYR_BASE}/../${{ inputs.license_allow_list }} \
-c origin/${BASE_REF}..
- name: Upload results
uses: actions/upload-artifact@v4
continue-on-error: true
if: always() && contains(github.event.pull_request.user.login, 'dependabot[bot]') != true
with:
name: licenses.xml
path: ncs/${{ inputs.path }}/licenses.xml
overwrite: true