Skip to content

FR: Ability for process_wrapper to write exit code to a file instead of forwarding it #3771

@blorente

Description

@blorente

Problem

Currently, the process_wrapper forwards the exit code of a given child process. As a result, if the child process fails, so will the process_wrapper, and the action running it.

This makes it impossible to do things like post-processing linter outputs.

Specifically, I want to call rust_clippy_action from my own rules (rules_lint). I want to do some post-processing to clippy's output in a further action down the line (e.g. to generate reports in a different format). Clippy may generate both warnings and errors, and return with a non-zero code if there is at least one error.

Imagine my code has one warning and one error. I have two options:

  • Let the entire build fail because there was one error, or
  • Demote all errors to warnings so that clippy succeeds, which loses me information about which problems were actually errors.

Proposal

I'd like to add two arguments to process_wrapper:

  • --forward-exit-code (boolean): If set, the process_wrapper will exit with the same exit code as the subprocess if it had no internal errors.
  • --exit-code-file (String): If set, the exit code of the child process will be written to this file. Unset by default.

This allows callers a lot more control over how they want to treat errors, and should be an invisible change for existing users.

However, it touches a fundamental API ( the process_wrapper), so I thought better to ask first: Would this be an acceptable change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions