github.com/massongit/reviewdog@v0.0.0-20240331071725-4a16675475a8/.github/workflows/reviewdog.yml (about) 1 name: reviewdog 2 on: 3 push: 4 branches: 5 - master 6 pull_request: 7 8 jobs: 9 reviewdog-github-check: 10 permissions: 11 checks: write 12 contents: read 13 pull-requests: write 14 name: reviewdog (github-check) 15 runs-on: ubuntu-latest 16 steps: 17 - uses: actions/checkout@v4 18 19 - uses: actions/setup-go@v5 20 with: 21 go-version-file: "go.mod" 22 23 - name: Install linters 24 run: go install golang.org/x/lint/golint@latest 25 26 - name: Setup reviewdog 27 # uses: reviewdog/action-setup@v1 28 run: | 29 go install ./cmd/reviewdog 30 31 - name: Run reviewdog 32 env: 33 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 run: | 35 golint ./... | reviewdog -f=golint -name=golint-github-check -reporter=github-check -level=warning 36 37 - name: Run reviewdog with sub-dir (github-check) 38 env: 39 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 run: | 41 cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-check-subdir -reporter=github-check -level=info -filter-mode=nofilter 42 43 - name: Custom rdjson test (github-check) 44 env: 45 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 46 run: | 47 cat ./_testdata/custom_rdjson.json | \ 48 reviewdog -name="custom-rdjson" -f=rdjson -reporter=github-check -level=info 49 50 reviewdog-pr: 51 permissions: 52 checks: write 53 contents: read 54 pull-requests: write 55 if: github.event_name == 'pull_request' 56 name: reviewdog on Pull Request 57 runs-on: ubuntu-latest 58 steps: 59 - uses: actions/checkout@v4 60 61 - uses: actions/setup-go@v5 62 with: 63 go-version-file: "go.mod" 64 65 - name: Install linters 66 run: go install golang.org/x/lint/golint@latest 67 68 - name: Setup reviewdog 69 # uses: reviewdog/action-setup@v1 70 run: | 71 go install ./cmd/reviewdog 72 73 - name: Run reviewdog (github-pr-check) 74 continue-on-error: true 75 env: 76 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 77 run: | 78 reviewdog -reporter=github-pr-check -runners=golint,govet -fail-on-error 79 80 - name: Run reviewdog (github-pr-review with tee) 81 env: 82 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 83 run: | 84 # Remove Go Problem Matchers [1] as it reports duplicate results with 85 # reviewdog. 86 # [1]: https://github.com/actions/toolkit/blob/master/docs/commands.md#problem-matchers 87 echo "::remove-matcher owner=go::" 88 golint ./... | reviewdog -f=golint -name=golint-pr-review -reporter=github-pr-review -tee 89 90 - name: Run reviewdog with sub-dir (github-pr-review) 91 env: 92 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 93 run: | 94 cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-pr-review-subdir -reporter=github-pr-review -tee 95 96 - name: Run reviewdog with sub-dir (local+fail-on-error) 97 run: | 98 echo 'var LocalTest = 14' >> ./_testdata/golint.go 99 cd ./_testdata/ && golint ./... | reviewdog -f=golint -diff="git diff" -fail-on-error || EXIT_CODE=$? 100 git reset --hard @ 101 test "${EXIT_CODE}" = 1 102 103 - name: Run reviewdog (github-pr-check with fail-on-error) 104 continue-on-error: true 105 env: 106 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 107 run: | 108 cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-pr-check-fail-on-error -reporter=github-pr-check -fail-on-error 109 110 - name: Run reviewdog (github-pr-check with -filter-mode=file) 111 env: 112 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 113 run: | 114 golint | reviewdog -f=golint -name=golint-pr-check-filter-mode-file -reporter=github-pr-check -filter-mode=file -level=warning 115 116 - name: Run reviewdog (github-pr-review -filter-mode=nofilter) 117 env: 118 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 119 run: | 120 cd ./_testdata/ && golint ./... | reviewdog -f=golint -name=golint-pr-review-nofilter -reporter=github-pr-review -filter-mode=nofilter -fail-on-error || EXIT_CODE=$? 121 test "${EXIT_CODE}" = 1 122 123 - name: Unexpected failure (github-pr-review) 124 env: 125 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 126 run: | 127 cd ./_testdata/ && reviewdog -conf=reviewdog_error.yml \ 128 -reporter=github-pr-review || EXIT_CODE=$? 129 test "${EXIT_CODE}" = 1 130 - name: Unexpected failure (github-check) 131 env: 132 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 133 run: | 134 cd ./_testdata/ && reviewdog -conf=reviewdog_error.yml \ 135 -reporter=github-check || EXIT_CODE=$? 136 test "${EXIT_CODE}" = 1 137 - name: Unexpected failure (local) 138 run: | 139 cd ./_testdata/ && reviewdog -conf=reviewdog_error.yml \ 140 -reporter=local -diff='git diff master' || EXIT_CODE=$? 141 test "${EXIT_CODE}" = 1 142 - name: Suggestion (rdjsonl) 143 env: 144 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 145 run: | 146 cat ./_testdata/suggestions.json | \ 147 reviewdog -name="suggestion-test" -f=rdjsonl -reporter=github-pr-review 148 149 - name: Custom rdjsonl test (github-pr-review) 150 env: 151 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 152 run: | 153 cat ./_testdata/custom_rdjson.json | \ 154 reviewdog -name="custom-rdjson" -f=rdjson -reporter=github-pr-review 155 156 - name: gofmt -s with reviewdog 157 env: 158 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 159 run: | 160 gofmt -s -d . | \ 161 reviewdog -name="gofmt" -f=diff -f.diff.strip=0 -reporter=github-pr-review 162 163 golangci-lint: 164 permissions: 165 checks: write 166 contents: read 167 pull-requests: write 168 if: github.event_name == 'pull_request' 169 name: runner / golangci-lint 170 runs-on: ubuntu-latest 171 steps: 172 - uses: actions/checkout@v4 173 - uses: reviewdog/action-golangci-lint@v2 174 with: 175 github_token: ${{ secrets.github_token }} 176 golangci_lint_flags: "--timeout 2m" 177 level: "warning" 178 reporter: github-pr-check 179 180 staticcheck: 181 permissions: 182 checks: write 183 contents: read 184 pull-requests: write 185 if: github.event_name == 'pull_request' 186 name: runner / staticcheck 187 runs-on: ubuntu-latest 188 steps: 189 - uses: actions/checkout@v4 190 - uses: actions/setup-go@v5 191 with: 192 go-version-file: "go.mod" 193 - uses: reviewdog/action-staticcheck@v1 194 with: 195 github_token: ${{ secrets.github_token }} 196 reporter: github-pr-review 197 filter_mode: nofilter 198 fail_on_error: true 199 # workdir: ./_testdata/ 200 201 misspell: 202 name: runner / misspell 203 runs-on: ubuntu-latest 204 steps: 205 - uses: actions/checkout@v4 206 - uses: reviewdog/action-misspell@v1 207 with: 208 github_token: ${{ secrets.github_token }} 209 locale: "US" 210 reporter: github-check 211 212 languagetool: 213 name: runner / languagetool 214 runs-on: ubuntu-latest 215 steps: 216 - uses: actions/checkout@v4 217 - uses: reviewdog/action-languagetool@v1 218 with: 219 github_token: ${{ secrets.github_token }} 220 reporter: github-check 221 level: info 222 patterns: | 223 **/*.md 224 !**/testdata/** 225 226 shellcheck: 227 if: github.event_name == 'pull_request' 228 name: runner / shellcheck 229 runs-on: ubuntu-latest 230 steps: 231 - uses: actions/checkout@v4 232 - uses: reviewdog/action-shellcheck@v1 233 with: 234 github_token: ${{ secrets.github_token }} 235 reporter: github-pr-review 236 237 alex: 238 name: runner / alex 239 runs-on: ubuntu-latest 240 steps: 241 - uses: actions/checkout@v4 242 - uses: reviewdog/action-alex@v1 243 with: 244 github_token: ${{ secrets.github_token }} 245 reporter: github-check 246 level: info 247 248 textlint: 249 name: runner / textlint 250 runs-on: ubuntu-latest 251 steps: 252 - uses: actions/checkout@v4 253 - uses: reviewdog/action-setup@v1 254 - run: npm install 255 - name: textlint 256 env: 257 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 258 run: | 259 npx textlint -f checkstyle README.md | \ 260 reviewdog -f=checkstyle -name="textlint" -reporter=github-check -level=info 261 262 sarif: 263 name: runner / textlint sarif 264 runs-on: ubuntu-latest 265 steps: 266 - uses: actions/checkout@v4 267 - uses: reviewdog/action-setup@v1 268 - run: npm install 269 - name: textlint sarif 270 env: 271 REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} 272 run: | 273 npx textlint -f @microsoft/eslint-formatter-sarif README.md | \ 274 reviewdog -f=sarif -name="textlint" -reporter=github-check -level=info