Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
positron96 authored Mar 16, 2022
1 parent 6068e0e commit 8edf4b0
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions platformio2codecoverage/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
The bug is reported here: https://github.com/platformio/platformio-core/issues/4029

0 comments on commit 8edf4b0

Please sign in to comment.