Ensure we test a consistent commit for PRs#2649
Conversation
By default, Azure Devops clones the special "merge" commit the GitHub creates for PRs. As we clone the repo multiple times (generally, once for each stage), that means later stages can end up cloning a different commit, if there have been commits to master since the first stages run. This often causes failures if those new commits introduce additional tests, or generally change anything. To ensure we test all stages against the same commit, we make a note of the current commit ID of master before starting the pipeline. If we're running a branch directly, then we use the built-in clone command, so this change is a noop. If we're running a PR however, we clone the PR branch and then merge with the original commit ID _manually_. This ensures we are always testing the same effective merge commit. The main downside is the additional complexity required in the pipeline, but what's a 100 extra lines in a 2000 line yaml file between friends...
Code Coverage Report 📊
View the full report for further details: Datadog.Trace Breakdown
|
| master | #2649 | Change | |
|---|---|---|---|
| Lines % | 73% |
72% |
-1% |
| Branches % | 71% |
70% |
-1% |
| Complexity | 12307 |
12307 |
0 ✔️ |
The following classes have significant coverage changes.
| File | Line coverage change | Branch coverage change | Complexity change |
|---|---|---|---|
| Datadog.Trace.Telemetry.JsonWebRequestTelemetryTransport | -27% ⛔ |
-57% ⛔ |
0 ✔️ |
| Datadog.Trace.Ci.GitInfo | -17% ⛔ |
-11% ⛔ |
0 ✔️ |
| Datadog.Trace.Ci.CIVisibility | 7% ✔️ |
7% ✔️ |
0 ✔️ |
View the full reports for further details:
Benchmarks Report 🐌Benchmarks for #2649 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Unknown 🤷 Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Faster 🎉 Same allocations ✔️
|
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.SerilogBenchmark.EnrichedLog‑netcoreapp3.1 | 1.154 | 5,830.03 | 5,053.13 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EnrichedLog |
net472 | 5.93μs | 26.5ns | 103ns | 0.29 | 0 | 0 | 1.87 KB |
| master | EnrichedLog |
netcoreapp3.1 | 5.83μs | 32.8ns | 236ns | 0.0196 | 0 | 0 | 1.49 KB |
| #2649 | EnrichedLog |
net472 | 6.01μs | 21.4ns | 80.2ns | 0.29 | 0 | 0 | 1.87 KB |
| #2649 | EnrichedLog |
netcoreapp3.1 | 5.08μs | 22.9ns | 82.5ns | 0.0202 | 0 | 0 | 1.49 KB |
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️
Faster 🎉 in #2649
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1
1.165
1,199.03
1,029.20
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 | 1.165 | 1,199.03 | 1,029.20 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartFinishSpan |
net472 | 926ns | 4.94ns | 27ns | 0.0719 | 0 | 0 | 457 B |
| master | StartFinishSpan |
netcoreapp3.1 | 919ns | 4.14ns | 15.5ns | 0.00612 | 0 | 0 | 456 B |
| master | StartFinishScope |
net472 | 1.1μs | 5.58ns | 26.2ns | 0.0845 | 0 | 0 | 538 B |
| master | StartFinishScope |
netcoreapp3.1 | 1.2μs | 3.96ns | 15.3ns | 0.00777 | 0 | 0 | 576 B |
| #2649 | StartFinishSpan |
net472 | 899ns | 3.69ns | 13.8ns | 0.0719 | 0 | 0 | 457 B |
| #2649 | StartFinishSpan |
netcoreapp3.1 | 892ns | 4.93ns | 29.2ns | 0.00601 | 0 | 0 | 456 B |
| #2649 | StartFinishScope |
net472 | 1.09μs | 3.47ns | 13ns | 0.0844 | 0 | 0 | 538 B |
| #2649 | StartFinishScope |
netcoreapp3.1 | 1.03μs | 4.93ns | 20.9ns | 0.00805 | 0 | 0 | 576 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunOnMethodBegin |
net472 | 1.27μs | 3.37ns | 12.6ns | 0.0842 | 0 | 0 | 538 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 1.16μs | 3.85ns | 14.9ns | 0.00807 | 0 | 0 | 576 B |
| #2649 | RunOnMethodBegin |
net472 | 1.28μs | 6.13ns | 25.3ns | 0.0838 | 0 | 0 | 538 B |
| #2649 | RunOnMethodBegin |
netcoreapp3.1 | 1.16μs | 4.51ns | 17.4ns | 0.0079 | 0 | 0 | 576 B |
kevingosse
left a comment
There was a problem hiding this comment.
That looks... correct I guess?
| git checkout --force $prBranch | ||
| displayName: checkout | ||
| - bash: | | ||
| git config --global user.email "[email protected]" |
There was a problem hiding this comment.
You could at least have made it @datadoghq.com 😛
There was a problem hiding this comment.
I genuinely did originally, and decided not to do that, in case we add restrictions for datadoghq.com, and we accidentally end up pushing some code from here 😆
Summary of changes
For pull requests, don't use the built-in clone command in Azure Devops, as it uses the variable "merge" commit. Instead, clone the branch, and do the merge manually.
Reason for change
Merging PRs to master can currently cause unrelated PR builds to fail, because the commit being built changes for later stages.
Implementation details
By default, Azure Devops clones the special "merge" commit the GitHub creates for PRs. As we clone the repo multiple times (generally, once for each stage), that means later stages can end up cloning a different commit, if there have been commits to master since the first stages run. This often causes failures if those new commits introduce additional tests, or generally change anything.
To ensure we test all stages against the same commit, we make a note of the current commit ID of master before starting the pipeline. If we're running a branch directly, then we use the built-in clone command, so this change is a noop. If we're running a PR however, we clone the PR branch and then merge with the original commit ID manually. This ensures we are always testing the same effective merge commit.
Test coverage
Ran test branches to confirm it does the merge correctly + it doesn't merge when not doing a PR
Other details
Alternative approaches considered:
tarto pass around artifacts. A very good alternative. I thought this approach was going to be easier, but we run into drive space issues from "duplicating" everything on disk.