Giter Site home page Giter Site logo

reviewdog / action-staticcheck Goto Github PK

View Code? Open in Web Editor NEW
19.0 29.0 2.0 80 KB

๐Ÿถ Run staticcheck with reviewdog on pull requests to improve code review experience.

Home Page: https://github.com/marketplace?type=actions&query=reviewdog

License: MIT License

Shell 74.32% jq 25.68%

action-staticcheck's Introduction

action-staticcheck

Test reviewdog depup release GitHub release (latest SemVer) action-bumpr supported

This action runs staticcheck with reviewdog on pull requests to improve code review experience.

github-pr-review demo Link to the staticcheck check rule is available as well. e.g. SA9004

Input

inputs:
  github_token:
    description: 'GITHUB_TOKEN'
    default: '${{ github.token }}'
  workdir:
    description: 'Working directory relative to the root directory.'
    default: '.'
  ### Flags for reviewdog ###
  level:
    description: 'Report level for reviewdog [info,warning,error]'
    default: 'error'
  reporter:
    description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].'
    default: 'github-pr-check'
  filter_mode:
    description: |
      Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
      Default is added.
    default: 'added'
  fail_on_error:
    description: |
      Exit code for reviewdog when errors are found [true,false]
      Default is `false`.
    default: 'false'
  reviewdog_flags:
    description: 'Additional reviewdog flags'
    default: ''
  ### Flags for staticcheck ###
  target:
    description: 'Target of staticcheck'
    default: './...'
  staticcheck_flags:
    description: 'staticcheck flags'
    default: ''

Usage

name: reviewdog
on: [pull_request]
jobs:
  staticcheck:
    name: runner / staticcheck
    runs-on: ubuntu-latest
    steps:
      # checkout code
      - uses: actions/checkout@v4

      # If you want to use the specific version of Go,
      # you need actions/setup-go@v4 action.
      - uses: actions/setup-go@v4
        with:
          go-version: "1.21"

      # run staticcheck
      - uses: reviewdog/action-staticcheck@v1
        with:
          github_token: ${{ secrets.github_token }}
          # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
          reporter: github-pr-review
          # Report all results.
          filter_mode: nofilter
          # Exit with 1 when it find at least one finding.
          fail_on_error: true

Development

Release

You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch). Pushing tag manually by yourself also work.

This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3. ref: https://help.github.com/en/articles/about-actions#versioning-your-action

Lint - reviewdog integration

This reviewdog action template itself is integrated with reviewdog to run lints which is useful for Docker container based actions.

reviewdog integration

Supported linters:

Dependencies Update Automation

This repository uses haya14busa/action-depup to update reviewdog version.

reviewdog depup demo

action-staticcheck's People

Contributors

github-actions[bot] avatar haya14busa avatar jackton1 avatar kstiehl avatar oksana-grishchenko avatar renovate-bot avatar renovate[bot] avatar review-dog avatar shogo82148 avatar sksat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

action-staticcheck's Issues

Go 1.18

staticcheck already supports go 1.18, but review dog doesn't

Is there a release on the way?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/depup.yml
  • actions/checkout v4.1.5@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
  • haya14busa/action-depup v1
  • peter-evans/create-pull-request v6
.github/workflows/release.yml
  • actions/checkout v4.1.5@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
  • haya14busa/action-bumpr v1
  • haya14busa/action-update-semver v1
  • haya14busa/action-cond v1
  • actions/checkout v4.1.5@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
  • haya14busa/action-bumpr v1
.github/workflows/reviewdog.yml
  • actions/checkout v4.1.5@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
  • haya14busa/action-cond v1
  • reviewdog/action-shellcheck v1
  • actions/checkout v4.1.5@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
  • reviewdog/action-misspell v1
.github/workflows/test.yml
  • actions/checkout v4.1.5@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
  • actions/setup-go v5
  • actions/checkout v4.1.5@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
  • actions/setup-go v5

  • Check this box to trigger a request for Renovate to run again on this repository

Should this be failing if there is an issue in a filtered finding?

I'm seeing this behavior:

Screen Shot 2020-11-09 at 3 49 44 PM

With this config:

  staticcheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: reviewdog/action-staticcheck@v1
        with:
          github_token: ${{ secrets.github_token }}
          reporter: github-check

Is it expected to fail a PR if there are no newly introduced lint issues?

Do not use latest staticcheck version (or/and support specifying staticcheck version)

This is a follow-up to #16.

It's safer to use a fixed staticcheck version and automate updating it with depup instead of installing the latest version.

Optionally, we can also support specifying the staticcheck version as an action input.
Personally, I don't like this option so much because ...

  1. Generally it's good to use the latest version so that users can enjoy the latest improved version of staticcheck.
  2. Most users won't notice and could forget the new version of staticcheck if we put this as an action input. Users can use action-depup to update the staticcheck version input, but probably it's too much work.
  3. It would be hard to maintain the script in this action. Suppose a new staticcheck introduced new flags or breaking changes, it's difficult to update the script if users pass an old version as the input.

Users can still pin the action-staticcheck version to pin staticcheck version or they can manually install staticcheck and reviewdog if they want to stick with an old version.

cc/ @kstiehl @dominikh

@kstiehl, I'd appreciate it if you want to work on this issue but I'll leave it to you :)

fails on golang 1.16 code

i'm getting errors like WriteFile not declared by package os. staticcheck seems to work fine locally.

Needs new release

I have a build failure that I believe indicates that the version of the staticcheck binary was not built with go 1.16 (lint failure on embed package import).

Error pulling private repos

I'm trying to setup this action in a golang project that uses private github repos. I've had success in other cases adding a step to the build to configure authentication using an auth token, but this doesn't seem to work with this action.

name: reviewdog
on: [pull_request]
jobs:
  staticcheck:
    name: runner / staticcheck
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Configure git for private modules
        env:
          TOKEN: ${{ secrets.USER_TOKEN }}
        run: git config --global url."https://my-github-user:${TOKEN}@github.com".insteadOf "https://github.com"
      - uses: reviewdog/action-staticcheck@v1
        with:
          github_token: ${{ secrets.github_token }}
          reporter: github-pr-review
          filter_mode: nofilter
          fail_on_error: true

I've tried setting GIT_TERMINAL_PROMPT=1 in the staticcheck environment and using my token as the github token for staticcheck, both with no success.

The error is as follows, with specific information removed:

err: exit status 1: stderr: go: github.com/Organization/repository@versionref: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/daca67f07b1fc0438808c512647cb396744c1640c17a52da47f378d3533b2fb5: exit status 128:
	fatal: could not read Username for 'github.com': No such device or address

Thanks for any help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.