| name: Coding Guidelines |
| |
| on: pull_request |
| |
| permissions: |
| contents: read |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} |
| cancel-in-progress: true |
| |
| jobs: |
| compliance_job: |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 30 |
| name: Run coding guidelines checks on patch series (PR) |
| steps: |
| - name: Checkout the code |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| with: |
| persist-credentials: false |
| ref: ${{ github.event.pull_request.head.sha }} |
| fetch-depth: 0 |
| |
| - name: Set up Python |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 |
| with: |
| python-version: 3.12 |
| cache: pip |
| cache-dependency-path: scripts/requirements-actions.txt |
| |
| - name: Install Python packages |
| run: | |
| pip install -r scripts/requirements-actions.txt --require-hashes |
| |
| - name: Install Packages |
| run: | |
| sudo apt-get update |
| sudo apt-get install coccinelle |
| |
| - name: Run Coding Guidelines Checks |
| continue-on-error: true |
| id: coding_guidelines |
| env: |
| BASE_REF: ${{ github.base_ref }} |
| run: | |
| export ZEPHYR_BASE=$PWD |
| git config --global user.email "actions@zephyrproject.org" |
| git config --global user.name "Github Actions" |
| git remote -v |
| rm -fr ".git/rebase-apply" |
| rm -fr ".git/rebase-merge" |
| git rebase origin/${BASE_REF} |
| git clean -f -d |
| source zephyr-env.sh |
| # debug |
| ls -la |
| git log --pretty=oneline | head -n 10 |
| ./scripts/ci/guideline_check.py --annotate --output output.txt -c origin/${BASE_REF}.. |
| |
| - name: check-warns |
| run: | |
| if [[ -s "output.txt" ]]; then |
| echo "Coding guideline violations, annotated on the changed lines:" |
| cat output.txt |
| count=$(wc -l < output.txt) |
| echo "::error title=Coding guidelines::${count} coding guideline violation(s), see the annotations on the changed lines" |
| exit 1; |
| fi |