|
| 1 | +name: Compliance Checks |
| 2 | + |
| 3 | +on: pull_request |
| 4 | + |
| 5 | +jobs: |
| 6 | + check_compliance: |
| 7 | + runs-on: ubuntu-22.04 |
| 8 | + name: Run compliance checks on patch series (PR) |
| 9 | + steps: |
| 10 | + - name: Update PATH for west |
| 11 | + run: | |
| 12 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 13 | +
|
| 14 | + - name: Checkout the code |
| 15 | + uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + path: sdk-hostap |
| 18 | + ref: ${{ github.event.pull_request.head.sha }} |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: cache-pip |
| 22 | + uses: actions/cache@v3 |
| 23 | + with: |
| 24 | + path: ~/.cache/pip |
| 25 | + key: ${{ runner.os }}-doc-pip |
| 26 | + |
| 27 | + - name: Install python dependencies |
| 28 | + working-directory: sdk-hostap |
| 29 | + run: | |
| 30 | + pip3 install setuptools |
| 31 | + pip3 install wheel |
| 32 | + pip3 install python-magic lxml junitparser gitlint pylint pykwalify yamllint |
| 33 | + pip3 install west |
| 34 | +
|
| 35 | + - name: Clone Zephyr downstream |
| 36 | + env: |
| 37 | + BASE_REF: ${{ github.base_ref }} |
| 38 | + working-directory: sdk-hostap |
| 39 | + run: | |
| 40 | + git config --global user.email "[email protected]" |
| 41 | + git config --global user.name "Your Name" |
| 42 | + git remote -v |
| 43 | + # Ensure there's no merge commits in the PR |
| 44 | + #[[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ |
| 45 | + #(echo "::error ::Merge commits not allowed, rebase instead";false) |
| 46 | + # Sauce tag checks before rebasing |
| 47 | + git rev-list --first-parent origin/${BASE_REF}..HEAD | tr '\n' ',' | \ |
| 48 | + xargs gitlint -c ncs-sauce-tags.enable=true \ |
| 49 | + -c title-starts-with-subsystem.regex=".*" --commits |
| 50 | + git rebase origin/${BASE_REF} |
| 51 | + # debug |
| 52 | + git log --pretty=oneline | head -n 10 |
| 53 | + # Clone downstream Zephyr (no west needed as we only need the scripts) |
| 54 | + git clone https://github.com/nrfconnect/sdk-zephyr |
| 55 | +
|
| 56 | + - name: Run CODEOWNERS test |
| 57 | + id: codeowners |
| 58 | + env: |
| 59 | + BASE_REF: ${{ github.base_ref }} |
| 60 | + working-directory: sdk-hostap |
| 61 | + if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true |
| 62 | + run: | |
| 63 | + ./scripts/ci/codeowners.py -c origin/${BASE_REF}.. |
| 64 | +
|
| 65 | + - name: Run Compliance Tests |
| 66 | + continue-on-error: true |
| 67 | + id: compliance |
| 68 | + env: |
| 69 | + BASE_REF: ${{ github.base_ref }} |
| 70 | + working-directory: sdk-hostap |
| 71 | + if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true |
| 72 | + run: | |
| 73 | + export ZEPHYR_BASE="$(dirname "$(pwd)")/sdk-hostap/sdk-zephyr" |
| 74 | + # debug |
| 75 | + ls -la |
| 76 | + git log --pretty=oneline | head -n 10 |
| 77 | + ./scripts/ci/check_compliance.py --annotate -e KconfigBasic -e Kconfig \ |
| 78 | + -c origin/${BASE_REF}.. |
| 79 | +
|
| 80 | + - name: upload-results |
| 81 | + uses: actions/upload-artifact@v3 |
| 82 | + continue-on-error: true |
| 83 | + if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true |
| 84 | + with: |
| 85 | + name: compliance.xml |
| 86 | + path: sdk-hostap/compliance.xml |
| 87 | + |
| 88 | + - name: check-warns |
| 89 | + working-directory: sdk-hostap |
| 90 | + if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true |
| 91 | + run: | |
| 92 | + export ZEPHYR_BASE="$(dirname "$(pwd)")/sdk-hostap/sdk-zephyr" |
| 93 | + if [[ ! -s "compliance.xml" ]]; then |
| 94 | + exit 1; |
| 95 | + fi |
| 96 | +
|
| 97 | + files=($($ZEPHYR_BASE/scripts/ci/check_compliance.py -l)) |
| 98 | + for file in "${files[@]}"; do |
| 99 | + f="${file}.txt" |
| 100 | + if [[ -s $f ]]; then |
| 101 | + errors=$(cat $f) |
| 102 | + errors="${errors//'%'/'%25'}" |
| 103 | + errors="${errors//$'\n'/'%0A'}" |
| 104 | + errors="${errors//$'\r'/'%0D'}" |
| 105 | + echo "::error file=${f}::$errors" |
| 106 | + exit=1 |
| 107 | + fi |
| 108 | + done |
| 109 | +
|
| 110 | + if [ "${exit}" == "1" ]; then |
| 111 | + exit 1; |
| 112 | + fi |
0 commit comments