51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
name: 'Go Coverage Processor'
|
|
description: 'Process Go test coverage files and generate reports'
|
|
|
|
inputs:
|
|
test-type:
|
|
description: 'Type of test (e.g., be-unit, be-integration)'
|
|
required: true
|
|
type: string
|
|
coverage-file:
|
|
description: 'Path to the Go coverage file (.cov)'
|
|
required: true
|
|
type: string
|
|
codecov-token:
|
|
description: 'Token for CodeCov (required for CodeCov reporting)'
|
|
required: false
|
|
default: ''
|
|
codecov-flag:
|
|
description: 'Flag to categorize the upload to CodeCov'
|
|
required: false
|
|
default: ''
|
|
codecov-name:
|
|
description: 'Custom name for the upload to CodeCov'
|
|
required: false
|
|
default: ''
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Process Go coverage output
|
|
shell: bash
|
|
env:
|
|
COVERAGE_FILE: ${{ inputs.coverage-file }}
|
|
run: |
|
|
# Ensure valid coverage file even if empty
|
|
if [ ! -s "$COVERAGE_FILE" ]; then
|
|
echo "Coverage file is empty, creating a minimal valid file"
|
|
echo "mode: set" > "$COVERAGE_FILE"
|
|
fi
|
|
|
|
- name: Report coverage to CodeCov
|
|
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5
|
|
if: inputs.codecov-token != ''
|
|
with:
|
|
files: ${{ inputs.coverage-file }}
|
|
flags: ${{ inputs.codecov-flag || inputs.test-type }}
|
|
name: ${{ inputs.codecov-name || inputs.test-type }}
|
|
slug: grafana/grafana
|
|
# This URL doesn't use the Google auth, but is much more locked down. As such, it requires OIDC or a CodeCov-provided token to do anything.
|
|
url: https://codecov-webhook.grafana-dev.net
|
|
token: ${{ inputs.codecov-token }}
|