Skip to content

Conversation

@justice-adams-apple
Copy link
Contributor

  • Add bisect.py

this python script is responsible for managing a repository bisection in a CI job. It is intended to be used in CI to keep track of a bisection process. This bisection manager orchestrates automated git bisections across CI/CD systems (Jenkins, GitHub Actions), manages bisection state, and generates comprehensive reports. By extracting the logic maintaining the binary search to a separate maintainable tool, we can eliminate much of that logic from the CI jobs themselves thus making this portable across CI systems.

This script runs the following commands:

  • init: Initialize a new bisection session or continue an existing one. Outputs a JSON state object with session details, commit range, and first commit to test. Creates bisection_state.json, bisection.log, and restart_instructions.log to be archived by CI jobs
  • log-step: Log the start of a bisection step and retrieve next commit to test. Appends step details to the bisection.log and prints information about the soon-to-be-tested commit to the CI console. If bisection is complete, outputs completion status instead of next commit
  • record: Record the CI test result for a commit and update bisection boundaries. Updates the JSON state object with new boundaries and next action
  • show-restart: Display and log restart instructions for the current bisection step. Called before running a test so users know how to restart if the job fails as these bisections can be long running jobs
  • log-job: Log the execution details of a CI test job to the CI console for easier debugging.
  • final-report: Generate comprehensive final report when bisection completes. The report includes session details, first bad commit, commit diff/stats, test result summary, and statistics

The CI job in question would use the script like so

python3 bisect.py init --repo-path llvm-project f71be4038910e897b0ed78a963e00ac1fdc9b6cc a5c751e3253f09567cef180edee60cc19cc5e366 --test-job clang-stage1-RA

while (bisection is not complete) {
  python3 bisect.py log-step --repo-path llvm-project N

  python3 bisect.py show-restart --repo-path llvm-project N clang-stage1-RA --platform jenkins

  <build CI job in question>

  python3 bisect.py log-job --repo-path llvm-project clang-stage1 <(SUCCESS|FAIL)> <DURATION> --job-url https://ci.swift.org/job/clang-stage1-RA/ --build-number <NUM>

  python3 bisect.py record --repo-path llvm-project <COMMIT> <(SUCCESS|FAIL)>
}


python3 bisect.py final-report --repo-path llvm-project

Throughout this process the json state file is updated and used to continue the bisection. Shown to work here:
https://ci.swift.org/view/xInfrastructure/job/wip-run-bisect/

@justice-adams-apple
Copy link
Contributor Author

cc @azharudd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant