hpc-threshold: Small utility for validating whether HPC result is above defined thresholds

[ bsd3, development, library, program ] [ Propose Tags ] [ Report a vulnerability ]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), bytestring, hpc-threshold, interpolate, pcre-heavy [details]
License BSD-3-Clause
Copyright 2018 Ecky Putrady
Author Ecky Putrady
Maintainer eckyputrady@gmail.com
Category Development
Home page https://github.com/eckyputrady/hpc-threshold#readme
Bug tracker https://github.com/eckyputrady/hpc-threshold/issues
Source repo head: git clone https://github.com/eckyputrady/hpc-threshold
Uploaded by eckyputrady at 2018-04-23T11:55:50Z
Distributions NixOS:0.1.0.3
Executables hpc-threshold
Downloads 2278 total (14 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-04-29 [all 1 reports]

Readme for hpc-threshold-0.1.0.0

[back to package description]

hpc-threshold

This is a small utility for validating whether HPC result is above some defined thresholds. This program is meant to be used within a CI pipeline, in which the build will fail if the code coverage falls below the thresholds.

The program reads a configuration file named .hspec-threshold and parse HPC text from stdin. The program outputs a report and will terminate with status code 1 if the coverage falls below threshold, and 0 otherwise.

User Guide

Install the utility by using stack

stack install hpc-threshold

Then, create a configuration file named .hspec-threshold:

[ Threshold 
    { thresholdName = "Expressions used"
    , thresholdRegex = "(\\d+)% expressions used"
    , thresholdValue = 80.0
    }
, Threshold 
    { thresholdName = "Boolean coverage"
    , thresholdRegex = "(\\d+)% boolean coverage"
    , thresholdValue = 80.0
    }
, Threshold 
    { thresholdName = "Alternatives used"
    , thresholdRegex = "(\\d+)% alternatives used"
    , thresholdValue = 80.0
    }
, Threshold 
    { thresholdName = "Local declarations used"
    , thresholdRegex = "(\\d+)% local declarations used"
    , thresholdValue = 80.0
    }
, Threshold 
    { thresholdName = "Top-level declarations used"
    , thresholdRegex = "(\\d+)% top-level declarations used"
    , thresholdValue = 80.0
    }
]
  • thresholdRegex is the regex to be used for extracting the coverage from HPC report. It requires 1 digit capture.
  • thresholdValue is the threshold for the code coverage.
  • thresholdName will be used for the threshold report

Then, build the coverage report:

stack test --coverage

Then, generate a text report and feed that into hpc-threshold:

(stack hpc report --all 2&>1) | hpc-threshold

The stderr -> stdout redirection is necessary there because stack hpc report outputs the result in stderr, but we want to pipe that into hpc-threshold.

Then, you'll get an output similar to the following:

Code coverage threshold check: FAIL
· Expressions used: 67.0% (< 80.0%)
· Boolean coverage: 14.0% (< 80.0%)
· Alternatives used: 42.0% (< 80.0%)
✓ Local declarations used: 88.0% (≥ 80.0%)
✓ Top-level declarations used: 80.0% (≥ 80.0%)

If we check the exit code of the last process, we'll get 1 since some coverage areas are below the configured threshold

$ echo $?
1

For successful scenario, the output that you'll get is as follows:

Code coverage threshold check: PASS
✓ Expressions used: 67.0% (≥ 60.0%)
✓ Boolean coverage: 14.0% (≥ 10.0%)
✓ Alternatives used: 42.0% (≥ 40.0%)
✓ Local declarations used: 88.0% (≥ 80.0%)
✓ Top-level declarations used: 80.0% (≥ 80.0%)

And the exit code is 0

$ echo $?
0