This is a small project that will allow for easily calculating stats for all repos across an organization, or a single repository of interest. Other metrics could be added for other entities beyond repository health too!
To build the library:
$ makeThis will compile an executable, codestats that you can interact with.
$ ./codestats repo buildsi/build-abi-containersYou can also save to file:
$ ./codestats repo buildsi/build-abi-containers --outfile examples/repo.jsonYou can also pretty print json:
$ go run main.go repo buildsi/build-abi-containers --pretty
build-abi-containers
[
{
"Stats": [
{
"Name": "Has-Codeowners",
"Pass": false
},
{
"Name": "Has-Maintainers",
"Pass": false
},
{
"Name": "Has-GitHub-Actions",
"Pass": true
},
{
"Name": "Has-CircleCI",
"Pass": false
},
{
"Name": "Has-Travis",
"Pass": false
},
{
"Name": "Has-PullApprove",
"Pass": false
},
{
"Name": "Has-Glide",
"Pass": false
},
{
"Name": "Has-Code-Of-Conduct",
"Pass": false
},
{
"Name": "Has-Contributing",
"Pass": false
},
{
"Name": "Has-Authors",
"Pass": false
},
{
"Name": "Has-Pull-Request-Template",
"Pass": false
},
{
"Name": "Has-Issue-Template",
"Pass": false
},
{
"Name": "Has-Support.md",
"Pass": false
},
{
"Name": "Has-Funding",
"Pass": false
},
{
"Name": "Has-Security",
"Pass": false
}
],
"Name": "buildsi/build-abi-containers",
"Branch": "main",
"Url": "https://github.com/buildsi/build-abi-containers",
"Stars": 2,
"Forks": 1,
"Issues": 3,
"Language": "Python",
"Archived": false,
"CreatedAt": "2021-05-23T20:02:51Z",
"UpdatedAt": "2021-10-16T12:37:19Z"
}
]If you want to get stats for an org:
$ ./codestats org buildsi
build-notes
build-si-modeling
Smeagle
build-abi-tests
build-abi-containers
build-sandbox
...You can also add an optional skip pattern to say - "Don't parse repos that match this regular expression!"
$ go run main.go org spack --skip spack-search --output example/spack.jsonYou can also add an optional pattern to only parse a subset of repos, or add --pretty to pretty print the json.
$ go run main.go org buildsi --pattern build-abi-containers --pretty
build-abi-containers
build-abi-containers-results
{
{
"Stats": [
{
"Name": "Has-Codeowners",
"Pass": false
},
{
"Name": "Has-Maintainers",
"Pass": false
},
{
"Name": "Has-GitHub-Actions",
"Pass": true
},
{
"Name": "Has-CircleCI",
"Pass": false
},
{
"Name": "Has-Travis",
"Pass": false
},
{
"Name": "Has-PullApprove",
"Pass": false
},
{
"Name": "Has-Glide",
"Pass": false
}
],
"Name": "buildsi/build-abi-containers",
"Branch": "main",
"Url": "https://github.com/buildsi/build-abi-containers",
"Stars": 2,
"Forks": 1,
"Issues": 3,
"Language": "Python",
"Archived": false,
"CreatedAt": "2021-05-23T20:02:51Z",
"UpdatedAt": "2021-10-16T12:37:19Z"
},
{
"Stats": [
{
"Name": "Has-Codeowners",
"Pass": false
},
{
"Name": "Has-Maintainers",
"Pass": false
},
{
"Name": "Has-GitHub-Actions",
"Pass": true
},
{
"Name": "Has-CircleCI",
"Pass": false
},
{
"Name": "Has-Travis",
"Pass": false
},
{
"Name": "Has-PullApprove",
"Pass": false
},
{
"Name": "Has-Glide",
"Pass": false
}
],
"Name": "buildsi/build-abi-containers-results",
"Branch": "main",
"Url": "https://github.com/buildsi/build-abi-containers-results",
"Stars": 1,
"Forks": 0,
"Issues": 0,
"Language": "Python",
"Archived": false,
"CreatedAt": "2021-06-08T23:44:24Z",
"UpdatedAt": "2021-08-29T14:25:50Z"
}
}or again, save to output file:
$ go run main.go org buildsi --outfile examples/org.jsonThe output file is the same format, so you can use the same visualization code in docs for a web interface.
For either the org or repo command, you can provide an optional yaml file to define a list of stats you want:
$ go run main.go repo buildsi/build-abi-containers --config examples/all-stats.yaml There is also an example file with known GitHub health stats
$ go run main.go repo buildsi/build-abi-containers --config examples/health-stats.yamlOr save to output file, perhaps for a web interface!
$ go run main.go org buildsi --outfile examples/data.json And finally, if you don't want to use a config file and want a quick run of one or more metrics, ask for them on the fly with --metric
$ go run main.go repo spack/spack --metric has-code-of-conduct
$ go run main.go repo spack/spack --metric has-code-of-conduct,has-fundingWhen you generate stats, you can put them in the same directory as the provided docs to generate a nice interface, which will be organized by type and repository. You can see an example at https://vsoch.github.io/codestats
The repository also serves a GitHub action! You can run extractions with the same variables, for either an organization or a repository.
name: Codestats Test
on:
pull_request: []
push:
branches:
- main
jobs:
extract-repo:
runs-on: ubuntu-latest
name: Repository Stats
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Codestats for a repository
uses: vsoch/codestats@main
with:
repository: spack/spack
metric: has-code-of-conduct
outfile: spack.json
- name: View Outfile
run: cat spack.json
extract-org:
runs-on: ubuntu-latest
name: Org Stats
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Codestats for an organization
uses: vsoch/codestats@main
with:
org: spack
metric: has-code-of-conduct
pattern: spack-tutorial
outfile: spack-tutorial.json
- name: View Outfile
run: cat spack-tutorial.jsonThe above is a basic example, for each of a repository and an org, and you can see variables in the action.yml. Please don't hesitate to open an issue to ask a question or request better documentation.
So what else would you like to see? Additional stats or interface support? Please open an issue and let me know!
- IDEA: should there be a common format for a stat, beyond hard coding? E.g., most seem like checking if something exists - this could be YAML
This was inspired by bloodorange/oci-stats!
