Skip to content

Commit

Permalink
Merge branch 'master' into rdp
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jul 20, 2020
2 parents 9e6518f + 91b7155 commit 116d662
Show file tree
Hide file tree
Showing 23 changed files with 181 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
deploy:
working_directory: ~/reviewdog/doghouse/appengine/
docker:
- image: gcr.io/gcpug-container/appengine-go:1.13-slim
- image: gcr.io/gcpug-container/appengine-go:1.14-slim
environment:
GAE_DEPLOY_ACCOUNT: review-dog@appspot.gserviceaccount.com
GAE_DEPLOY_PROJECT: review-dog
Expand Down
1 change: 1 addition & 0 deletions .github/goreleaser-header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See [CHANGELOG](https://github.com/reviewdog/reviewdog/blob/master/CHANGELOG.md)
3 changes: 2 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": [
"config:base"
"config:base",
":semanticCommits"
],
"packageRules": [
{
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Code scanning - action"

on:
push:
pull_request:
schedule:
- cron: '0 10 * * 6'

jobs:
CodeQL-Build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ on:
- master
tags:
- 'v*.*.*'
pull_request:
types:
- labeled

jobs:
release:
if: github.event.action != 'labeled'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -37,8 +41,16 @@ jobs:
if: "steps.tag.outputs.value != ''"
with:
version: latest
args: release --rm-dist
args: release --rm-dist --release-header .github/goreleaser-header.md
env:
# Need to use personal access token instead of default token to
# update https://github.com/reviewdog/homebrew-tap.
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}

release-check:
if: github.event.action == 'labeled'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Post bumpr status comment
uses: haya14busa/action-bumpr@v1
11 changes: 11 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,14 @@ jobs:
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review

alex:
name: runner / alex
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: reviewdog/action-alex@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ changelog:
exclude:
- '^docs:'
- '^test:'
- '^chore'
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### :book: Release Note <!-- optional -->

### :rocket: Enhancements
- [#563](https://github.com/reviewdog/reviewdog/issues/563) Use `CI_API_V4_URL` environment variable when present.
- ...

### :bug: Fixes
- [#609](https://github.com/reviewdog/reviewdog/issues/609) reviewdog command will fail with unexpected tool's error for github-check/github-pr-check reporters as well. ([@haya14busa])
- ...

### :rotating_light: Breaking changes
- ...

---

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

### :rocket: Enhancements
- [#563](https://github.com/reviewdog/reviewdog/issues/563) Use `CI_API_V4_URL` environment variable when present.

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

---

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

### :sparkles: Release Note
Expand Down Expand Up @@ -49,10 +58,15 @@ $ cd subdir/ && reviewdog -filter-mode=file -fail-on-error -reporter=github-pr-r
### :bug: Fixes
- [#461](https://github.com/reviewdog/reviewdog/issues/461) All reporters now supports sub-directory run. ([@haya14busa])

### :rotating_light: 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]: https://github.com/reviewdog/reviewdog/compare/v0.10.0...HEAD
[v0.10.0]: https://github.com/reviewdog/reviewdog/compare/v0.9.17...v0.10.0
[v0.10.1]: https://github.com/reviewdog/reviewdog/compare/v0.10.0...v0.10.1
[@haya14busa]: https://github.com/haya14busa
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ by diff.

```shell
# Install the latest version. (Install it into ./bin/ by default).
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s

# Specify installation directory ($(go env GOPATH)/bin/) and version.
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b $(go env GOPATH)/bin [vX.Y.Z]
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b $(go env GOPATH)/bin [vX.Y.Z]

# In alpine linux (as it does not come with curl by default)
$ wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s [vX.Y.Z]
$ wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s [vX.Y.Z]
```

### Nightly releases

You can also use [nightly reviewdog release](https://github.com/reviewdog/nightly)
to try the latest reviewdog improvements every day!

```
$ curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b $(go env GOPATH)/bin
```shell
$ curl -sfL https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
```

### Build from HEAD with go get
Expand Down Expand Up @@ -342,8 +342,7 @@ server.
### Reporter: GitHub Checks (-reporter=github-check)

It's basically same as `-reporter=github-pr-check` except it works not only for
Pull Request but also for commit and it reports results outside Pull Request
diff too.
Pull Request but also for commit.

[![sample comment outside diff](https://user-images.githubusercontent.com/3797062/69917921-e0680580-14ae-11ea-9a56-de9e3cbac005.png)](https://github.com/reviewdog/reviewdog/pull/364/files)

Expand Down Expand Up @@ -491,9 +490,11 @@ You can use public GitHub Actions to start using reviewdog with ease! :tada: :ar

- Common
- [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell) - Run [misspell](https://github.com/client9/misspell).
- Text (e.g. Markdown)
- [reviewdog/action-alex](https://github.com/reviewdog/action-alex) - Run [alex](languagetool) which catches insensitive, inconsiderate writing. (e.g. master/slave)
- [reviewdog/action-languagetool](https://github.com/reviewdog/action-languagetool) - Run [languagetool](https://github.com/languagetool-org/languagetool).
- [tsuyoshicho/action-textlint](https://github.com/tsuyoshicho/action-textlint) - Run [textlint](https://github.com/textlint/textlint)
- [tsuyoshicho/action-redpen](https://github.com/tsuyoshicho/action-redpen) - Run [redpen](https://github.com/redpen-cc/redpen)
- [reviewdog/action-languagetool](https://github.com/reviewdog/action-languagetool) - Run [languagetool](https://github.com/languagetool-org/languagetool).
- Docker
- [reviewdog/action-hadolint](https://github.com/reviewdog/action-hadolint) - Run [hadolint](https://github.com/hadolint/hadolint) to lint `Dockerfile`.
- Env
Expand Down Expand Up @@ -723,7 +724,7 @@ $ reviewdog -reporter=github-pr-review -filter-mode=nofilter -fail-on-error
```

### Filter Mode Support Table
Note that not all reporters provide full suppport of filter mode due to API limitation.
Note that not all reporters provide full support of filter mode due to API limitation.
e.g. `github-pr-review` reporter uses [GitHub Review
API](https://developer.github.com/v3/pulls/reviews/) but it doesn't support posting comment outside diff (`diff_context`),
so reviewdog will use [Check annotation](https://developer.github.com/v3/checks/runs/) as fallback to post those comments [1].
Expand Down
27 changes: 22 additions & 5 deletions cienv/github_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,22 @@ type GitHubEvent struct {
} `json:"head_commit"`
}

type GitHubRepo struct {
Owner struct {
ID int64 `json:"id"`
}
}

type GitHubPullRequest struct {
Number int `json:"number"`
Head struct {
Sha string `json:"sha"`
Ref string `json:"ref"`
Repo struct {
Fork bool `json:"fork"`
} `json:"repo"`
Sha string `json:"sha"`
Ref string `json:"ref"`
Repo GitHubRepo `json:"repo"`
} `json:"head"`
Base struct {
Repo GitHubRepo `json:"repo"`
} `json:"base"`
}

// LoadGitHubEvent loads GitHubEvent if it's running in GitHub Actions.
Expand Down Expand Up @@ -94,3 +101,13 @@ func IsInGitHubAction() bool {
// https://help.github.com/en/articles/virtual-environments-for-github-actions#default-environment-variables
return os.Getenv("GITHUB_ACTION") != ""
}

// IsGitHubPRFromForkedRepo returns true if reviewdog is running in GitHub
// Actions and running for PullRequests from forked repository.
func IsGitHubPRFromForkedRepo() bool {
event, err := LoadGitHubEvent()
if err != nil {
return false
}
return event.PullRequest.Head.Repo.Owner.ID != event.PullRequest.Base.Repo.Owner.ID
}
11 changes: 1 addition & 10 deletions cmd/reviewdog/doghouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,10 @@ func checkResultToAnnotation(c *reviewdog.CheckResult, wd, gitRelWd string) *dog
// It returns true if reviewdog should exit with 1.
// e.g. At least one annotation result is in diff.
func reportResults(w io.Writer, filteredResultSet *reviewdog.FilteredResultMap) bool {
if filteredResultSet.Len() != 0 && isPRFromForkedRepo() {
if filteredResultSet.Len() != 0 && cienv.IsGitHubPRFromForkedRepo() {
fmt.Fprintln(w, `reviewdog: This is Pull-Request from forked repository.
GitHub token doesn't have write permission of Check API, so reviewdog will
report results via logging command [1].
[1]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#logging-commands`)
}

Expand Down Expand Up @@ -252,11 +251,3 @@ report results via logging command [1].
}
return shouldFail
}

func isPRFromForkedRepo() bool {
event, err := cienv.LoadGitHubEvent()
if err != nil {
return false
}
return event.PullRequest.Head.Repo.Fork
}
3 changes: 1 addition & 2 deletions cmd/reviewdog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,11 @@ See -reporter flag for migration and set -reporter="github-pr-review" or -report
// instead of review comment because if it's PR from forked repository,
// GitHub token doesn't have write permission due to security concern and
// cannot post results via Review API.
if cienv.IsInGitHubAction() && isPRFromForkedRepo() {
if cienv.IsInGitHubAction() && cienv.IsGitHubPRFromForkedRepo() {
fmt.Fprintln(w, `reviewdog: This is Pull-Request from forked repository.
GitHub token doesn't have write permission of Review API, so reviewdog will
report results via logging command [1] and create annotations similar to
github-pr-check reporter as a fallback.
[1]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#logging-commands`)
cs = githubutils.NewGitHubActionLogWriter(opt.level)
} else {
Expand Down
2 changes: 1 addition & 1 deletion doghouse/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ includes:
# GitHub APIs, so it should be safe to increase the scaling condition while
# preserving the performance.
#
# reviewdog CLI tipically call multiple requests at the same time, so the
# reviewdog CLI typically call multiple requests at the same time, so the
# default max_concurrent_requests (=10) seems to be too small and it can be a
# reason why AppEngine starts multiple instances for the reviewdog server.
#
Expand Down
2 changes: 1 addition & 1 deletion doghouse/appengine/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func notfound(w http.ResponseWriter) {
func (g *GitHubHandler) getUserOrBadRequest(ctx context.Context, ghcli *github.Client, w http.ResponseWriter) (bool, *github.User) {
u, _, err := ghcli.Users.Get(ctx, "")
if err != nil {
// Token seeims invalid. Clear it before returning BadRequest status.
// Token seems invalid. Clear it before returning BadRequest status.
g.tokenStore.Clear(w)
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "Cannot get GitHub authenticated user. Please reload the page again.")
Expand Down
1 change: 1 addition & 0 deletions doghouse/server/doghouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (ch *Checker) Check(ctx context.Context) (*doghouse.CheckResponse, error) {

results := annotationsToCheckResults(ch.req.Annotations)
filterMode := ch.req.FilterMode
//lint:ignore SA1019 Need to support OutsideDiff for backward compatibility.
if ch.req.PullRequest == 0 || ch.req.OutsideDiff {
// If it's not Pull Request run, do not filter results by diff regardless
// of the filter mode.
Expand Down
2 changes: 1 addition & 1 deletion doghouse/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type CheckRequest struct {
// Optional.
Level string `json:"level"`

// Deprecatd: Use FilterMode == diffilter.NoFilter instead.
// Deprecated: Use FilterMode == difffilter.NoFilter instead.
//
// OutsideDiff represents whether it report results in outside diff or not as
// annotations. It's useful only when PullRequest != 0. If PullRequest is
Expand Down
2 changes: 1 addition & 1 deletion filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,6 @@ func TestGetOldPosition_added(t *testing.T) {
fdiff := findFileDiff(filediffs, path, strip)
gotPath, _ := getOldPosition(fdiff, strip, path, 1)
if gotPath != "" {
t.Errorf("got %q as old path for addedd diff file, want empty", gotPath)
t.Errorf("got %q as old path for added diff file, want empty", gotPath)
}
}
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ module github.com/reviewdog/reviewdog
go 1.14

require (
cloud.google.com/go v0.58.0
cloud.google.com/go v0.61.0
cloud.google.com/go/datastore v1.1.0
contrib.go.opencensus.io/exporter/stackdriver v0.13.1
contrib.go.opencensus.io/exporter/stackdriver v0.13.2
github.com/bradleyfalzon/ghinstallation v1.1.1
github.com/golang/protobuf v1.4.2
github.com/google/go-cmp v0.4.1
github.com/google/go-cmp v0.5.0
github.com/google/go-github/v31 v31.0.0
github.com/haya14busa/go-actions-toolkit v0.0.0-20200105081403-ca0307860f01
github.com/haya14busa/secretbox v0.0.0-20180525171038-07c7ecf409f5
github.com/justinas/nosurf v1.1.0
github.com/kylelemons/godebug v1.1.0
github.com/mattn/go-shellwords v1.0.10
github.com/rakyll/statik v0.1.7
github.com/reviewdog/errorformat v0.0.0-20200602145434-9f3caa8ff10b
github.com/xanzy/go-gitlab v0.32.1
go.opencensus.io v0.22.3
golang.org/x/build v0.0.0-20200610210258-973ac284c062
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
github.com/reviewdog/errorformat v0.0.0-20200718103534-732d4abf7a25
github.com/xanzy/go-gitlab v0.33.0
go.opencensus.io v0.22.4
golang.org/x/build v0.0.0-20200616162219-07bebbe343e9
golang.org/x/net v0.0.0-20200707034311-ab3426394381
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
google.golang.org/protobuf v1.24.0
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v2 v2.3.0
)

0 comments on commit 116d662

Please sign in to comment.