Problems

Mint can scan the output of tasks for problems associated to specific lines of code, such as linter or compiler errors. The Mint UI will highlight the problems each task produces, making it easy to see what issues caused a task to fail at a glance.

Mint can detect problems from log output and from files written to the filesystem.

Detecting problems from log output

To scan log output for problems, you can configure Mint to use problem matchers, which are regex patterns that produce structured data. Mint uses the same configuration format as GitHub Action's Problem Matchers.

Mint has several built-in problem matchers:

  • eslint: Create problems from ESLint linter errors and warnings.
  • erb-lint: Create problems from erb-lint linters errors and warnings.
  • rubocop: Create problems from Rubocop linter errors and warnings.
  • shellcheck: Create problems from ShellCheck linter errors and warnings.
  • tsc: Create problems from errors and warnings produced by the TypeScript compiler.

You can specify which built-in problem matchers you want to use in the outputs section of a task, like so:

tasks:
  - key: lint
    run: npm run lint
    outputs:
      problems:
        - matcher: eslint

If you want to use a problem matcher that is not built into Mint, you can also specify a URL to a problem matcher, like so:

tasks:
  - key: lint
    run: npm run lint
    outputs:
      problems:
        - matcher: https://raw.githubusercontent.com/actions/setup-node/8f152de45cc393bb48ce5d89d36b731f54556e65/.github/eslint-stylish.json

Detecting problems from a file

Some linting tools support writing files containing the issues they detect. You can configure Mint to read files after your task completes and generate problems based on those files.

Mint currently supports three different file formats for generating problems:

  • Mint Problem JSON
  • GitHub Annotations JSON
  • GitHub Actions annotations-action JSON

The schema of each of these formats is detailed below. To detect problems from a file, you can configure the outputs section of a task like so:

tasks:
  - key: write-problem
    run: |
      echo '[{"file": "path/to/file.js", "line": 5, "owner": "owner", "message": "my message", "severity": "error", "code": "XYZ"}]' > ./problem.json
    outputs:
      problems:
        - path: problem.json

Mint will automatically detect the format of your file and parse it appropriately.

Mint Problem JSON

Mint's native problem format follows the following schema:

type Problem = {
  owner: string
  message: string
  severity: 'error' | 'warning' | 'info'
  code?: string
  file?: string
  fromPath?: string
  line?: number
  column?: number
  end_line?: number
  end_column?: number
}
type MintProblemJson = Problem[]

For example:

[
  {
    "owner": "my-lint-tool",
    "message": "my message",
    "severity": "error",
    "code": "MYTOOL-500",
    "file": "path/to/file.js",
    "line": 5,
    "column": 3
  }
]

GitHub Annotations JSON

Mint supports the format used by the GitHub API for GitHub annotations, which follows this schema:

type GitHubAnnotation = {
  path: string
  message: string
  end_line: number
  start_line: number
  annotation_level: 'warning' | 'failure' | 'notice'
  title?: string | undefined
  end_column?: number | undefined
  start_column?: number | undefined
  raw_details?: string | undefined
  blob_href?: string | undefined
}
type GitHubAnnotationJson = GitHubAnnotation[]

For example:

[
  {
    "path": "path/to/file.js",
    "message": "my message",
    "end_line": 4,
    "start_line": 4,
    "annotation_level": "failure",
    "title": "my-tool",
    "start_column": 3
  }
]

GitHub Actions annotations-action JSON

Mint supports the format used by the GitHub Actions reusable action annotations-action, which follows this schema:

type GitHubAnnotationsActionPayload = {
  message: string
  annotation_level: 'warning' | 'failure' | 'notice'
  path?: string | undefined
  title?: string | undefined
  file?: string | undefined
  line?: number | undefined
  end_line?: number | undefined
  end_column?: number | undefined
  start_line?: number | undefined
  start_column?: number | undefined
  raw_details?: string | undefined
  blob_href?: string | undefined
}
type GitHubAnnotationsActionJson = GitHubAnnotationsActionPayload[]

For example:

[
  {
    "message": "my message",
    "annotation_level": "failure",
    "path": "path/to/file.js",
    "title": "my-tool",
    "line": 4,
    "start_column": 3
  }
]