Compare commits

...

2 Commits

Author SHA1 Message Date
Bartosz Podrygajlo
dfbbb4d654 testing ci 2024-09-05 14:16:59 +02:00
Bartosz Podrygajlo
0af4b18fd1 Add clang-format-diff to cls_static_code_analysis.py
Updated docker image base for oai-formatting-check from ubuntu 18 to ubuntu 22
to access clang-format-diff present in clang-format package.
2024-09-05 14:15:32 +02:00
2 changed files with 25 additions and 4 deletions

View File

@@ -244,14 +244,21 @@ class StaticCodeAnalysis():
logDir = f'{lSourcePath}/cmake_targets/build_log_{self.testCase_id}'
cmd.run(f'mkdir -p {logDir}')
cmd.run('docker image rm oai-formatting-check:latest')
cmd.run(f'docker build --target oai-formatting-check --tag oai-formatting-check:latest {check_options} --file {lSourcePath}/ci-scripts/docker/Dockerfile.formatting.bionic {lSourcePath} > {logDir}/oai-formatting-check.txt 2>&1')
cmd.run(f'docker build --target oai-formatting-check --tag oai-formatting-check:latest {check_options} --file {lSourcePath}/ci-scripts/docker/Dockerfile.formatting.ubuntu22 {lSourcePath} > {logDir}/oai-formatting-check.txt 2>&1')
if self.ranAllowMerge:
diff_command = f'$(git merge-base {self.ranBranch} {self.ranTargetBranch if self.ranTargetBranch else "origin/develop"})'
logging.debug(diff_command)
cmd.run(f'docker run --rm oai-formatting-check:latest bash -c "{diff_command}" > {logDir}/clang-format-check-1.txt 2>&1')
clang_format_diff_cmd = f'git diff --unified=0 --no-color {diff_command}...{self.ranBranch} | clang-format-diff -p1'
cmd.run(f'docker run --rm oai-formatting-check:latest bash -c "{clang_format_diff_cmd}" > {logDir}/clang-format-check.txt 2>&1')
cmd.run('docker image rm oai-formatting-check:latest')
cmd.run('docker image prune --force')
cmd.run('docker volume prune --force')
# Analyzing the logs
cmd.copyin(f'{logDir}/oai-formatting-check.txt', 'oai-formatting-check.txt')
cmd.copyin(f'{logDir}/clang-format-check.txt', 'clang-format-check.txt')
cmd.copyin(f'{logDir}/clang-format-check.txt', 'clang-format-check-1.txt')
cmd.close()
finalStatus = 0
@@ -356,4 +363,17 @@ class StaticCodeAnalysis():
HTML.htmleNBFailureMsg = 'Could not access oai-formatting-check.txt file'
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE)
if self.ranAllowMerge:
if (os.path.isfile('./clang-format-check.txt')):
num_lines = 0
with open('./clang-format-check.txt', 'r') as logfile:
for line in logfile:
num_lines += 1
if num_lines != 0:
HTML.CreateHtmlTestRowQueue('clang-format errors', 'OK', [f'non-emtpy error file: num lines {num_lines}'])
else:
finalStatus = -1
HTML.htmleNBFailureMsg = 'Could not access clang-format-check.txt file'
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE)
return finalStatus

View File

@@ -25,7 +25,7 @@
#
#---------------------------------------------------------------------
FROM ubuntu:bionic AS oai-formatting-check
FROM ubuntu:22.04 as oai-formatting-check
ARG MERGE_REQUEST
ARG SRC_BRANCH
@@ -36,7 +36,8 @@ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
gawk \
git
git \
clang-format
WORKDIR /oai-ran
COPY . .