0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 12:39:08 +01:00

SERVER-95851 Fix 0% coverage reports and pull requests have separate coveralls builds (#28737)

GitOrigin-RevId: e44387453918d42d722da105670efccf61efe51a
This commit is contained in:
Trevor Guidry 2024-11-01 12:21:34 -04:00 committed by MongoDB Bot
parent 019730112d
commit 9a7e6722cc
2 changed files with 42 additions and 0 deletions

View File

@ -584,6 +584,14 @@ functions:
exec_timeout_secs: ${exec_timeout_secs}
timeout_secs: ${timeout_secs}
"set code coverage expansion": &set_code_coverage_expansion
command: expansions.update
display_name: "set code coverage expansion"
params:
updates:
- key: gather_code_coverage_results
value: "true"
### Set expansion macros used in each task.
"set task expansion macros": &set_task_expansion_macros
command: expansions.update
@ -1160,6 +1168,8 @@ functions:
- key: aws_secret_remote
value: ${mongodatafiles_aws_secret}
- *f_expansions_write
- *set_code_coverage_expansion
- *f_expansions_write
- *set_up_remote_credentials
- *f_expansions_write
- *determine_resmoke_jobs
@ -1188,6 +1198,8 @@ functions:
- *f_expansions_write
- *update_task_timeout
- *f_expansions_write
- *set_code_coverage_expansion
- *f_expansions_write
- command: expansions.update
params:
env:
@ -1412,6 +1424,8 @@ functions:
- *get_version_expansions
- *apply_version_expansions
- *f_expansions_write
- *set_code_coverage_expansion
- *f_expansions_write
- *bazel_coverage_sh
"ninja compile sh": &ninja_compile_sh

View File

@ -7,6 +7,7 @@ import sys
import tarfile
from urllib.request import urlretrieve
import git
import requests
import retry
@ -72,6 +73,31 @@ def main():
)
return 0
should_gather_code_coverage = expansions.get("gather_code_coverage_results", False)
if not should_gather_code_coverage:
print("Missing 'gather_code_coverage_results' expansion, skipping code coverage.")
return 0
if not os.path.exists(".git"):
print("No git repo found in working directory. Code coverage needs git repo to function.")
return 1
repo = git.Repo()
head_sha = repo.head.object.hexsha
evergreen_revision = expansions.get("revision")
# We need all code coverage runs from the same patch to have the same commit on HEAD
# When different runs have different git SHAs they are grouped in different builds in coveralls.
#
# Because of the weird cloning we do to have a git repo present during code coverage tasks
# and the inconsistent behaviors of the local git state during evergreen patches and
# commit-queue runs. We need to always ensure that the HEAD matches the evergreen revision
# for consistency in coveralls.
if head_sha != evergreen_revision:
print("test not equal")
print(f"head_sha: {head_sha}")
print(f"evergreen revision: {evergreen_revision}")
repo.git.reset("--mixed", evergreen_revision)
disallowed_arches = {"s390x", "s390", "ppc64le", "ppc64", "ppc", "ppcle"}
arch = platform.uname().machine.lower()
print(f"Detected arch: {arch}")
@ -123,6 +149,8 @@ def main():
)
args.append(bazel_coverage_report_location)
retry_coveralls_report(args)
# no gcda files are generated from bazel coverage so we can exit early here
return 0
scons_build_dir = os.path.join(workdir, "src", "build", "debug")
if os.path.exists(scons_build_dir):