Back to Kibana

Code Coverage Team Assignments

src/dev/code_coverage/docs/team_assignment/README.md

9.4.02.6 KB
Original Source

Code Coverage Team Assignments

Team assignment occurs once per ci run.

The entry point is a yaml config
Within the yaml config, this shell script is used.
Search for node scripts/generate_team_assignments.js and you'll see how it is generated before ingestion begins.
The generated file's path is passed to the ingestion system via an environment variable: --teamAssignmentsPath $TEAM_ASSIGN_PATH.
The ingestion system uses it here.

Team Assignment Parsing (from .github/CODEOWNERS)

We add additional metadata to the CODEOWNERS file.
This metadata allows users to assign teams to paths, in a friendly location.
Example CODEOWNERS Block:
notice the coverage delimiter #CC# ...

/x-pack/solutions/security/test/fixtures/es_archives/endpoint/ @elastic/endpoint-app-team @elastic/siem
#CC# /x-pack/legacy/plugins/siem/ @elastic/siem
#CC# /x-pack/plugins/siem/ @elastic/siem
#CC# /x-pack/solutions/security/plugins/security_solution/ @elastic/siem

The first 3 lines above fill the usual purpose of the CODEOWNERS file and cause PRs modifying files in these paths to require approval by the listed team(s).
They also attribute files in those paths for purpose of code coverage reporting.
The last 3 lines above ONLY attribute files in those paths for purpose of code coverage reporting.

Team Assignment Data File Creation (Before Ingestion)

We create a data file containing all paths in the repo, with a team assigned.
Example Team Assignments Block:

x-pack/solutions/security/plugins/security_solution/common/constants.ts siem
x-pack/solutions/security/plugins/security_solution/common/detection_engine/build_exceptions_query.test.ts siem
x-pack/solutions/security/plugins/security_solution/common/detection_engine/build_exceptions_query.ts siem
...

Team Assignment Data File Usage (During Code Coverage Ingestion)

Subsequently, we use the data file during ingestion. We search the data file, for any given "coveredFilePath"

  • Given the above assignments block, and lets say the "coveredFilePath" during ingestion is
    • x-pack/solutions/security/plugins/security_solution/common/constants.ts
    • The team assignment would be siem in our Kibana Stats Cluster