Skip to content

Commit 73e950d

Browse files
committed
test
1 parent eaf2b25 commit 73e950d

File tree

2 files changed

+180
-6
lines changed

2 files changed

+180
-6
lines changed

.github/workflows/action-docker-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,13 @@ jobs:
5050
- name: generate test coverage
5151
run: go test ./... -coverprofile=./cover.out -covermode=atomic
5252

53-
- name: set action image version to dev
54-
run: |
55-
yq e -i '.runs.image = "docker://ghcr.io/vladopajic/go-test-coverage:dev"' action.yml
56-
image=$(yq '.runs.image' action.yml)
57-
echo "Image: $image"
58-
5953
## Test 1
6054

6155
- name: "test: total coverage 0% (config)"
6256
uses: ./
6357
id: test-1
6458
with:
59+
version: dev
6560
config: ./.github/workflows/testdata/zero.yml
6661

6762
- name: "check: test output values"
@@ -75,6 +70,7 @@ jobs:
7570
id: test-2
7671
continue-on-error: true
7772
with:
73+
version: dev
7874
config: ./.github/workflows/testdata/total100.yml
7975

8076
- name: "check: test should have failed"
@@ -91,6 +87,7 @@ jobs:
9187
uses: ./
9288
id: test-3
9389
with:
90+
version: dev
9491
profile: cover.out
9592
threshold-file: 0
9693
threshold-package: 0
@@ -103,6 +100,7 @@ jobs:
103100
id: test-4
104101
continue-on-error: true
105102
with:
103+
version: dev
106104
profile: cover.out
107105
threshold-file: 0
108106
threshold-package: 0
@@ -118,6 +116,7 @@ jobs:
118116
uses: ./
119117
id: test-5
120118
with:
119+
version: dev
121120
config: ./.github/workflows/testdata/total100.yml
122121
threshold-file: 0
123122
threshold-package: 0
@@ -130,6 +129,7 @@ jobs:
130129
id: test-6
131130
continue-on-error: true
132131
with:
132+
version: dev
133133
profile: unexistant-profile.out
134134
debug: true
135135
threshold-file: 0

action/docker/action.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: go-test-coverage
2+
author: vladopajic
3+
description: go-test-coverage is a tool designed to report issues when test coverage falls below a specified threshold.
4+
branding:
5+
icon: 'code'
6+
color: 'blue'
7+
8+
inputs:
9+
# Config
10+
config:
11+
description: Path to the configuration file (.testcoverage.yml), which defines test coverage settings and thresholds.
12+
required: false
13+
default: ""
14+
type: string
15+
source-dir:
16+
description: Sets relative path to source files.
17+
required: false
18+
default: ""
19+
type: string
20+
debug:
21+
description: Prints additional debugging output when running action.
22+
required: false
23+
default: false
24+
type: boolean
25+
26+
# Individual properties
27+
profile:
28+
description: Path to the coverage profile file. Overrides value from configuration.
29+
required: false
30+
default: ""
31+
type: string
32+
# DEPRECATED
33+
local-prefix:
34+
description: DEPRECATED! not used anymore.
35+
required: false
36+
default: ""
37+
type: string
38+
threshold-file:
39+
description: Minimum coverage percentage required for individual files. Overrides value from configuration.
40+
required: false
41+
default: -1
42+
type: number
43+
threshold-package:
44+
description: Minimum coverage percentage required for each package. Overrides value from configuration.
45+
required: false
46+
default: -1
47+
type: number
48+
threshold-total:
49+
description: Minimum overall project coverage percentage required. Overrides value from configuration.
50+
required: false
51+
default: -1
52+
type: number
53+
54+
breakdown-file-name:
55+
description: File name of go-test-coverage breakdown file, which can be used to analyze coverage difference. Overrides value from configuration.
56+
required: false
57+
default: ""
58+
type: string
59+
60+
diff-base-breakdown-file-name:
61+
description: File name of go-test-coverage breakdown file used to calculate coverage difference from current (head).
62+
required: false
63+
default: ""
64+
type: string
65+
66+
# Badge (as file)
67+
badge-file-name:
68+
description: If specified, a coverage badge will be generated and saved to the given file path.
69+
required: false
70+
default: ""
71+
type: string
72+
73+
# Badge (on CDN)
74+
cdn-secret:
75+
description: API secret key for CDN. If specified, the badge will be uploaded to the CDN.
76+
required: false
77+
default: ""
78+
type: string
79+
cdn-key:
80+
description: API key for CDN access.
81+
required: false
82+
default: ""
83+
type: string
84+
cdn-region:
85+
description: Specifies the CDN region for the badge upload.
86+
required: false
87+
default: ""
88+
type: string
89+
cdn-endpoint:
90+
description: URL endpoint for CDN where the badge will be uploaded.
91+
required: false
92+
default: ""
93+
type: string
94+
cdn-file-name:
95+
description: Filename (including path) for storing the badge on the CDN.
96+
required: false
97+
default: ""
98+
type: string
99+
cdn-bucket-name:
100+
description: Name of the CDN bucket where the badge will be saved.
101+
required: false
102+
default: ""
103+
type: string
104+
cdn-force-path-style:
105+
description: Forces path-style URL access in the CDN.
106+
required: false
107+
default: false
108+
type: boolean
109+
110+
# Badge (on Git)
111+
git-token:
112+
description: GitHub token for authorization. If provided, the badge will be uploaded to the specified GitHub repository.
113+
required: false
114+
default: ""
115+
type: string
116+
git-repository:
117+
description: Target GitHub repository in {owner}/{repository} format where the badge will be stored.
118+
required: false
119+
default: ${{ github.repository }}
120+
type: string
121+
git-branch:
122+
description: Repository branch where the badge file will be saved.
123+
required: false
124+
default: ""
125+
type: string
126+
git-file-name:
127+
description: File name (including path) for storing the badge in the specified repository.
128+
required: false
129+
default: .badges/${{ github.ref_name }}/coverage.svg
130+
type: string
131+
132+
version:
133+
description: Version of go-test-coverage source to run
134+
required: false
135+
# TOOL_VERSION: when changing version update version in other places
136+
default: v2.15.0
137+
type: string
138+
139+
outputs:
140+
total-coverage:
141+
description: Integer value in the range [0-100], representing the overall project test coverage percentage.
142+
badge-color:
143+
description: Color hex code for the badge (e.g., `#44cc11`), representing the coverage status.
144+
report:
145+
description: JSON-encoded string containing the detailed test coverage report.
146+
badge-text:
147+
description: Deprecated! Text label for the badge.
148+
149+
runs:
150+
using: docker
151+
image: docker://ghcr.io/vladopajic/go-test-coverage:${{ inputs.version }}
152+
args:
153+
- --config=${{ inputs.config || '***' }}
154+
- --profile=${{ inputs.profile || '***' }}
155+
- --source-dir=${{ inputs.source-dir || '***' }}
156+
- --debug=${{ inputs.debug }}
157+
- --github-action-output=true
158+
- --threshold-file=${{ inputs.threshold-file }}
159+
- --threshold-package=${{ inputs.threshold-package }}
160+
- --threshold-total=${{ inputs.threshold-total }}
161+
- --breakdown-file-name=${{ inputs.breakdown-file-name || '***' }}
162+
- --diff-base-breakdown-file-name=${{ inputs.diff-base-breakdown-file-name || '***' }}
163+
- --badge-file-name=${{ inputs.badge-file-name || '***' }}
164+
- --cdn-key=${{ inputs.cdn-key || '***' }}
165+
- --cdn-secret=${{ inputs.cdn-secret || '***' }}
166+
- --cdn-region=${{ inputs.cdn-region || '***' }}
167+
- --cdn-endpoint=${{ inputs.cdn-endpoint || '***' }}
168+
- --cdn-file-name=${{ inputs.cdn-file-name || '***' }}
169+
- --cdn-bucket-name=${{ inputs.cdn-bucket-name || '***' }}
170+
- --cdn-force-path-style=${{ inputs.cdn-force-path-style }}
171+
- --git-token=${{ inputs.git-token || '***' }}
172+
- --git-branch=${{ inputs.git-branch || '***' }}
173+
- --git-repository=${{ inputs.git-repository || '***'}}
174+
- --git-file-name=${{ inputs.git-file-name || '***' }}

0 commit comments

Comments
 (0)