From e14c14ed4a475a4c8d0c4b63adaf07122b6fe9b7 Mon Sep 17 00:00:00 2001 From: Tommi Rantanen Date: Mon, 22 Sep 2025 16:01:19 +0300 Subject: [PATCH] github: workflow: First version of compliance Adding content to workflow for running compliance on PRs. Signed-off-by: Tommi Rantanen --- .checkpatch.conf | 32 +++++++++ .github/workflows/compliance.yml | 107 +++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 .checkpatch.conf diff --git a/.checkpatch.conf b/.checkpatch.conf new file mode 100644 index 00000000..9715bdd2 --- /dev/null +++ b/.checkpatch.conf @@ -0,0 +1,32 @@ +--emacs +--summary-file +--show-types +--max-line-length=100 +--min-conf-desc-length=1 + +--ignore BRACES +--ignore PRINTK_WITHOUT_KERN_LEVEL +--ignore SPLIT_STRING +--ignore VOLATILE +--ignore CONFIG_EXPERIMENTAL +--ignore PREFER_KERNEL_TYPES +--ignore PREFER_SECTION +--ignore AVOID_EXTERNS +--ignore NETWORKING_BLOCK_COMMENT_STYLE +--ignore DATE_TIME +--ignore MINMAX +--ignore CONST_STRUCT +--ignore FILE_PATH_CHANGES +--ignore SPDX_LICENSE_TAG +--ignore C99_COMMENT_TOLERANCE +--ignore REPEATED_WORD +--ignore UNDOCUMENTED_DT_STRING +--ignore DT_SPLIT_BINDING_PATCH +--ignore DT_SCHEMA_BINDING_PATCH +--ignore TRAILING_SEMICOLON +--ignore COMPLEX_MACRO +--ignore MULTISTATEMENT_MACRO_USE_DO_WHILE +--ignore ENOSYS +--ignore IS_ENABLED_CONFIG +--ignore EMBEDDED_FUNCTION_NAME +--ignore MACRO_WITH_FLOW_CONTROL diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index e69de29b..84e362f5 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -0,0 +1,107 @@ +name: Compliance + +on: + pull_request: + +jobs: + compliance_job: + runs-on: ubuntu-24.04 + name: Run compliance checks on patch series (PR) + + # Skip job if it was triggered by Renovate Bot + if: ${{ !contains(github.actor, 'renovate') }} + + steps: + - name: Installation + run: | + apt-get update && apt-get install --no-install-recommends -y libmagic1 git + pip install west gitlint + + - name: Checkout the code + uses: actions/checkout@v4 + with: + path: serial_modem + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Initialize + working-directory: serial_modem + run: | + if [ ! -d "../.west" ]; then + west init -l . + else + echo ".west folder already exists, skipping west init." + fi + west update -o=--depth=1 -n + + - name: Install zephyr requirements + run: | + pip install -r zephyr/scripts/requirements-actions.txt + # Junitparser v3 and 4 don't work with check_compliance.py + pip install --upgrade junitparser==2.8.0 + + - name: Run Compliance Tests + id: compliance + shell: bash + env: + BASE_REF: ${{ github.base_ref }} + working-directory: serial_modem + run: | + export ZEPHYR_BASE="../zephyr" + $ZEPHYR_BASE/scripts/ci/check_compliance.py \ + --annotate \ + -m Codeowners \ + -m Devicetree \ + -m Gitlint \ + -m Identity \ + -m Nits \ + -m pylint \ + -m checkpatch \ + -c origin/${BASE_REF}.. || \ + echo "COMPLIANCE_FAILED=true" >> $GITHUB_ENV + + - name: Process Compliance Results + working-directory: serial_modem + shell: bash + run: | + # Check for compliance.xml existence + if [[ ! -s "compliance.xml" ]]; then + echo "::error::compliance.xml file is missing or empty" + exit 1 + fi + + # Initialize exit code + exit_code=0 + + # Define error files to check + error_files=( + "Nits.txt" + "checkpatch.txt" + "Identity.txt" + "Gitlint.txt" + "pylint.txt" + "Devicetree.txt" + "Kconfig.txt" + "KconfigBasic.txt" + "Codeowners.txt" + ) + + # Process each error file + for file in "${error_files[@]}"; do + if [[ -s $file ]]; then + errors=$(cat $file) + errors="${errors//'%'/'%25'}" + errors="${errors//$'\n'/'%0A'}" + errors="${errors//$'\r'/'%0D'}" + echo "::error file=${file}::$errors" + exit_code=1 + fi + done + + # Check if compliance test failed + if [[ "$COMPLIANCE_FAILED" == "true" ]]; then + echo "::error::Compliance tests failed. Please check the logs for details." + exit_code=1 + fi + + exit $exit_code