Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
paloaltonetworks

GitHub Action

paloaltonetworks/cov

1.0.0

paloaltonetworks/cov

paloaltonetworks

paloaltonetworks/cov

Very simple action to run code coverage checking for go projects

Installation

Copy and paste the following snippet into your .yml file.

              

- name: paloaltonetworks/cov

uses: PaloAltoNetworks/cov@1.0.0

Learn more about this action in PaloAltoNetworks/cov
Choose a version

Cov

Cov is a simple code coverage checker for golang. It's like codacy or codecov (at least regarding features that people actually want), but not SaaS in a few line of code. It can be used in a integration pipeline to validate pull request coverage.

This repository contains a github action that can be used directly with your github workflow (check below)

Installation

go install github.com/PaloAltoNetworks/cov@latest

Or you can get a release from the releases page.

Usage

Analyzes coverage

Usage:
  cov cover.out... [flags]

Flags:
  -b, --branch string    The branch to use to check the patch coverage against. Example: master
  -f, --filter strings   The filters to use for coverage lookup
  -h, --help             help for cov
  -i, --ignore strings   Define patterns to ignore matching files.
  -q, --quiet            Do not print details, just the verdict
  -t, --threshold int    The target of coverage in percent that is requested

When the --branch BASE is used a diff will be done between your current branch and the branch passed as base to identify the files you changed.

You can pass several coverage files, they all will be merged.

You can filter for a given package or any substring.

When --threshold X is set, the output will be colored given that target and the return will be 1 if target is not reached.

You can ignore files matching some patterns using the --ignore option:

Examples

Show coverage for all coverage files:

cov *.out

Show coverage for a pull request against master:

cov --branch master coverage.out

Ignore all files in autogen/api and examples:

cov --ignore "**/autogen/api/*" --ignore "**/examples/*" coverage.out

Note: Your pull branch must be aligned with latest change of the base branch

Github Action

You can use this repository as a Github Action for your workflows. You simply need to make sure one of your step generates a coverage file (usually using go test -coverprofile=coverage.out) then add a new step:

    name: build-go
    on:
      push:
        branches:
        - master
      pull_request:
    jobs:
      build:
        steps:
        - uses: actions/checkout@v3
        - uses: actions/setup-go@v3
        - name: test
          run: go test -coverprofile=coverage.out ./...
        - uses: PaloAltoNetworks/cov@master
          with:
            cov_version: latest
            cov_file: coverage.out
            cov_threshold: "70"
            main_branch: main

All parameters are optionals. The default values are shown below, but they can all be ommited if they are good enough for you.