badges / badges/shields

docstr-coverage badge

Open
#5,339 1 comment 3 reactions 0 assignees View on GitHub
service-badge
Dominant language
JavaScript
Stars
27.2k
Forks
5.6k
Avg merge
1d 8h
Merged PRs (30d)
46

Description

:clipboard: **Description**

[docstr-coverage](https://github.com/HunterMcGushion/docstr_coverage) is a python package to get the documentation coverage for python projects.
This badge would show the total documentation coverage for the project (e.g. "docstr-coverage | 78% ") with a color gradient ranging from red to green based on the percentage.

:link: **Data**
This badge will use a Github CI Artifact as its data.
It will get the data from a Github CI artifact through the Github APIs V3 (json, not GraphQL, because the needed APIs are not supported yet in GraphQL).

The user will need to run `docstr-coverage` in a Github Workflow and upload the result as a build artifact on Github. A sample Workflow file can be found below
Github Workflow file

```yml
name: docs

on:
[push]

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Run documentation coverage
run: |
mkdir documentation-reports
docstr-coverage telereddit --percentage-only 2>&1 | tee ./documentation-reports/docstr-coverage.txt

- name: Upload documentation reports as artifact
uses: actions/upload-artifact@v2
with:
name: documentation-reports
path: ./documentation-reports/
```

The badge will:
- Get the artifacts list from the latest successful Github Workflow run ([Link to the sample API](https://api.github.com/repos/fabiosangregorio/telereddit/actions/workflows/docs.yml/runs?branch=master&status=success))
- Get the single artifact download URL from last call ([Link to the sample API](https://api.github.com/repos/fabiosangregorio/telereddit/actions/runs/173081036/artifacts))
- Download the zipped artifact and extract it
- Read the percentage from the coverage report and return it

:microphone: **Motivation**
`docstr-coverage` is a relatively small package so it doesn't offer a full online service from which to fetch the coverage data. This badge would provide a "serviceless" way to surface data to shields through artifacts, and could also be used for future badges.

Contributor guide

Open the contributing guide

Research direction

Start with the sample GitHub Actions workflow and the linked GitHub API responses for workflow runs and artifacts. Trace how a badge can select the latest successful run, download and extract its artifact, and read the coverage percentage. Done means the badge returns the percentage with a red-to-green gradient from the uploaded docstr-coverage report.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, github-actions, javascript
Domain
api, backend, devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.