diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index d713e117a..4dc1ae5ef 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -64,24 +64,6 @@ jobs: exit 1 fi - - name: "Checkstyle" - run: | - MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} ${{ env.MVN_SKIP_CI_PLUGINS }} -P!build-test-modules org.apache.maven.plugins:maven-checkstyle-plugin:checkstyle" - mvn $MVN_ARGS - python .pipeline/scripts/print-checkstyle.py - - - name: "PMD" - run: | - MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} ${{ env.MVN_SKIP_CI_PLUGINS }} org.apache.maven.plugins:maven-pmd-plugin:pmd" - mvn $MVN_ARGS - python .pipeline/scripts/print-pmd.py - - - name: "Spotbugs" - run: | - MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} ${{ env.MVN_SKIP_CI_PLUGINS }} com.github.spotbugs:spotbugs-maven-plugin:spotbugs" - mvn $MVN_ARGS - python .pipeline/scripts/print-spotbugs.py - - name: "Run Unit Tests" run: | MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report" diff --git a/.pipeline/config.yml b/.pipeline/config.yml index af7ac32f7..ee5d1d714 100644 --- a/.pipeline/config.yml +++ b/.pipeline/config.yml @@ -7,19 +7,4 @@ steps: mavenExcludedScopes: ["provided", "test"] failOn: ['BLOCKER', 'CRITICAL', 'MAJOR'] versioningModel: "major" - detectTools: ['DETECTOR', 'BINARY_SCAN'] - -stages: - codeCheck: - checkstyle: - high: '0' - normal: '0' - low: '0' - spotbugs: - high: '0' - normal: '0' - low: '0' - pmd: - high: '0' - normal: '0' - low: '0' + detectTools: ['DETECTOR', 'BINARY_SCAN'] \ No newline at end of file diff --git a/.pipeline/scripts/print-checkstyle.py b/.pipeline/scripts/print-checkstyle.py deleted file mode 100755 index 5e4349e62..000000000 --- a/.pipeline/scripts/print-checkstyle.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import glob -import yaml -import xml.etree.ElementTree as ET - -findings = { - 'info': 0, - 'warning': 0, - 'error': 0 -} - -config = None -with open(".pipeline/config.yml", "r") as stream: - try: - config = yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) - -threshold_low = int(config['stages']['codeCheck']['checkstyle']['low']) -threshold_normal = int(config['stages']['codeCheck']['checkstyle']['normal']) -threshold_high = int(config['stages']['codeCheck']['checkstyle']['high']) - -all_checkstyle_report_files = glob.glob('**/checkstyle-result.xml', recursive=True) -for checkstyle_report_file in all_checkstyle_report_files: - if os.path.isfile(checkstyle_report_file): - parsed_checkstyle_report = ET.parse(checkstyle_report_file) - checkstyle_report = parsed_checkstyle_report.getroot() - for sdk_source_file in checkstyle_report: - if sdk_source_file.find('error') is not None: - print(f"File: .{sdk_source_file.attrib['name'].removeprefix(os.getcwd())}") - for error in sdk_source_file: - findings[error.attrib['severity']] += 1 - print(f" - Rule: {error.attrib['source']}") - print(f" Severity: {error.attrib['severity']}") - print(f" Message: {error.attrib['message']}") - print(f" Line: {error.attrib['line']}") - print() - -allowed_high = threshold_high if threshold_high >= 0 else 'unlimited' -allowed_normal = threshold_normal if threshold_normal >= 0 else 'unlimited' -allowed_low = threshold_low if threshold_low >= 0 else 'unlimited' - -if 'GITHUB_STEP_SUMMARY' in os.environ: - with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: - print('## Checkstyle Result', file=f) - print('| Category | Actual Findings | Allowed Findings |', file=f) - print('| -------- | --------------- | ---------------- |', file=f) - print(f"| High | {findings['error']} | {allowed_high} |", file=f) - print(f"| Normal | {findings['warning']} | {allowed_normal} |", file=f) - print(f"| Low | {findings['info']} | {allowed_low} |", file=f) - -print('Checkstyle result:') -print(f"warnings high: {findings['error']}, allowed are {allowed_high}") -print(f"warnings normal: {findings['warning']}, allowed are {allowed_normal}") -print(f"warnings low: {findings['info']}, allowed are {allowed_low}") - -if threshold_high >= 0 and findings['error'] > threshold_high: - sys.exit('Checkstyle exceeded threshold for high findings') -elif threshold_normal >= 0 and findings['warning'] > threshold_normal: - sys.exit('Checkstyle exceeded threshold for normal findings') -elif threshold_low >= 0 and findings['info'] > threshold_low: - sys.exit('Checkstyle exceeded threshold for low findings') \ No newline at end of file diff --git a/.pipeline/scripts/print-pmd.py b/.pipeline/scripts/print-pmd.py deleted file mode 100755 index c13e84ae0..000000000 --- a/.pipeline/scripts/print-pmd.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import glob -import yaml -import xml.etree.ElementTree as ET - -# 1 is highest, 5 is lowest, cf https://pmd.sourceforge.io/pmd-5.3.3/customizing/rule-guidelines.html -findings = { - '1': 0, - '2': 0, - '3': 0, - '4': 0, - '5': 0, -} - -config = None -with open(".pipeline/config.yml", "r") as stream: - try: - config = yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) - -threshold_high = int(config['stages']['codeCheck']['pmd']['high']) -threshold_normal = int(config['stages']['codeCheck']['pmd']['normal']) -threshold_low = int(config['stages']['codeCheck']['pmd']['low']) - -all_pmd_report_files = glob.glob('**/pmd.xml', recursive=True) -for pmd_report_file in all_pmd_report_files: - if os.path.isfile(pmd_report_file): - parsed_pmd_report = ET.parse(pmd_report_file) - pmd_report = parsed_pmd_report.getroot().findall('{http://pmd.sourceforge.net/report/2.0.0}file') - for sdk_source_file in pmd_report: - print(f"File: .{sdk_source_file.attrib['name'].removeprefix(os.getcwd())}") - for violation in sdk_source_file.findall('{http://pmd.sourceforge.net/report/2.0.0}violation'): - ET.dump(violation) - findings[str(violation.attrib['priority'])] += 1 - print(f" - Rule: {violation.attrib['rule']}") - print(f" Priority: {violation.attrib['priority']}") - print(f" Message: {violation.text.strip()}") - print(f" Line: {violation.attrib['beginline']}") - print() - -high_findings = findings['1'] + findings['2'] -normal_findings = findings['3'] -low_findings = findings['4'] + findings['5'] - -allowed_high = threshold_high if threshold_high >= 0 else 'unlimited' -allowed_normal = threshold_normal if threshold_normal >= 0 else 'unlimited' -allowed_low = threshold_low if threshold_low >= 0 else 'unlimited' - -if 'GITHUB_STEP_SUMMARY' in os.environ: - with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: - print('## PMD Result', file=f) - print('| Category | Actual Findings | Allowed Findings |', file=f) - print('| -------- | --------------- | ---------------- |', file=f) - print(f"| High | {high_findings} | {allowed_high} |", file=f) - print(f"| Normal | {normal_findings} | {allowed_normal} |", file=f) - print(f"| Low | {low_findings} | {allowed_low} |", file=f) - -print('pmd result:') -print(f"warnings high: {high_findings}, allowed are {allowed_high}") -print(f"warnings normal: {normal_findings}, allowed are {allowed_normal}") -print(f"warnings low: {low_findings}, allowed are {allowed_low}") - -if threshold_high >= 0 and high_findings > threshold_high: - sys.exit('PMD exceeded threshold for high findings') -elif threshold_normal >= 0 and normal_findings > threshold_normal: - sys.exit('PMD exceeded threshold for normal findings') -elif threshold_low >= 0 and low_findings > threshold_low: - sys.exit('PMD exceeded threshold for low findings') diff --git a/.pipeline/scripts/print-spotbugs.py b/.pipeline/scripts/print-spotbugs.py deleted file mode 100755 index 87b7c712d..000000000 --- a/.pipeline/scripts/print-spotbugs.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import glob -import yaml -import xml.etree.ElementTree as ET - -findings = { - '1': 0, - '2': 0, - '3': 0, -} - -config = None -with open(".pipeline/config.yml", "r") as stream: - try: - config = yaml.safe_load(stream) - except yaml.YAMLError as exc: - print(exc) - -threshold_low = int(config['stages']['codeCheck']['spotbugs']['low']) -threshold_normal = int(config['stages']['codeCheck']['spotbugs']['normal']) -threshold_high = int(config['stages']['codeCheck']['spotbugs']['high']) - - -all_spotbugs_report_files = glob.glob('**/spotbugsXml.xml', recursive=True) -for spotbugs_report_file in all_spotbugs_report_files: - if os.path.isfile(spotbugs_report_file): - - parsed_spotbugs_report = ET.parse(spotbugs_report_file) - spotbugs_report = parsed_spotbugs_report.getroot() - - for bugInstance in spotbugs_report.findall('.//BugInstance'): - findings[str(bugInstance.get('priority'))] += 1 - if bugInstance.get('priority') == '1': - print(' - Bug Type:', bugInstance.get('type')) - print(' Bug Category:', bugInstance.get('category')) - print(' Bug Priority:', bugInstance.get('priority')) - print(' Bug Message:', bugInstance.find('LongMessage').text) - print(' Source File:', bugInstance.find('SourceLine').get('sourcefile')) - print(' Source Line Number:', bugInstance.find('SourceLine').get('start')) - print() - -allowed_high = threshold_high if threshold_high >= 0 else 'unlimited' -allowed_normal = threshold_normal if threshold_normal >= 0 else 'unlimited' -allowed_low = threshold_low if threshold_low >= 0 else 'unlimited' - -if 'GITHUB_STEP_SUMMARY' in os.environ: - with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: - print('## Spotbugs Result', file=f) - print('| Category | Actual Findings | Allowed Findings |', file=f) - print('| -------- | --------------- | ---------------- |', file=f) - print(f"| High | {findings['1']} | {allowed_high} |", file=f) - print(f"| Normal | {findings['2']} | {allowed_normal} |", file=f) - print(f"| Low | {findings['3']} | {allowed_low} |", file=f) - -print('Spotbugs result:') -print(f"warnings high: {findings['1']}, allowed are {allowed_high}") -print(f"warnings normal: {findings['2']}, allowed are {allowed_normal}") -print(f"warnings low: {findings['3']}, allowed are {allowed_low}") - -if threshold_high >= 0 and findings['1'] > threshold_high: - sys.exit('Spotbugs exceeded threshold for high findings') -elif threshold_normal >= 0 and findings['2'] > threshold_normal: - sys.exit('Spotbugs exceeded threshold for normal findings') -elif threshold_low >= 0 and findings['3'] > threshold_low: - sys.exit('Spotbugs exceeded threshold for low findings')