From 99ea63bce947845a393da7d5c6a294c21bef8fcc Mon Sep 17 00:00:00 2001 From: Priyanshu Shukla <78398690+priyxnshuuu@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:41:08 +0530 Subject: [PATCH 1/9] comminting the error file --- error_example.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 error_example.py diff --git a/error_example.py b/error_example.py new file mode 100644 index 0000000..012edf5 --- /dev/null +++ b/error_example.py @@ -0,0 +1,33 @@ +# Syntax error - missing colon +def greet(name) + print("Hello,", name) + +# Linting error - using single quotes instead of double quotes +print('This is a linting error') + +# Syntax error - invalid syntax in print statement +print("This will cause a syntax error" # missing closing parenthesis + +# Linting error - unused variable +x = 10 + +# Syntax error - invalid syntax in variable assignment +y = 10 # Missing semicolon + +# Linting error - indentation error +def my_function(): +print("Indentation error") + +# Syntax error - invalid syntax in function definition +def my_function() # Missing colon + print("This will cause a syntax error") + +# Linting error - line too long +this_is_a_long_variable_name_that_should_be_shortened_to_avoid_line_too_long_error = 10 + +# Syntax error - invalid syntax in if statement +if x == 10 # Missing colon + print("This will cause a syntax error") + +# Linting error - multiple imports on one line +import os, sys From c9c14eb94d1bb7f19dd46a70bab54adf1ee050c3 Mon Sep 17 00:00:00 2001 From: Priyanshu Shukla <78398690+priyxnshuuu@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:19:17 +0530 Subject: [PATCH 2/9] adding yaml file to the project --- .github/workflows/pr_agent.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/pr_agent.yml diff --git a/.github/workflows/pr_agent.yml b/.github/workflows/pr_agent.yml new file mode 100644 index 0000000..7efeb09 --- /dev/null +++ b/.github/workflows/pr_agent.yml @@ -0,0 +1,20 @@ +on: + pull_request: + types: [opened, reopened, ready_for_review] + issue_comment: +jobs: + pr_agent_job: + if: ${{ github.event.sender.type != 'Bot' }} + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + contents: write + name: Run pr agent on every pull request, respond to user comments + steps: + - name: PR Agent action step + id: pragent + uses: Codium-ai/pr-agent@main + env: + OPENAI_KEY: ${{ secrets.OPENAI_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 8a9a0f382a7f43caa31c451ae717984af1241f03 Mon Sep 17 00:00:00 2001 From: Priyanshu Shukla <78398690+priyxnshuuu@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:30:46 +0530 Subject: [PATCH 3/9] add --- .github/workflows/code-review-gpt.yml | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/code-review-gpt.yml diff --git a/.github/workflows/code-review-gpt.yml b/.github/workflows/code-review-gpt.yml new file mode 100644 index 0000000..8bea574 --- /dev/null +++ b/.github/workflows/code-review-gpt.yml @@ -0,0 +1,33 @@ +name: Code Review GPT + +on: + pull_request: + branches: [main] + +permissions: + pull-requests: write + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install code-review-gpt + run: npm install code-review-gpt + + - name: Run code review script + run: npx code-review-gpt review --ci=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + GITHUB_SHA: ${{ github.sha }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From d45d992d6207d23eaf2b8af9d1b63d05fbd27b03 Mon Sep 17 00:00:00 2001 From: Priyanshu Shukla <78398690+priyxnshuuu@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:32:03 +0530 Subject: [PATCH 4/9] add --- .github/workflows/code-review-gpt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-review-gpt.yml b/.github/workflows/code-review-gpt.yml index 8bea574..eaf390c 100644 --- a/.github/workflows/code-review-gpt.yml +++ b/.github/workflows/code-review-gpt.yml @@ -2,7 +2,7 @@ name: Code Review GPT on: pull_request: - branches: [main] + branches: [master] permissions: pull-requests: write From 8d9595ec2f6aeefd94f1fca82ab2817392172fd9 Mon Sep 17 00:00:00 2001 From: Priyanshu Shukla <78398690+priyxnshuuu@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:34:56 +0530 Subject: [PATCH 5/9] add --- .github/workflows/code-review-gpt.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/code-review-gpt.yml b/.github/workflows/code-review-gpt.yml index eaf390c..3249df1 100644 --- a/.github/workflows/code-review-gpt.yml +++ b/.github/workflows/code-review-gpt.yml @@ -28,6 +28,5 @@ jobs: run: npx code-review-gpt review --ci=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} - GITHUB_SHA: ${{ github.sha }} + MODEL: 'gpt-3.5-turbo' OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From c8f504b4be4b29bd281036a88e4f595aac7a771c Mon Sep 17 00:00:00 2001 From: Priyanshu Shukla <78398690+priyxnshuuu@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:36:30 +0530 Subject: [PATCH 6/9] add --- .github/workflows/code-review-gpt.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/code-review-gpt.yml b/.github/workflows/code-review-gpt.yml index 3249df1..1083d0e 100644 --- a/.github/workflows/code-review-gpt.yml +++ b/.github/workflows/code-review-gpt.yml @@ -28,5 +28,7 @@ jobs: run: npx code-review-gpt review --ci=github env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} MODEL: 'gpt-3.5-turbo' + GITHUB_SHA: ${{ github.sha }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From 53d3024184c98b2ed075d53110a6c438f48f19a1 Mon Sep 17 00:00:00 2001 From: mohit-zangoh Date: Mon, 15 Apr 2024 15:32:50 +0530 Subject: [PATCH 7/9] cummit 1 --- .github/workflows/reviewdog.yml | 274 ++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 .github/workflows/reviewdog.yml diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..57f9b5e --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,274 @@ +name: reviewdog +on: + push: + branches: + - master + pull_request: + +jobs: + reviewdog-github-check: + permissions: + checks: write + contents: read + pull-requests: write + name: reviewdog (github-check) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Install linters + run: go install golang.org/x/lint/golint@latest + + - name: Setup reviewdog + # uses: reviewdog/action-setup@v1 + run: | + go install ./cmd/reviewdog + + - name: Run reviewdog + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + golint ./... | reviewdog -f=golint -name=golint-github-check -reporter=github-check -level=warning + + - name: Run reviewdog with sub-dir (github-check) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-check-subdir -reporter=github-check -level=info -filter-mode=nofilter + + - name: Custom rdjson test (github-check) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cat ./_testdata/custom_rdjson.json | \ + reviewdog -name="custom-rdjson" -f=rdjson -reporter=github-check -level=info + + reviewdog-pr: + permissions: + checks: write + contents: read + pull-requests: write + if: github.event_name == 'pull_request' + name: reviewdog on Pull Request + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Install linters + run: go install golang.org/x/lint/golint@latest + + - name: Setup reviewdog + # uses: reviewdog/action-setup@v1 + run: | + go install ./cmd/reviewdog + + - name: Run reviewdog (github-pr-check) + continue-on-error: true + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + reviewdog -reporter=github-pr-check -runners=golint,govet -fail-on-error + + - name: Run reviewdog (github-pr-review with tee) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Remove Go Problem Matchers [1] as it reports duplicate results with + # reviewdog. + # [1]: https://github.com/actions/toolkit/blob/master/docs/commands.md#problem-matchers + echo "::remove-matcher owner=go::" + golint ./... | reviewdog -f=golint -name=golint-pr-review -reporter=github-pr-review -tee + + - name: Run reviewdog with sub-dir (github-pr-review) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-pr-review-subdir -reporter=github-pr-review -tee + + - name: Run reviewdog with sub-dir (local+fail-on-error) + run: | + echo 'var LocalTest = 14' >> ./_testdata/golint.go + cd ./_testdata/ && golint ./... | reviewdog -f=golint -diff="git diff" -fail-on-error || EXIT_CODE=$? + git reset --hard @ + test "${EXIT_CODE}" = 1 + + - name: Run reviewdog (github-pr-check with fail-on-error) + continue-on-error: true + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-pr-check-fail-on-error -reporter=github-pr-check -fail-on-error + + - name: Run reviewdog (github-pr-check with -filter-mode=file) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + golint | reviewdog -f=golint -name=golint-pr-check-filter-mode-file -reporter=github-pr-check -filter-mode=file -level=warning + + - name: Run reviewdog (github-pr-review -filter-mode=nofilter) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-pr-review-nofilter -reporter=github-pr-review -filter-mode=nofilter -fail-on-error || EXIT_CODE=$? + test "${EXIT_CODE}" = 1 + + - name: Unexpected failure (github-pr-review) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd ./_testdata/ && reviewdog -conf=reviewdog_error.yml \ + -reporter=github-pr-review || EXIT_CODE=$? + test "${EXIT_CODE}" = 1 + - name: Unexpected failure (github-check) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd ./_testdata/ && reviewdog -conf=reviewdog_error.yml \ + -reporter=github-check || EXIT_CODE=$? + test "${EXIT_CODE}" = 1 + - name: Unexpected failure (local) + run: | + cd ./_testdata/ && reviewdog -conf=reviewdog_error.yml \ + -reporter=local -diff='git diff master' || EXIT_CODE=$? + test "${EXIT_CODE}" = 1 + - name: Suggestion (rdjsonl) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cat ./_testdata/suggestions.json | \ + reviewdog -name="suggestion-test" -f=rdjsonl -reporter=github-pr-review + + - name: Custom rdjsonl test (github-pr-review) + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cat ./_testdata/custom_rdjson.json | \ + reviewdog -name="custom-rdjson" -f=rdjson -reporter=github-pr-review + + - name: gofmt -s with reviewdog + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gofmt -s -d . | \ + reviewdog -name="gofmt" -f=diff -f.diff.strip=0 -reporter=github-pr-review + + golangci-lint: + permissions: + checks: write + contents: read + pull-requests: write + if: github.event_name == 'pull_request' + name: runner / golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-golangci-lint@v2 + with: + github_token: ${{ secrets.github_token }} + golangci_lint_flags: "--timeout 2m" + level: "warning" + reporter: github-pr-check + + staticcheck: + permissions: + checks: write + contents: read + pull-requests: write + if: github.event_name == 'pull_request' + name: runner / staticcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + - uses: reviewdog/action-staticcheck@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + filter_mode: nofilter + fail_on_error: true + # workdir: ./_testdata/ + + misspell: + name: runner / misspell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-misspell@v1 + with: + github_token: ${{ secrets.github_token }} + locale: "US" + reporter: github-check + + languagetool: + name: runner / languagetool + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-languagetool@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + level: info + patterns: | + **/*.md + !**/testdata/** + + shellcheck: + if: github.event_name == 'pull_request' + name: runner / shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-shellcheck@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + + alex: + name: runner / alex + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-alex@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + level: info + + textlint: + name: runner / textlint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-setup@v1 + - run: npm install + - name: textlint + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + npx textlint -f checkstyle README.md | \ + reviewdog -f=checkstyle -name="textlint" -reporter=github-check -level=info + + sarif: + name: runner / textlint sarif + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-setup@v1 + - run: npm install + - name: textlint sarif + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + npx textlint -f @microsoft/eslint-formatter-sarif README.md | \ + reviewdog -f=sarif -name="textlint" -reporter=github-check -level=info \ No newline at end of file From ea1ba09815514654b485d6e039dd842c94f419fb Mon Sep 17 00:00:00 2001 From: mohit-zangoh Date: Mon, 15 Apr 2024 15:47:28 +0530 Subject: [PATCH 8/9] commit2 --- .github/workflows/reviewdog.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 57f9b5e..a240c41 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -271,4 +271,5 @@ jobs: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | npx textlint -f @microsoft/eslint-formatter-sarif README.md | \ - reviewdog -f=sarif -name="textlint" -reporter=github-check -level=info \ No newline at end of file + reviewdog -f=sarif -name="textlint" -reporter=github-check -level=info + \ No newline at end of file From 18aa0cfdc73fb4c21bac43deafc5aaa4981da9b2 Mon Sep 17 00:00:00 2001 From: mohit-zangoh Date: Mon, 15 Apr 2024 16:06:44 +0530 Subject: [PATCH 9/9] commit3 --- go.mod | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..dc72a30 --- /dev/null +++ b/go.mod @@ -0,0 +1,70 @@ +module github.com/reviewdog/reviewdog + +go 1.21.7 + +require ( + cloud.google.com/go/compute/metadata v0.2.3 + cloud.google.com/go/datastore v1.15.0 + code.gitea.io/sdk/gitea v0.17.1 + contrib.go.opencensus.io/exporter/stackdriver v0.13.12 + github.com/bradleyfalzon/ghinstallation/v2 v2.10.0 + github.com/golang/protobuf v1.5.4 + github.com/google/go-cmp v0.6.0 + github.com/google/go-github/v60 v60.0.0 + github.com/google/go-github/v61 v61.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.1 + github.com/kylelemons/godebug v1.1.0 + github.com/mattn/go-shellwords v1.0.12 + github.com/rakyll/statik v0.1.7 + github.com/reva2/bitbucket-insights-api v1.0.0 + github.com/reviewdog/errorformat v0.0.0-20240311054359-739e471a49b3 + github.com/reviewdog/go-bitbucket v0.0.0-20201024094602-708c3f6a7de0 + github.com/stretchr/testify v1.9.0 + github.com/vvakame/sdlog v1.2.0 + github.com/xanzy/go-gitlab v0.102.0 + go.opencensus.io v0.24.0 + golang.org/x/build v0.0.0-20230906094020-6ed658a430ec + golang.org/x/oauth2 v0.19.0 + golang.org/x/sync v0.7.0 + google.golang.org/protobuf v1.33.0 + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + cloud.google.com/go v0.110.7 // indirect + cloud.google.com/go/compute v1.23.0 // indirect + cloud.google.com/go/monitoring v1.15.1 // indirect + cloud.google.com/go/trace v1.10.1 // indirect + github.com/aws/aws-sdk-go v1.43.31 // indirect + github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davidmz/go-pageant v1.0.2 // indirect + github.com/go-fed/httpsig v1.1.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/s2a-go v0.1.4 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect + github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-retryablehttp v0.7.2 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/prometheus v2.5.0+incompatible // indirect + github.com/stretchr/objx v0.5.2 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/api v0.128.0 // indirect + google.golang.org/appengine v1.6.8-0.20221117013220-504804fb50de // indirect + google.golang.org/genproto v0.0.0-20230821184602-ccc8af3d0e93 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect + google.golang.org/grpc v1.57.1 // indirect +)