Skip to content

Commit 5f93047

Browse files
committed
Merge branch 'master' of https://github.com/dropseed/commitstat
* 'master' of https://github.com/dropseed/commitstat: Add go cover example and move links to paragraphs Update README.md Update README.md Update README.md Add example uses section to README More consistent language for new stat
2 parents e69f8bc + a6a294a commit 5f93047

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

README.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# commitstat
22

3-
A CI tool for reporting and comparing stats on commits. It can parse a stat from a file or stdin, check whether the number has increased or decreased, and then report a pass/fail status.
4-
5-
Can be used to check test coverage, typing coverage, file sizes, and more.
3+
A CI tool for reporting and comparing stats on commits and pull requests.
4+
It can parse a stat from a file or stdin,
5+
check whether the number has increased or decreased from the previous commit or main branch,
6+
and then report a pass/fail status on GitHub.
67

78
```console
89
$ commitstat coverage-report.txt --regex "\| Total\s*\|\s*([\d\.]+%)" --goal increase --name coverage
@@ -12,8 +13,19 @@ $ commitstat coverage-report.txt --regex "\| Total\s*\|\s*([\d\.]+%)" --goal inc
1213
$ stat -f %z app.zip | commitstat - --name app-size
1314
```
1415

16+
Can be used to check test coverage, typing coverage, file sizes, and more.
17+
The status can be purely informative, or be set as a required status check (via GitHub branch protection) to ensure that something like test coverage doesn't get worse because of a pull request.
18+
19+
This is a lightweight alternative to hosted services like [Codecov](https://about.codecov.io/) and [Coveralls](https://coveralls.io/).
20+
All of the data that commitstat uses is stored directly in the GitHub commit status and doesn't involve any third-party services or hosting.
21+
There aren't any visualization tools built-in but you can always store artifacts in your CI provider or look at coverage reports locally.
22+
23+
![commitstat-example](https://user-images.githubusercontent.com/649496/121426939-c166f100-c939-11eb-8061-f97cf0f10407.png)
24+
1525
## Quick install
1626

27+
You can install commitstat locally to test your parsing patterns, but commit statuses will only be created when run in CI.
28+
1729
```console
1830
$ curl https://rg.gosu.cc/dropseed/commitstat/master/install.sh | bash -s -- -b $HOME/bin
1931
```
@@ -44,3 +56,32 @@ jobs:
4456
env:
4557
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4658
```
59+
60+
## Example uses
61+
62+
### mypy
63+
64+
Parse the [mypy](https://mypy.readthedocs.io/en/stable/command_line.html#report-generation) imprecision text report (lower number is better).
65+
66+
```console
67+
$ mypy src --ignore-missing-imports --no-incremental --txt-report ./.reports/mypy
68+
$ commitstat .reports/mypy/index.txt --regex "\| Total\s*\|\s*([\d\.]+%)" --goal decrease --name mypy
69+
```
70+
71+
### pytest-cov
72+
73+
Parse the [pytest-cov](https://github.com/pytest-dev/pytest-cov) default HTML report for the total coverage percentage.
74+
75+
```console
76+
$ pytest --cov=src --cov-report=html:.reports/src/pytest src
77+
$ commitstat .reports/pytest/index.html --regex "<span class=\"pc_cov\">(\d+%)<\/span>" --goal increase --name pytest
78+
```
79+
80+
### Go test coverage
81+
82+
Parse total test coverage from the [built-in go coverage tool](https://blog.golang.org/cover).
83+
84+
```console
85+
$ go test ./... -coverprofile=coverage.out
86+
$ go tool cover -func coverage.out | commitstat - --regex "total:\s+\(statements\)\s+([\d\.]+%)" --name coverage
87+
```

internal/status/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func compareStats(stat, comparisonStat, goal string) (state, string, error) {
4141
// IMPORTANT: the current stat needs to be the first thing in the description
4242
// because that's how we will parse it back off
4343
if comparisonStat == "" {
44-
return stateSuccess, fmt.Sprintf("%s is the first value seen", stat), nil
44+
return stateSuccess, fmt.Sprintf("%s - nothing to compare to", stat), nil
4545
}
4646

4747
statNum, err := parse.ParseStatNumber(stat)

0 commit comments

Comments
 (0)