Skip to content

Commit 3b6fde3

Browse files
authored
Update codecov to comment on PR (#5412)
1 parent a8fa461 commit 3b6fde3

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

build/jobs/aggregate-coverage.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,29 @@ steps:
3838
- script: |
3939
curl -Os https://cli.codecov.io/latest/linux/codecov
4040
chmod +x codecov
41-
./codecov --verbose upload-process --disable-search --git-service github -f $(Pipeline.Workspace)/AggregatedCoverage/Cobertura.xml
41+
42+
# Build the base command
43+
CMD="./codecov --verbose upload-process \
44+
--disable-search \
45+
--git-service github \
46+
--slug microsoft/fhir-server \
47+
-f $(Pipeline.Workspace)/AggregatedCoverage/Cobertura.xml"
48+
49+
# For PR builds, use the PR head commit and source branch so Codecov
50+
# can associate the upload with the correct pull request.
51+
if [ "$BUILD_REASON" = "PullRequest" ]; then
52+
CMD="$CMD --sha $PR_HEAD_SHA --branch $PR_SOURCE_BRANCH --pr $PR_NUMBER"
53+
else
54+
CMD="$CMD --sha $(Build.SourceVersion) --branch $(Build.SourceBranch)"
55+
fi
56+
57+
echo "Running: $CMD"
58+
eval $CMD
4259
displayName: 'Upload coverage to Codecov'
4360
condition: succeededOrFailed()
4461
env:
4562
CODECOV_TOKEN: $(CODECOV_TOKEN)
63+
BUILD_REASON: $(Build.Reason)
64+
PR_HEAD_SHA: $(System.PullRequest.SourceCommitId)
65+
PR_SOURCE_BRANCH: $(System.PullRequest.SourceBranch)
66+
PR_NUMBER: $(System.PullRequest.PullRequestNumber)

0 commit comments

Comments
 (0)