Skip to content

Commit cb5af72

Browse files
authored
Merge branch 'main' into test-ci
2 parents c726b72 + a528d88 commit cb5af72

File tree

9 files changed

+49
-11
lines changed

9 files changed

+49
-11
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ jobs:
1919
username: ${{ github.repository_owner }}
2020
password: ${{ secrets.GITHUB_TOKEN }}
2121

22+
- name: Set up Docker Buildx
23+
uses: docker/[email protected]
24+
with:
25+
use: true
26+
platforms: linux/arm64,linux/amd64
27+
2228
- name: build and push
2329
uses: docker/build-push-action@v6
2430
with:
2531
push: true
32+
platforms: linux/arm64,linux/amd64
2633
build-args: |
2734
VERSION=dev
2835
tags: |
@@ -39,6 +46,9 @@ jobs:
3946
name: test
4047
runs-on: ubuntu-latest
4148
needs: build-dev-image
49+
strategy:
50+
matrix:
51+
os: [ ubuntu-latest, ubuntu-24.04-arm ]
4252

4353
steps:
4454
- name: checkout

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ jobs:
4040
username: ${{ github.repository_owner }}
4141
password: ${{ secrets.GITHUB_TOKEN }}
4242

43+
- name: Set up Docker Buildx
44+
uses: docker/[email protected]
45+
with:
46+
use: true
47+
platforms: linux/arm64,linux/amd64
48+
4349
- name: build and push
4450
uses: docker/build-push-action@v6
4551
with:
4652
push: true
4753
build-args: |
4854
VERSION=${{ env.RELEASE_VERSION }}
55+
platforms: linux/arm64,linux/amd64
4956
tags: |
5057
ghcr.io/vladopajic/go-test-coverage:${{ env.RELEASE_VERSION }}
5158
ghcr.io/vladopajic/go-test-coverage:${{ steps.majorver.outputs.major-tag }}

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# GO_VERSION: automatically update to most recent via dependabot
2-
FROM golang:1.25.3 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.25.3 AS builder
3+
34
WORKDIR /workspace
45

56
COPY go.mod go.mod
@@ -10,10 +11,13 @@ RUN go mod download all
1011
COPY ./ ./
1112

1213
ARG VERSION
13-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
14+
ARG TARGETOS
15+
ARG TARGETARCH
16+
17+
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
1418
go build -o go-test-coverage .
1519

16-
FROM gcr.io/distroless/base:latest
20+
FROM --platform=$BUILDPLATFORM gcr.io/distroless/base:latest
1721
WORKDIR /
1822
COPY --from=builder /workspace/go-test-coverage .
1923
COPY --from=builder /usr/local/go/bin/go /usr/local/go/bin/go

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ outputs:
139139
runs:
140140
using: docker
141141
# TOOL_VERSION: when changing version update version in other places
142-
image: docker://ghcr.io/vladopajic/go-test-coverage:v2.17.1
142+
image: docker://ghcr.io/vladopajic/go-test-coverage:v2.18.0
143143
args:
144144
- --config "${{ inputs.config }}"
145145
- --profile "${{ inputs.profile }}"

action/source/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ inputs:
130130
description: Version of go-test-coverage source to run
131131
required: false
132132
# TOOL_VERSION: when changing version update version in other places
133-
default: v2.17.1
133+
default: v2.18.0
134134
type: string
135135

136136
outputs:

docs/github_action.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ The `go-test-coverage` project provides two types of GitHub Actions:
176176
uses: vladopajic/go-test-coverage@v2
177177
with: ...
178178
```
179+
Pros/Cons:
180+
- Generally faster in practice because everything is packaged and prebuilt.
181+
- Does not require any additional dependencies on the CI runner.
182+
- However, **it introduces a potential supply-chain risk**: using a prebuilt container image means you must trust that the image is safe and has not been tampered with. This repository has no intention of introducing malicious code, but projects with stricter security requirements may still prefer to avoid running opaque binaries.
179183

180184
- **Source-based Action (optional/experimental)**
181185

@@ -188,9 +192,17 @@ The `go-test-coverage` project provides two types of GitHub Actions:
188192
uses: vladopajic/go-test-coverage/action/source@v2
189193
with: ...
190194
```
191-
Note: this action requires `go` to be installed.
195+
Pros/Cons:
196+
- Requires `go` to be installed on the CI runner.
197+
- Slightly slower, as dependencies need to be fetched and the binary built during the workflow.
198+
- The main **advantage is transparency and auditability**: the action runs exactly the code in this repository, which can be reviewed and pinned to a specific version. This can be preferable for environments with strong security or compliance requirements.
199+
200+
Both actions have the same inputs, so they can be used interchangeably.
201+
202+
203+
204+
192205

193-
Both actions have the same inputs, so they can be used interchangeably.
194206

195207

196208

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
const (
12-
Version = "v2.17.1" // TOOL_VERSION: when changing version update version in other places
12+
Version = "v2.18.0" // TOOL_VERSION: when changing version update version in other places
1313
Name = "go-test-coverage"
1414
)
1515

pkg/testcoverage/report.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ func reportUncoveredLines(w io.Writer, result AnalyzeResult) {
7777
defer tabber.Flush()
7878

7979
fmt.Fprintf(tabber, "\nFiles with uncovered lines:")
80-
fmt.Fprintf(tabber, "\n file:\tuncovered lines:")
80+
fmt.Fprintf(tabber, "\n file:\tcoverage:\tuncovered lines:")
8181

8282
for _, stats := range result.FilesWithUncoveredLines {
8383
if len(stats.UncoveredLines) > 0 {
8484
fmt.Fprintf(tabber, "\n %s\t", stats.Name)
85+
fmt.Fprintf(tabber, "%v%%\t", stats.CoveredPercentageF())
8586
compressUncoveredLines(tabber, stats.UncoveredLines)
8687
}
8788
}

pkg/testcoverage/report_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,15 @@ func Test_ReportUncoveredLines(t *testing.T) {
413413
FilesWithUncoveredLines: []coverage.Stats{
414414
{Name: "a.go", UncoveredLines: []int{1, 2, 3}},
415415
{Name: "b.go", UncoveredLines: []int{3, 5, 7}},
416+
{Name: "c.go", UncoveredLines: []int{1, 4, 10}, Covered: 20, Total: 100},
417+
{Name: "d.go", UncoveredLines: []int{7, 8, 9}, Covered: 18, Total: 88},
416418
},
417419
})
418420
assertHasUncoveredLinesInfo(t, buf.String(), []string{
419-
"a.go\t\t1-3\n",
420-
"b.go\t\t3 5 7\n",
421+
"a.go\t\t0%\t\t1-3\n",
422+
"b.go\t\t0%\t\t3 5 7\n",
423+
"c.go\t\t20%\t\t1 4 10\n",
424+
"d.go\t\t20.5%\t\t7-9\n",
421425
})
422426

423427
// when result passes, there should be no output

0 commit comments

Comments
 (0)