Commit 16396cb3 authored by Fulcrand Guilhem's avatar Fulcrand Guilhem
Browse files

Merge branch '79-job-super_linter-enhance-junit-report' into 'latest'

Resolve "[Job super_linter]  enhance junit report"

Closes #79

See merge request r2devops/hub!95
parents 5b59ca4e f71f406b
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ customize its behavior.
| **FILTER_REGEX_INCLUDE**          | Regular expression defining which files will be processed by linters (ex: `.*src/.*`)                                                                                      | `all`                |
| **LOG_LEVEL**                     | How much output the script will generate to the console. One of `VERBOSE`, `DEBUG` or `TRACE`.                                                                             | `VERBOSE`            |
| **MULTI_STATUS**                  | A status API is made for each language that is linted to make visual parsing easier.                                                                                       | `true`               |
| **REPORT_SUITE_TEST_NAME**        | Name of test suite inside test report                   | `super_linter`       |

#### Linters configuration

@@ -197,9 +198,5 @@ customize its behavior.

### Artifacts

!!! warning
    Currently, the report in merge request widget doesn't display details on
    issues found, they are only described in the job output log.

We use [Junit](https://junit.org/junit5/){:target="_blank"}'s XML report to display error report
directly in pipeline `Test` tab and in merge request widget.
+12 −4
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ stages:
super_linter:
  stage: static_tests
  image:
    name: github/super-linter:v3
    name: github/super-linter:v3.14.3
    entrypoint: [""]
  script:
    - /action/lib/linter.sh
@@ -15,18 +15,26 @@ super_linter:
    - mkdir ${CONVERTED_OUTPUT_FOLDER}
    - cd $OUTPUT_FOLDER
    - for report in *; do
    -     cat $report | tap-junit > ../${CONVERTED_OUTPUT_FOLDER}/${report}.xml
    -     'sed -i "s/message: \*\+/message: /g" $report' # workaround for https://github.com/dhershman1/tap-junit/issues/30#issuecomment-744462006
    -     cat $report | tap-junit -p -s "${REPORT_SUITE_TEST_NAME}" > ../${CONVERTED_OUTPUT_FOLDER}/${report}.xml # convert each tap file to junit xml
    -     sed -i 's/<failure message="\(.\+\)" type="fail">.*/<failure message="" type="fail">\n\1\n<\/failure>/g' ../${CONVERTED_OUTPUT_FOLDER}/${report}.xml # extract message to improve report display
    -     sed -i 's/\\n/\n/g' ../${CONVERTED_OUTPUT_FOLDER}/${report}.xml # add real newlines
    -     sed -i ':begin;$!N;s/<\/failure>\n<\/failure>/<\/failure>/;tbegin;P;D' ../${CONVERTED_OUTPUT_FOLDER}/${report}.xml # remove double </failure> that break the syntax in some reports
    - done
  variables:
    RUN_LOCAL: "true"
    DEFAULT_WORKSPACE: $CI_PROJECT_DIR
    DEFAULT_BRANCH: $CI_DEFAULT_BRANCH
    OUTPUT_FORMAT: "tap"
    OUTPUT_DETAILS: "detailed"
    OUTPUT_FOLDER: "super-linter.report"
    CONVERTED_OUTPUT_FOLDER: "converted-xml.report"
    TAP_JUNIT_VERSION: "3.1.2"
    TAP_JUNIT_VERSION: "4.0.0"
    REPORT_SUITE_TEST_NAME: "super_linter"
  artifacts:
    paths:
      - "${OUTPUT_FOLDER}/*.tap"
    when: always
    reports:
      junit: "${CONVERTED_OUTPUT_FOLDER}/*.xml"
    expire_in: 30 days
  allow_failure: true
+4 −0
Original line number Diff line number Diff line
* Improve MR report by providing detailed information about issues found
* Upgrade super-linter to version v3.14.3
* Provide `tap` output files as artifacts
* Improve output with newlines in report integration