Skip to content

Conversation

taraspos
Copy link
Contributor

@taraspos taraspos commented Oct 2, 2020

  • Updated Unreleased section in CHANGELOG or it's not notable changes.

This fixes #113 via integration with Bitbucket Code Insights and Bitbucket Pipelines.

See example project trane9991/reviewdog-example.

With the example PR trane9991/reviewdog-example PR#1.

Example report:
Screen Shot 2020-10-02 at 5 09 49 PM

Example annotated diff in PR:
Screen Shot 2020-10-02 at 5 10 59 PM

@taraspos
Copy link
Contributor Author

taraspos commented Oct 2, 2020

I would keep it as a Draft for now and test it on my project to make sure no issue arises but would happy if this can be reviewed in meantime. 🐶

@taraspos
Copy link
Contributor Author

taraspos commented Oct 2, 2020

Current implementation generates one report for all the runners in one project.
It might be a good idea to generate a report per runner to make it more similar to github integration.

@taraspos
Copy link
Contributor Author

taraspos commented Oct 2, 2020

Did a change to create report per runner
Screen Shot 2020-10-02 at 10 35 23 PM

@taraspos taraspos requested a review from haya14busa October 23, 2020 21:21
@taraspos
Copy link
Contributor Author

Hey, @haya14busa, all done! Please check if all looks good to you.

The last thing to decide, if we will keep the openapi package as part of reviewdog/reviewdog repo or let's create some separate one - reviewdog/bitbucket.

// filtering of annotations dividing them in two groups:
// - This pull request (10)
// - All (50)
log.Printf("reviewdog: [bitbucket-code-report] supports only with filter.ModeNoFilter for now\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log this only if the filter mode is not default nor no-filter mode.

}

// if this is simple run, get the single tool name
if name := toolName(opt); len(name) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] name != ""

@@ -689,3 +750,26 @@ func buildRunnersMap(runners string) map[string]bool {
}
return m
}

func getRunnersList(opt *option, conf *project.Config) []string {
if len(opt.runners) > 0 { // if runners explicitly defined, use them
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] It's better to check the specified runner name is actually in the project config.

// hash the output of linter and use it as external id
a.SetExternalId(externalIDFromDiagnostic(c.Result.Diagnostic))
a.SetSummary(c.Result.Diagnostic.GetMessage())
a.SetDetails(fmt.Sprintf(`[%s] %s`, c.ToolName, c.Result.Diagnostic.GetMessage()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optinal] Does bitbucket support markdown? Then we may want to re-use this util func.

// MarkdownComment creates comment body markdown.
func MarkdownComment(c *reviewdog.Comment) string {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, markdown isn't supported in the Code Reports, I tried :(


// create client
client := NewAPIClientWithConfigurations(&http.Client{Timeout: 1 * time.Second}, openapi.ServerConfiguration{URL: ts.URL})
bb := NewReportAnnotator(client, username, repo, commit, test.runnersList)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix this warning?

Using the variable on range scope `test` in function literal (scopelint)

ctx := context.Background()

for _, c := range test.comments {
// post comments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[super nit] I think this comment is redundant.

t.Error(err)
}
}
// flush comments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[super nit] I think this comment is redundant.

@haya14busa haya14busa merged commit 2b11a08 into reviewdog:master Oct 24, 2020
@review-dog
Copy link
Member

Hi, @trane9991! We merged your PR to reviewdog! 🐶
Thank you for your contribution! ✨

We just invited you to join the @reviewdog organization on GitHub.
Accept the invite by visiting https://github.com/orgs/reviewdog/invitation.
By joining the team, you'll be a part of reviewdog community and can help the maintainance of reviewdog.

Thanks again!

@haya14busa
Copy link
Member

The comments were mostly nitpicks, so I just fixed them and merged! Thank you for your contribution!

@haya14busa
Copy link
Member

The last thing to decide, if we will keep the openapi package as part of reviewdog/reviewdog repo or let's create some separate one - reviewdog/bitbucket.

As the above ^^ comment, we invited you to the reviewdog org.
Can you create a repo for the bitbucket and create a pr to use it separately? Thanks!

@taraspos
Copy link
Contributor Author

Thanks, amazing!

Can you create a repo for the bitbucket and create a pr to use it separately?

Will do so. Could we release v0.11.0 once it is done? :)

@haya14busa
Copy link
Member

I have a plan to release a new version this weekend (hopefully).
It's mostly blocked by documentation for suggestion feature / rdformat, so I'd say creating a bitbucket is not release-blocking.

@taraspos
Copy link
Contributor Author

Cool, anyway, I should be able to move the bitbucket to the separate repository right now.

@taraspos
Copy link
Contributor Author

Screen Shot 2020-10-24 at 2 51 45 PM

@haya14busa , I think you can add bitbucket tag here now :)

@haya14busa
Copy link
Member

Good idea. Done!

KikeE36 added a commit to KikeE36/reviewdog that referenced this pull request Feb 22, 2021
https://github.com/reviewdog/reviewdog/tree/reviewdog:master
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### ✨ Release Note <!-- optional -->

### 🚀 Enhancements
- [reviewdog#888](reviewdog#888) Allow GitHub PR reporting for a forked repository iff it's triggered by `pull_request_target`

### 🐛 Fixes
- ...

### 🚨 Breaking changes
- ...

---

## [v0.11.0] - 2020-10-25

### ✨ Release Note
reviewdog v0.11 introduced [Reviewdog Diagnostic Format (RDFormat)](./README.md#reviewdog-diagnostic-format-rdformat)
as generic machine-readable diagnostic format and it unlocks new rich features like code suggestions.

### 🚀 Enhancements
- [reviewdog#629](reviewdog#629) Introduced Reviewdog Diagnostic Format.
 - [reviewdog#674](reviewdog#674) [reviewdog#703](reviewdog#703) Support rdjsonl/rdjson as input format
 - [reviewdog#680](reviewdog#680) github-pr-review: Support multiline comments
 - [reviewdog#675](reviewdog#675) [reviewdog#698](reviewdog#698) github-pr-review: Support suggested changes
 - [reviewdog#699](reviewdog#699) Support diff input format (`-f=diff`). Useful for suggested changes.
 - [reviewdog#700](reviewdog#700) Support to show code(rule), code URL and severity in GitHub and GitLab reporters.
- [reviewdog#678](reviewdog#678) github-pr-review: Support Code Suggestions
  - Introduced [reviewdog/action-suggester](https://github.com/reviewdog/action-suggester) action.
- Introduced [reviewdog/action-setup](https://github.com/reviewdog/action-setup) GitHub Action which installs reviewdog easily including nightly release.
- [reviewdog#769](reviewdog#769) Integration with [Bitbucket Code Insights](https://support.atlassian.com/bitbucket-cloud/docs/code-insights/) and [Bitbucket Pipelines](https://bitbucket.org/product/ru/features/pipelines)

---

## [v0.10.2] - 2020-08-04

### 🐛 Fixes
- [reviewdog#709](reviewdog#709) Check for GITHUB_ACTIONS instead of GITHUB_ACTION

---

## [v0.10.1] - 2020-06-30

### 🚀 Enhancements
- [reviewdog#563](reviewdog#563) Use `CI_API_V4_URL` environment variable when present.

### 🐛 Fixes
- [reviewdog#609](reviewdog#609) reviewdog command will fail with unexpected tool's error for github-check/github-pr-check reporters as well. ([@haya14busa])
- [reviewdog#603](reviewdog#603) Fixed detection of Pull Requests from forked repo. ([@haya14busa])

---

## [v0.10.0] - 2020-05-07

### ✨ Release Note

With v0.10.0 release, now reviewdog can find issues outside diff by controlling
filtering behavior with `-filter-mode`. Also, you can ensure to check reported
results by exit 1 with `-fail-on-error`.

Example
```shell
$ cd subdir/ && reviewdog -filter-mode=file -fail-on-error -reporter=github-pr-review
```

### 🚀 Enhancements
- [reviewdog#446](reviewdog#446)
  Added `-fail-on-error` flag
  ([document](https://github.com/reviewdog/reviewdog/tree/e359505275143ec85e9b114fc1ab4a4e91d04fb5#exit-codes))
  and improved exit code handling. ([@DmitryLanda](https://github.com/DmitryLanda), [@haya14busa])
- [reviewdog#187](reviewdog#187)
  Added `-filter-mode` flag [`added`, `diff_context`, `file`, `nofilter`]
  ([document](https://github.com/reviewdog/reviewdog/tree/e359505275143ec85e9b114fc1ab4a4e91d04fb5#filter-mode))
  which controls how reviewdog filter results. ([@Le6ow5k1](https://github.com/Le6ow5k1), [@haya14busa])
- [reviewdog#69](reviewdog#69) Support gerrit! ([@staticmukesh](https://github.com/staticmukesh))
- [reviewdog#548](reviewdog#548) Introduced nightly release ([reviewdog/nightly](https://github.com/reviewdog/nightly)). ([@haya14busa])

### 🐛 Fixes
- [reviewdog#461](reviewdog#461) All reporters now supports sub-directory run. ([@haya14busa])

### 🚨 Breaking changes
- `github-check` reporter won't report results outside diff by default now. You
  need to use `-filter-mode=nofilter` to keep the same bahavior.

---

See https://github.com/reviewdog/reviewdog/releases for older release note.

[Unreleased]: reviewdog/reviewdog@v0.10.0...HEAD
[v0.10.0]: reviewdog/reviewdog@v0.9.17...v0.10.0
[v0.10.1]: reviewdog/reviewdog@v0.10.0...v0.10.1
[v0.10.2]: reviewdog/reviewdog@v0.10.1...v0.10.2
[v0.11.0]: reviewdog/reviewdog@v0.10.2...v0.11.0
[@haya14busa]: https://github.com/haya14busa
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.

Add support for BitBucket
3 participants