CI: clean-up check on check compliance test

- Rebase check_compliance.py and compliance.yml from zephyr project
- Fix checkpatch subprocess command.
- rebase

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
This commit is contained in:
Arnaud Pouliquen
2022-04-11 09:20:37 +02:00
committed by Arnaud Pouliquen
parent 695d29ba60
commit 78acf765c5
2 changed files with 18 additions and 39 deletions
+14 -26
View File
@@ -22,6 +22,7 @@ jobs:
pip3 install junitparser==1.6.3 gitlint
- uses: actions/checkout@v1
- name: Run Compliance Tests
continue-on-error: true
id: compliance
env:
BASE_REF: ${{ github.base_ref }}
@@ -31,7 +32,6 @@ jobs:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git rebase origin/${BASE_REF}
export
./scripts/ci/check_compliance.py -m checkpatch -m Gitlint -m Identity -c origin/${BASE_REF}..
- name: upload-results
@@ -46,30 +46,18 @@ jobs:
if [[ ! -s "compliance.xml" ]]; then
exit 1;
fi
if [ -s checkpatch.txt ]; then
errors=$(cat checkpatch.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Checkpatch.txt::$errors"
exit=1
fi
if [ -s Identity.txt ]; then
errors=$(cat Identity.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Identity.txt::$errors"
exit=1
fi
if [ -s Gitlint.txt ]; then
errors=$(cat Gitlint.txt)
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::error file=Gitlint.txt::$errors"
exit=1
fi
if [ ${exit} == 1 ]; then
for file in checkpatch.txt Identity.txt Gitlint.txt; 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=1
fi
done
if [ "${exit}" == "1" ]; then
exit 1;
fi
+4 -13
View File
@@ -9,9 +9,9 @@ import subprocess
import re
import os
from email.utils import parseaddr
from junitparser import TestCase, TestSuite, JUnitXml, Skipped, Error, Failure, Attr
import logging
import argparse
from junitparser import TestCase, TestSuite, JUnitXml, Skipped, Error, Failure, Attr
import tempfile
import traceback
from pathlib import Path
@@ -24,10 +24,6 @@ EDIT_TIP = "\n\n*Tip: The bot edits this comment instead of posting a new " \
logger = None
# This ends up as None when we're not running in a Zephyr tree
ZEPHYR_BASE = os.environ.get('ZEPHYR_BASE')
def git(*args, cwd=None):
# Helper for running a Git command. Returns the rstrip()ed stdout output.
# Called like git("diff"). Exits with SystemError (raised by sys.exit()) on
@@ -189,8 +185,7 @@ class CheckPatch(ComplianceTest):
path_hint = "<git-top>"
def run(self):
# Default to Zephyr's checkpatch if ZEPHYR_BASE is set
checkpatch = os.path.join(ZEPHYR_BASE or GIT_TOP, 'scripts',
checkpatch = os.path.join(GIT_TOP, 'scripts',
'checkpatch.pl')
if not os.path.exists(checkpatch):
self.skip(checkpatch + " not found")
@@ -199,18 +194,14 @@ class CheckPatch(ComplianceTest):
diff = subprocess.Popen(('git', 'diff', COMMIT_RANGE),
stdout=subprocess.PIPE)
try:
subprocess.check_output((checkpatch, '--mailback', '--no-tree', '-'),
subprocess.check_output(checkpatch + ' --mailback' + ' --no-tree' + ' -',
stdin=diff.stdout,
stderr=subprocess.STDOUT,
shell=True, cwd=GIT_TOP)
except subprocess.CalledProcessError as ex:
output = ex.output.decode("utf-8")
if re.search("[1-9][0-9]* errors,", output):
self.add_failure(output)
else:
# No errors found, but warnings. Show them.
self.add_info(output)
self.add_failure(output)
class GitLint(ComplianceTest):