Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow buf lint action to show warnings but still pass #11

Closed
commure-stabai opened this issue Jan 14, 2022 · 1 comment
Closed

Allow buf lint action to show warnings but still pass #11

commure-stabai opened this issue Jan 14, 2022 · 1 comment

Comments

@commure-stabai
Copy link

The bufbuild/buf-lint-action@v1 action currently causes the job that calls it to fail if there are any lint problems. Since these lint problems may not be mandatory fixes (especially if they're preexisting problems), it would be nice if the action had an input that causes it not to fail.

It is treated as a failure because the linter is very reasonably returning a nonzero exit code, which GitHub interprets as a failure, so this status would need to be caught. There is also the question of whether the ::warning signal should be used instead of ::error in this case, but that doesn't appear to govern any GitHub workflow functionality.

@lrewega
Copy link
Member

lrewega commented Jan 14, 2022

Since these lint problems may not be mandatory fixes (especially if they're preexisting problems),

You may find configuring buf lint to ignore preexisting problems to be a better solution than ignoring the exit status. You can generate the necessary configuration by running buf lint --error-format=config-ignore-yaml. For example, if you don't yet have a buf.yaml you can run buf lint --error-format=config-ignore-yaml | tee buf.yaml and then further customize the used or ignored lint rules as you see fit.

it would be nice if the action had an input that causes it not to fail.

If ignoring existing lint problems doesn't work for you, there are a number of ways to customize how the failure is handled within the workflow for a job or step, such as:

  • Set job.<job_id>.continue-on-error or job.<job_id>.steps[*].continue-on-error within the job or step respectively. For example, to allow buf-lint job to succeed if the bufbuild/buf-lint-action@v1 step from fails:

      jobs:
        buf-lint:
          runs-on: ubuntu-latest
          steps:
            - uses: actions/checkout@v2
            - uses: bufbuild/buf-setup-action@v0.5.0
            - uses: bufbuild/buf-lint-action@v1
    +         continue_on_error: true
  • Use job.<job_id>.if or job.<job_id>.steps[*].if to ignore the previous job or step failure. For example, to run the following step regardless:

      jobs:
        lint:
          runs-on: ubuntu-latest
          steps:
            - uses: actions/checkout@v2
            - uses: bufbuild/buf-setup-action@v0.5.0
            - uses: bufbuild/buf-lint-action@v1
            - name: more linting
    +         if: always() 
              run: make lint   

    though !cancelled() might be better than always() if you want to respect workflow cancellation.

I hope this helps! If not, please let us know by reopening this issue.

@lrewega lrewega closed this as completed Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants