hauleth / mix_machine

Machine output for Mix tasks
MIT License
16 stars 1 forks source link
code-quality codeclimate elixir elixir-lang hacktoberfest mix sarif sarif-report

MixMachine

Make Mix compilation produce report that is machine-readable.

Currently supported formats:

Usage

Add it to list of your dependencies:

def deps do
  [
    {:mix_machine, "~> 0.1.0"}
  ]
end

And now you can use:

$ mix compile.machine

That will produce report.json with SARIF format.

Configration

Current behaviour can be controlled by few flags:

In addition to CLI flags these options can be set in project/0 function in mix.exs in :machine keyword list (it has lower precedence than CLI flags):

Example

def project do
  [
    # …
    machine: [
      format: :code_climate,
      output: "codeclimate.json",
      pretty: true,
      root: ".."
    ]
  ]

Usage in GitHub Actions

In your github .yml file, after you download Elixir deps, compile your project with mix mix_machine.compile.

    - name: Compile Deps
      run: mix deps.compile
    - name: Compile Project
      run: mix compile.machine

Note: This must come before any other lines that would inadvertently compile your code such as mix test!

Note: the mix deps.compile in a separate step is not required but it can be helpful to separate any compilation warnings in your project from any compilation warnings in your deps.

Then later in the .yml file add this to upload your Sarif file to your GitHub repository:

    - name: Upload Sarif
      uses: github/codeql-action/upload-sarif@v1
      with:
        sarif_file: report.json

License

See LICENSE.