Page MenuHomePhabricator

[CI] Add coderabbit as an AI reviewer on diffs
ClosedPublic

Authored by Fabien on Mon, Jul 20, 20:33.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABCce6d7833b74c: [CI] Add coderabbit as an AI reviewer on diffs
Summary

The coderabbit CLI is installed and used to review the diffs.
The review is added as a phabricator comment on the revision.

There is no way to test the full workflow without deploying the build bot, so the runOnDiff flag is commented out for now.
We can then deploy after this diff landed and summon the review manually for testing.

Once this tested is successful, we can enable the runOnDiff flag and remove the cat to teamcity stdout.

Test Plan
CR_API_KEY="<your agentic API key" ./contrib/teamcity/build-configurations.py ai-review

ninja check-buildbot

Summon the bot and inspect the build log to see the output (for now).

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Failed tests logs:

====== test_endpoint_status.EndpointStatusTestCase.test_status_preview_available ======
test_endpoint_status.py:1115 (EndpointStatusTestCase.test_status_preview_available)
200 != 500

self = <test.test_endpoint_status.EndpointStatusTestCase testMethod=test_status_preview_available>

    def test_status_preview_available(self):
        data = statusRequestData()
        data.buildResult = "success"
        data.branch = "phabricator/diff/456"
    
        self.teamcity.getPreviewUrl = mock.Mock()
        self.teamcity.getPreviewUrl.return_value = (
            "Preview is available at http://127.0.0.1:8080 for the next 10 minutes."
        )
    
        self.configure_build_info(
            properties=test.mocks.teamcity.buildInfo_properties(
                propsList=[
                    {
                        "name": "env.OS_NAME",
                        "value": "linux",
                    }
                ]
            ),
        )
    
        self.teamcity.session.send.side_effect = [
            test.mocks.teamcity.Response(),
            test.mocks.teamcity.Response(),
            test.mocks.teamcity.Response(),
        ]
    
        self.phab.differential.revision.edit = mock.Mock()
        self.phab.differential.diff.search.return_value = test.mocks.phabricator.Result(
            [
                {
                    "id": "456",
                    "fields": {"revisionPHID": "789"},
                }
            ]
        )
        self.phab.differential.revision.search.return_value = (
            test.mocks.phabricator.differential_revision_search_result()
        )
    
        response = self.app.post("/status", headers=self.headers, json=data)
>       self.assertEqual(response.status_code, 200)

test_endpoint_status.py:1157: AssertionError

Each failure log is accessible here:
test_endpoint_status.EndpointStatusTestCase.test_status_preview_available

Fix the test and add one

Tail of the build log:

/work /work/abc-ci-builds/ai-review
/work/abc-ci-builds/ai-review/script.sh: line 6: CR_API_KEY: unbound variable
Build ai-review failed with exit code 1

Tail of the build log:

/work /work/abc-ci-builds/ai-review
/work/abc-ci-builds/ai-review/script.sh: line 6: cr: command not found
Build ai-review failed with exit code 127

Only review committed files

Use a tmp dir during the installation, and disable echoing during authentication

Log out after the review

Fabien published this revision for review.Tue, Jul 21, 11:02
Fabien edited the summary of this revision. (Show Details)
Fabien edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Tue, Jul 21, 11:10