taiki-e / cargo-hack

Cargo subcommand to provide various options useful for testing and continuous integration.
Apache License 2.0
628 stars 28 forks source link

0.6.6 breaks compatibility piping to formatter in CI #221

Closed PKilcommons closed 1 year ago

PKilcommons commented 1 year ago

I am unsure if this issue makes more sense here or on install-action so please let me know if I should close this issue and reopen over there.

At the risk of this sounding like xkcd 1172, I was wondering if an option could be provided to disable the grouping behaviour added in #219. In our CI we use cargo-action-fmt to provide Github Action formatting for clippy. This worked seamlessly with taiki-e/install-action@cargo-hack, but since v0.6.6 piping to cargo-action-fmt now breaks the pipe. For now we're pinning to v0.6.5.

Here's the job without pinning to v0.6.5 if that helps at all.

    steps:
    - uses: actions/checkout@v4

    - name: Sccache Setup
      uses: mozilla-actions/sccache-action@v0.0.3
      with:
        version: "v0.5.3"

    - name: Install nightly
      uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: nightly
        components: clippy, rustfmt

    - name: Install cargo-hack
      uses: taiki-e/install-action@cargo-hack

    - uses: olix0r/cargo-action-fmt/setup@v2

    - name: Check clippy
      run: cargo hack clippy --all-targets --feature-powerset --message-format=json -Zlints -- -Dwarnings -Adeprecated | cargo-action-fmt

    - name: Check rustfmt
      if: success() || failure()
      run: cargo fmt --all -- --check

If this is not something you wish to support or if there is an existing workaround that I am not aware of, please do let me know.

taiki-e commented 1 year ago

Thanks for the report and sorry for the breakage!

Log grouping can be opt-out using the --log-group=none option, as explained in the changelog and help message.

Ideally, I would like to handle this using tty detection, but GitHub Actions is incompatible with tty detection (https://github.com/actions/runner/issues/241). A reasonable workaround here would be to avoid using log grouping if an option is passed in which stdout is assumed to be used, such as --message-format.

PKilcommons commented 1 year ago

Ah, I completely missed that argument; my fault for not reading closely enough.

Thanks for the quick response, and sorry for the trouble!

taiki-e commented 1 year ago

Fixed in v0.6.8. I have implemented the one mentioned in the above comment.

A reasonable workaround here would be to avoid using log grouping if an option is passed in which stdout is assumed to be used, such as --message-format.