-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathaction.yml
More file actions
137 lines (121 loc) · 5.11 KB
/
action.yml
File metadata and controls
137 lines (121 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: 'Go Unit Test Coverage Report'
description: 'Post Go code coverage reports to pull requests.'
author: "Friedrich Große"
branding:
icon: 'umbrella'
color: 'blue'
inputs:
version:
description: 'The exact version tag of the go-coverage-report tool to use.'
required: true
default: "v1.3.0"
sha256sum:
description: 'Optional SHA256 checksum of the tarball when downloading the go-coverage-report binary.'
required: false
coverage-artifact-name:
description: 'The name of the artifact containing the code coverage results.'
required: true
default: "code-coverage"
coverage-file-name:
description: 'The name of the file containing the code coverage results.'
required: true
default: "coverage.txt"
root-package:
description: |
The Go import path of the tested repository to add as a prefix to all paths of the
changed files. This is useful to map the changed files (e.g., ["foo/my_file.go"]
to their coverage profile which uses the full package name to identify the files
(e.g., "github.com/fgrosse/example/foo/my_file.go"). Note that currently,
packages with a different name than their directory are not supported.
required: false
default: "github.com/${{ github.repository }}"
skip-comment:
description: |
Skip creating or updating the pull request comment. This may be useful when you want
to generate the coverage report and modify it in your own scripts.
required: false
default: 'false'
trim:
description: Trim a prefix in the "Impacted Packages" column of the markdown report.
required: false
exclude:
description: Exclude files matching the given regular expression from the report.
required: false
github-baseline-workflow-ref:
description: |
The ref of the GitHub actions Workflow that produces the baseline coverage.
By default, the GitHub Actions Workflow ref is used
(e.g. "octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch").
You can aso just pass the name of the Workflow file directly (e.g. "my-workflow.yml").
default: ${{ github.workflow_ref }}
required: false
event-name:
description: "The event that triggered the workflow used to filter baseline runs."
default: "push"
required: false
target-branch:
description: |
The base branch to compare the coverage results against.
Defaults to github.base_ref, which is only set on pull_request events.
For other event types (e.g. push, schedule), set this explicitly.
default: ${{ github.base_ref }}
required: false
outputs:
coverage_report:
description: 'The generated coverage report in Markdown format.'
value: ${{ steps.coverage.outputs.coverage_report }}
total_coverage:
description: 'New overall test coverage percentage (e.g. "85.23").'
value: ${{ steps.coverage.outputs.total_coverage }}
coverage_delta:
description: 'Change in coverage compared to the baseline (e.g. "-2.13"). Positive means increase.'
value: ${{ steps.coverage.outputs.coverage_delta }}
coverage_trend:
description: 'Direction of coverage change: "increased", "decreased", or "no change".'
value: ${{ steps.coverage.outputs.coverage_trend }}
total_statements:
description: 'Total number of statements in the new coverage profile.'
value: ${{ steps.coverage.outputs.total_statements }}
covered_statements:
description: 'Number of covered statements in the new coverage profile.'
value: ${{ steps.coverage.outputs.covered_statements }}
missed_statements:
description: 'Number of missed (uncovered) statements in the new coverage profile.'
value: ${{ steps.coverage.outputs.missed_statements }}
runs:
using: "composite"
steps:
- name: Download go-coverage-report
shell: bash
id: download
run: $GITHUB_ACTION_PATH/scripts/download-cli-tool.sh "${{ inputs.version }}" "${{ inputs.sha256sum }}"
env:
RUNNER_OS: ${{ runner.os }}
RUNNER_ARCH: ${{ runner.arch }}
- name: Determine changed files
id: changed-files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
write_output_files: true
json: true
files: |
**.go
files_ignore: |
vendor/**
- name: Code coverage report
shell: bash
id: coverage
run: $GITHUB_ACTION_PATH/scripts/github-action.sh "${{ github.repository }}" "${{ github.event.pull_request.number }}" "${{ github.run_id }}"
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
GITHUB_BASELINE_WORKFLOW_REF: ${{ inputs.github-baseline-workflow-ref }}
TARGET_BRANCH: ${{ inputs.target-branch }}
CHANGED_FILES_PATH: .github/outputs/all_modified_files.json
COVERAGE_ARTIFACT_NAME: ${{ inputs.coverage-artifact-name }}
COVERAGE_FILE_NAME: ${{ inputs.coverage-file-name }}
ROOT_PACKAGE: ${{ inputs.root-package }}
SKIP_COMMENT: ${{ inputs.skip-comment }}
TRIM_PACKAGE: ${{ inputs.trim }}
EXCLUDE: ${{ inputs.exclude }}
EVENT_NAME: ${{ inputs.event-name }}