Skip to content

Commit 92ea4a9

Browse files
authored
Merge branch 'main' into fix/landingpage-product-section
2 parents 0b12f1a + 4064199 commit 92ea4a9

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

versioned_docs/version-3.0.0/keploy-cloud/deduplication.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,42 @@ Add the following on top of your main application file : -
4545
import _ "github.com/keploy/go-sdk/v3/keploy"
4646
```
4747

48-
Update the go build command in Dockerfile to add new flags which is required for deduplication (use same flags for native builds)
48+
**2. Build Configuration**
49+
50+
Update the `go build` command in your Dockerfile (or native build script) to include coverage flags. These are required for deduplication to calculate coverage accurately.
4951

5052
```bash
5153
RUN go build -cover -covermode=atomic -coverpkg=./... -o /app/main .
5254
```
5355

54-
**2. Run Deduplication**
56+
**3. Dockerfile Configuration (Important for Docker Users)**
57+
58+
If you are using a multi-stage Docker build (e.g., building in one stage and running in a slim image), you **must** ensure the Go toolchain and `go.mod` files are preserved in the final runtime image. The deduplication feature requires access to the Go runtime to map coverage data correctly.
59+
60+
Update your final runtime stage in the `Dockerfile` to include the following:
61+
62+
```dockerfile
63+
# ... inside your final runtime stage ...
64+
65+
# 1. Copy Go toolchain from the builder stage
66+
COPY --from=builder /usr/local/go /usr/local/go
67+
68+
# 2. Set Go environment variables so the app can use internal go tools
69+
ENV GOROOT=/usr/local/go
70+
ENV PATH=/usr/local/go/bin:${PATH}
71+
72+
# 3. Copy go.mod and go.sum (Required for dependency resolution during coverage)
73+
COPY --from=builder /src/go.mod /src/go.sum /app/
74+
75+
# 4. Set the GOMOD environment variable
76+
ENV GOMOD=/app/go.mod
77+
78+
# ... rest of your dockerfile ...
79+
```
80+
81+
> **Note:** If you face issues with toolchain downloads in restricted environments, you may also need to set `ENV GOTOOLCHAIN=local` and configure your `GOPROXY` in the Dockerfile.
82+
83+
**4. Run Deduplication**
5584

5685
For Docker, run:
5786

@@ -65,15 +94,15 @@ For Native, run:
6594
keploy test -c ./main --dedup
6695
```
6796

68-
This will generate a dedupData.yaml file
97+
This will generate a `dedupData.yaml` file.
6998

70-
After this Run
99+
After this, run:
71100

72101
```bash
73102
keploy dedup
74103
```
75104

76-
This command will create a duplicates.yaml file which will contain all the test cases which was found to be duplicate.
105+
This command will create a `duplicates.yaml` file which will contain all the test cases which were found to be duplicate.
77106

78107
In order to remove all the duplicate test cases, run the following command:
79108

0 commit comments

Comments
 (0)