From 8edf4b0e58c144d591736077a010e512cf51ab0d Mon Sep 17 00:00:00 2001 From: Paul Melnikov Date: Wed, 16 Mar 2022 16:46:56 +0700 Subject: [PATCH] Update README.md --- platformio2codecoverage/README.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/platformio2codecoverage/README.md b/platformio2codecoverage/README.md index befbbd1..0c858d5 100644 --- a/platformio2codecoverage/README.md +++ b/platformio2codecoverage/README.md @@ -1,5 +1,7 @@ # Converter of PlatformIO static analyzer reports into CodeClimate's JSON +Despite the name, it has nothing to do with code coverage. + Suitable for Gitlab CI/CD. You can use this image to convert `pio check --json` results into CodeClimate JSON results. @@ -11,33 +13,52 @@ The project is based on https://gitlab.com/ahogen/cppcheck-codequality cppcheck ## Example GitLab CI/CD file ``` + +.analyze_rules: &analyze_rules + rules: + - if: '$CODE_QUALITY_DISABLED' + when: never + - if: '$CI_PIPELINE_SOURCE == "web"' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Run code quality job in merge request pipelines + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # Run code quality job in pipelines on the master branch (but not in other branch pipelines) + - if: '$CI_COMMIT_TAG' + piocheck: stage: build image: name: registry.gitlab.com/positron96/dockerfiles/platformio:2021-08-30-8af189f0 entrypoint: [""] + <<: *analyze_rules + script: - pio check > pio.txt - pio check --json-output > pio.json + - echo $CI_PROJECT_DIR > basedir.txt artifacts: - paths: ["pio.json"] + # pio.txt can be removed altogether + paths: ["pio.json", "pio.txt", "basedir.txt"] code_quality: stage: test image: - name: registry.gitlab.com/positron96/dockerfiles/platformio2codecoverage:2021-08-11-e0fb4477 + name: registry.gitlab.com/positron96/dockerfiles/platformio2codecoverage:2021-08-30-571a9b3c entrypoint: [""] + <<: *analyse_rules + dependencies: [piocheck] script: - - piocheck-codecoverage.py -i pio.json -o codecoverage.json + - export BASEDIR=$(cat basedir.txt) + - piocheck-codecoverage.py -i pio.json -o codecoverage.json -s $BASEDIR artifacts: reports: codequality: codecoverage.json + paths: [codecoverage.json] + ``` * You need to run `pio check` twice as on the first run it will download the tool and will dump info about it on stdout, spoiling the resulting JSON. -The bug is reported here: https://github.com/platformio/platformio-core/issues/4029 \ No newline at end of file +The bug is reported here: https://github.com/platformio/platformio-core/issues/4029