actions-rs / clippy-check

📎 GitHub Action for PR annotations with clippy warnings
https://github.com/marketplace/actions/rust-clippy-check
MIT License
288 stars 41 forks source link

fix: @actions/core's `stdline` + `clippy` + Windows = :(, use manual LF splitting #102

Open ErichDonGubler opened 4 years ago

ErichDonGubler commented 4 years ago

Currently, running clippy-check on a windows-latest runner will fail to generate any report items because NodeJS' os.EOL is set to CRLF line endings (which the stdline listener in @actions/exec uses for line buffering), and clippy only emits LF line endings.

Fix this by using the stdout listener instead with a modified version of @action/exec's line-buffering algorithm that only uses LF line endings.


I first noticed this issue when I saw that the clippy check in a proprietary NZXTCorp repo was failing, but with no items shown in the generated report.

While this PR is active I will keep my clippy-check-windows-lf-failures repo open as an MRE, so that I can demonstrate the breakage and fix proposed here via failed public repo checks. For convenience, the interesting files of the repo are inlined below:

on: [push]

jobs:
  fail:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install minimal Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.45.2-x86_64-pc-windows-msvc
          profile: minimal
          components: clippy
      - uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d
        # ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        # |
        # \ compare to upstream `master` branch at time of bug
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          name: fail-clippy-report
  fix:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install minimal Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.45.2-x86_64-pc-windows-msvc
          profile: minimal
          components: clippy
      - uses: ErichDonGubler/clippy-check@fix-windows-lf-breaking-reports
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          name: fix-clippy-report
fn main() {
    // Trigger the [`approx_constant`][lint] lint from `clippy` on purpose.
    // [lint]: https://rust-lang.github.io/rust-clippy/master/#approx_constant
    println!("{}", 3.14);
}