1name: Compliance Checks 2 3on: pull_request 4 5jobs: 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 ref: ${{ github.event.pull_request.head.sha }} 18 fetch-depth: 0 19 20 - name: cache-pip 21 uses: actions/cache@v3 22 with: 23 path: ~/.cache/pip 24 key: ${{ runner.os }}-doc-pip 25 26 - name: Install python dependencies 27 run: | 28 pip3 install setuptools 29 pip3 install wheel 30 pip3 install python-magic lxml junitparser gitlint pylint pykwalify yamllint 31 pip3 install west 32 33 - name: west setup 34 env: 35 BASE_REF: ${{ github.base_ref }} 36 run: | 37 git config --global user.email "you@example.com" 38 git config --global user.name "Your Name" 39 git remote -v 40 # Ensure there's no merge commits in the PR 41 [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ 42 (echo "::error ::Merge commits not allowed, rebase instead";false) 43 git rebase origin/${BASE_REF} 44 # debug 45 git log --pretty=oneline | head -n 10 46 west init -l . || true 47 west update 2>&1 1> west.update.log || west update 2>&1 1> west.update2.log 48 49 - name: Run Compliance Tests 50 continue-on-error: true 51 id: compliance 52 env: 53 BASE_REF: ${{ github.base_ref }} 54 run: | 55 export ZEPHYR_BASE=$PWD 56 # debug 57 ls -la 58 git log --pretty=oneline | head -n 10 59 ./scripts/ci/check_compliance.py --annotate -e KconfigBasic \ 60 -c origin/${BASE_REF}.. 61 62 - name: upload-results 63 uses: actions/upload-artifact@v3 64 continue-on-error: true 65 with: 66 name: compliance.xml 67 path: compliance.xml 68 69 - name: check-warns 70 run: | 71 if [[ ! -s "compliance.xml" ]]; then 72 exit 1; 73 fi 74 75 files=($(./scripts/ci/check_compliance.py -l)) 76 for file in "${files[@]}"; do 77 f="${file}.txt" 78 if [[ -s $f ]]; then 79 errors=$(cat $f) 80 errors="${errors//'%'/'%25'}" 81 errors="${errors//$'\n'/'%0A'}" 82 errors="${errors//$'\r'/'%0D'}" 83 echo "::error file=${f}::$errors" 84 exit=1 85 fi 86 done 87 88 if [ "${exit}" == "1" ]; then 89 exit 1; 90 fi 91