clippy-check icon indicating copy to clipboard operation
clippy-check copied to clipboard

Support outputing raw 'clippy' output into a file

Open taufik-rama opened this issue 3 years ago • 2 comments

Do the checklist before filing an issue:

  • [X] Is this related to the actions-rs Actions? If you think it's a problem related to Github Actions in general, use GitHub Community forum instead: https://github.community
  • [X] You've read the Contributing section about feature requests: https://github.com/actions-rs/.github/blob/master/CONTRIBUTING.md#feature-requests
  • [ ] Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome.

Motivation

Basically what the title said, I think it's nice to add support so that the raw output of cargo clippy is stored in a file

Workflow example

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Clippy check
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-features
          output: clippy.json # this new attribute

Additional context

Currently I'm trying to integrate some rust projects with SonarQube action. It needs the clippy output to be parsed & sent into the server

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      # ...
      - name: Code Analysis
        uses: sonarsource/sonarqube-scan-action@master
        with:
          args: -Dsonar.rust.clippy.reportPaths=clippy.json # this is the `cargo clippy` output

Currently I'm only able to do that by basically re-running the cargo clippy command & storing the output

  build:
    runs-on: ubuntu-latest

    steps:
      # ...
      - name: Clippy check (file)
        run: cargo clippy --message-format=json > clippy.json

It would be nice if this action could store the raw output somewhere. For the implementation I could think that a simple tee command could do the trick, like:

$ cargo clippy --message-format=json | tee clippy.json

Would basically produce the same output as usual into stdout & also into a file clippy.json

taufik-rama avatar Sep 20 '21 02:09 taufik-rama

For the third checklist, I'll try to see how it could be done on the source code

taufik-rama avatar Sep 20 '21 02:09 taufik-rama

Seems more complicated than I imagine :sweat_smile: , I don't usually use current build system

Other approach that I thought might be possible is to add an input that points to the raw $ cargo clippy output file instead, and we could just read that file instead of doing the exec of cargo inside the script

taufik-rama avatar Sep 20 '21 06:09 taufik-rama