Skip to content

Allow custom buf.yaml file for lintingΒ #243

@apodznoev

Description

@apodznoev

Currently, the plugin performs linting like:

 runBufCommand(
                        project,
                        owner,
                        workingDirectory,
                        listOf("lint", "--error-format=json"),
                        expectedExitCodes = setOf(0, BUF_EXIT_CODE_FILE_ANNOTATION),
                    )

using default Buf settings.

In case the project follows a different configuration - e.g. uses buf.yaml with except block:

version: v1
deps:
- buf.build/googleapis/googleapis
breaking:
  ignore_unstable_packages: true
  use:
  - FILE
lint:
  allow_comment_ignores: true
  use:
  - COMMENTS
  - DEFAULT
  - PACKAGE_NO_IMPORT_CYCLE
  - UNARY_RPC
  except:
  - RPC_RESPONSE_STANDARD_NAME
  - RPC_REQUEST_RESPONSE_UNIQUE

The plugin reports a warning with a suggestion to apply a fix, which contradicts the project's configuration.

A solution would be to provide a setting with path to buf.yaml to be used for lining.

E.g.

configFileContent = readFrom(project.bufSettings.state.bufConfigPath)
 runBufCommand(
                        project,
                        owner,
                        workingDirectory,
                        listOf("lint", "--error-format=json", "--config="+configFileContent),
                        expectedExitCodes = setOf(0, BUF_EXIT_CODE_FILE_ANNOTATION),
                    )

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