-
Notifications
You must be signed in to change notification settings - Fork 31
Suggest reviewers action #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| name: Find Reviewer | ||
|
|
||
| on: | ||
| repository_dispatch: | ||
| types: [find-reviewer] | ||
|
|
||
| jobs: | ||
| find: | ||
| name: Search | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Create path | ||
| run: mkdir -p build/reviewer | ||
|
|
||
| - name: Get composer cache directory | ||
| id: composer-cache | ||
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
|
||
| - name: Cache dependencies | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: composer-${{ runner.os }}-7.4-${{ hashFiles('composer.*') }} | ||
| restore-keys: | | ||
| composer-${{ runner.os }}-7.4- | ||
| composer-${{ runner.os }}- | ||
| composer- | ||
|
|
||
| - name: Download dependencies | ||
| run: composer install --no-interaction --optimize-autoloader | ||
|
|
||
| - name: Cache dependencies | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: build/reviewer/var | ||
| key: nyholm-git-reviewer | ||
|
|
||
| - name: Checkout GitReviewer repo | ||
| run: | | ||
| mkdir -p build/reviewer/var | ||
| mv build/reviewer/var build/reviewer_tmp | ||
| composer create-project nyholm/git-reviewer build/reviewer | ||
| mv build/reviewer_tmp build/reviewer/var | ||
|
|
||
| - name: Download dependencies | ||
| run: | | ||
| cd build/reviewer | ||
| composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable | ||
|
|
||
| - name: Checkout target repo | ||
| id: target-repo | ||
| run: | | ||
| git clone https://github.com/${{ github.event.client_payload.repository }} build/target/${{ github.event.client_payload.repository }} | ||
| echo "::set-output name=dir::$(pwd)/build/target/${{ github.event.client_payload.repository }}" | ||
|
|
||
| - name: Find branch base | ||
| id: target-base | ||
| run: | | ||
| cd build/reviewer | ||
| BASE=$(./git-reviewer.php pull-request:base ${{ github.event.client_payload.pull_request_number }} ${{ steps.target-repo.outputs.dir }}) | ||
| echo "::set-output name=branch::$BASE" | ||
|
|
||
| - name: Checkout branch base | ||
| run: | | ||
| cd ${{ steps.target-repo.outputs.dir }} | ||
| echo ${{ steps.target-base.outputs.branch }} | ||
| git pull | ||
| git checkout ${{ steps.target-base.outputs.branch }} | ||
|
|
||
| - name: Find reviwers | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.CARSONPROD_GITHUB_TOKEN }} | ||
weaverryan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| run: | | ||
| cd build/reviewer | ||
| ./git-reviewer.php find ${{ github.event.client_payload.pull_request_number }} ${{ steps.target-repo.outputs.dir }} \ | ||
| --after `date +%Y-%m-%d --date="2 year ago"` \ | ||
| --ignore-path "src/Symfony/FrameworkBundle/*" \ | ||
| --ignore-path "src/Symfony/Bundle/FrameworkBundle/*" \ | ||
| --ignore-path "src/**/Tests/*" \ | ||
| --ignore-path CHANGELOG*.md \ | ||
Nyholm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --ignore-path UPGRADE*.md \ | ||
| --pretty-print > output.json | ||
|
|
||
| cat output.json | ||
|
|
||
| - name: Write comment | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.CARSONPROD_GITHUB_TOKEN }} | ||
| run: bin/console app:review:suggest ${{ github.event.client_payload.repository }} ${{ github.event.client_payload.pull_request_number }} ${{ github.event.client_payload.type }} `pwd`/build/reviewer/output.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| namespace App\Api\Issue; | ||
|
|
||
| use App\Model\Repository; | ||
|
|
||
| /** | ||
| * This will not write to Github, only output to STDERR. But it will try to read from Github. | ||
| * | ||
| * @author Tobias Nyholm <[email protected]> | ||
| */ | ||
| class StdErrIssueApi extends GithubIssueApi | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is never used. But it was really useful when testing/debugging, so I kept it in the PR. |
||
| { | ||
| public function open(Repository $repository, string $title, string $body, array $labels) | ||
| { | ||
| error_log(sprintf('Open new issue on %s', $repository->getFullName())); | ||
| error_log('Title: '.$title); | ||
| error_log('Labels: '.json_encode($labels)); | ||
| error_log($body); | ||
| } | ||
|
|
||
| public function close(Repository $repository, $issueNumber) | ||
| { | ||
| error_log(sprintf('Closing %s#%d', $repository->getFullName(), $issueNumber)); | ||
| } | ||
|
|
||
| public function commentOnIssue(Repository $repository, $issueNumber, string $commentBody) | ||
| { | ||
| error_log(sprintf('Commenting on %s#%d', $repository->getFullName(), $issueNumber)); | ||
| error_log($commentBody); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean this workflow is called each time a
find-reviewerwebhooks is received? Can you help me understand how this works? thx :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exact. Here are some resources about it you could find useful:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see https://github.com/carsonbot/carsonbot/pull/113/files#diff-761989cba708b0fb2f270ad4d799a7a955b1c611d9cefa6fde84611e03e516c0R36
The corresponding code was added in a separate PR, which is indeed weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I've defined a special event id called
find-reviewer. In theGithubPullRequestApi::findReviewer()that @stof linked, I am dispatching this special event.It is basically me saying: "Hey start the specific CI job called
find-reviewer".