Pin python dependencies to hashes and cleanup/unify python setup steps in various workflows. We now have one dependency file containing all requirements for github actions that is managed centrally with hashes. No direct pip installs are needed in workflow files and everything shall go via the requirements file. Pinning to specific version and hashes helps with preventing supply chain attacks. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
name: Coding Guidelines
|
|
|
|
on: pull_request
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
compliance_job:
|
|
runs-on: ubuntu-22.04
|
|
name: Run coding guidelines checks on patch series (PR)
|
|
steps:
|
|
- name: Checkout the code
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.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 --output output.txt -c origin/${BASE_REF}..
|
|
|
|
- name: check-warns
|
|
run: |
|
|
if [[ -s "output.txt" ]]; then
|
|
errors=$(cat output.txt)
|
|
errors="${errors//'%'/'%25'}"
|
|
errors="${errors//$'\n'/'%0A'}"
|
|
errors="${errors//$'\r'/'%0D'}"
|
|
echo "::error file=output.txt::$errors"
|
|
exit 1;
|
|
fi
|