|
| 1 | +# free-code-coverage (UPDATE-GITHUB-REPO) |
| 2 | + |
| 3 | +- This action uses a public GitHub repository to persist code coverage data between runs. |
| 4 | +- This is a truly free of charge alternative to the default one using an AWS S3 bucket. |
| 5 | +- Downside is that all code coverage data must be public to allow badges to be read. |
| 6 | + |
| 7 | +## Sample Usage |
| 8 | + |
| 9 | +``` |
| 10 | +on: |
| 11 | + pull_request: |
| 12 | + types: [labeled, unlabeled, closed] |
| 13 | +
|
| 14 | +jobs: |
| 15 | + update: |
| 16 | + runs-on: ubuntu-latest |
| 17 | +
|
| 18 | + steps: |
| 19 | + - uses: SamuelCabralCruz/free-code-coverage/[email protected] |
| 20 | + with: |
| 21 | + github-repo: <github-repo> |
| 22 | + project-name: <project-name> |
| 23 | + env: |
| 24 | + GITHUB_TOKEN: ${{ secrets.PAT }} |
| 25 | +``` |
| 26 | +> This can easily be adapted using a matrix strategy when using the action for multiple projects inside same repository. |
| 27 | +
|
| 28 | +### Environment Variables |
| 29 | + |
| 30 | +- GITHUB_TOKEN |
| 31 | + - Personal Access Token (PAT) which has read/write access to both repository this action is used in and |
| 32 | + the public repository used to persist code coverage data. |
| 33 | + > Need to enable all repo rights |
| 34 | +
|
| 35 | +### Inputs |
| 36 | + |
| 37 | +- github-repo |
| 38 | + - Public GitHub repository name following the following format {owner}/{repo} |
| 39 | + used to persist code coverage data between runs. |
| 40 | +- project-name |
| 41 | + - Lower kebab case string (lower-kebab-case-string) allowing to store action's data from multiple |
| 42 | + projects/repositories without collisions in the same bucket. |
| 43 | +- bypass-label (optional - default: 'ignoreCoverage') |
| 44 | + - Label to be added to a pull request in order to bypass code coverage check. |
| 45 | + - This label might be useful to knowingly accept a decrease in coverage. |
| 46 | + - Make sure that if a custom value is used for the UPLOAD part, it is the same value provided here. |
| 47 | + |
| 48 | +## Badges |
| 49 | + |
| 50 | +To add badges to your `README` or any other Markdown file, you can simply copy/paste and fill in the template below: |
| 51 | + ```md |
| 52 | +  |
| 53 | + ``` |
| 54 | + - You will need to provide values for: |
| 55 | + - github-repo |
| 56 | + - project-name |
| 57 | + - branch-name |
| 58 | + - escaped-branch-name |
| 59 | + - For encoding reasons, need to replace any `/` by `-` in the branch name |
| 60 | + - Would normally be the name of your repository's default branch name `main` or `master`. |
| 61 | + - Could also be the name of a branch that is never destined to be closed (ex: `develop` if you use |
| 62 | + [Gitflow workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)). |
| 63 | + |
| 64 | +## Checks |
| 65 | + |
| 66 | +To enforce code coverage not to decrease, you simply have to modify your branch rules and add |
| 67 | +`Code Coverage - <project-name>` as a required check before merge. |
0 commit comments