question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GitHub Action or GitHub App/Bot to Lint PRs

See original GitHub issue

Does the DotNet team have any plans of making this a GitHub Action or GitHub Bot?

As it would be good to have this available to lint PRs automatically for us with GitHub Checks API and highlight the items in the GitHub diff view of a PR with using the dry-run option

Where finally you could use the Checks API to Automatically fix the errors & do a commit on a users behalf if they choose that they want to correct it.

https://developer.github.com/apps/quickstart-guides/creating-ci-tests-with-the-checks-api/#step-26-automatically-fixing-rubocop-errors

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:11

github_iconTop GitHub Comments

11reactions
xt0rtedcommented, Mar 5, 2020

I just published my action to the marketplace https://github.com/marketplace/actions/dotnet-format. This can be used to run dotnet-format during your builds to report formatting errors, or to apply fixes and push them back to your branch.

The workflow to trigger via a slash command is a little verbose at the moment. I have a couple changes in the works that will hopefully clean that up some. If/when actions support early job termination without creating an error this will be a lot cleaner.

If you run into any issues or have suggestions open an issue and let me know. Hope this is useful for some of you.

2reactions
xt0rtedcommented, Feb 15, 2020

I’ve been working on a couple actions for doing this. If you’re already running dotnet-format in a workflow and want annotations you can get them by adding my dotnet-format-problem-matcher before you run dotnet-format:

- name: Add dotnet-format problem matcher
  uses: xt0rted/dotnet-format-problem-matcher@v1

The report messages aren’t as useful as those from other tools such as ESLint but it’s a good start. There’s a discussion in #525 about this.

I also have dotnet-tool-restore which will install any .net local tools setup in .config/dotnet-tools.json. I’ve been running this right after actions/setup-dotnet.

- name: Restore dotnet tools
  uses: xt0rted/dotnet-tool-restore@v1

I also have dotnet-format to run the tool but it’s not published yet, should be available later today or tomorrow. One of the nice features of this action is the option to format just the files that have changed so you can limit the scope of your PRs.

With these actions and a couple others I’m running dotnet-format on PRs with --dry-run to report any formatting violations with annotations. Then I have a second workflow that runs on PR comments looking for /dotnet format and will apply the fixes and push them back to the PR branch. I’m having trouble with this setup though because code pushes from GITHUB_TOKEN don’t trigger workflow runs, so a followup build & format check doesn’t occur. This was said to be possible using a Personal Access Token instead but that’s also not working for me right now 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marketplace Actions Lint Action
Lint Action. Shows linting errors on GitHub commits and PRs; Allows auto-fixing issues; Supports many linters and formatters. Note: The behavior of actions ......
Read more >
PR Lint Action - GitHub Marketplace
A GitHub Action that verifies your pull request contains a reference to a ticket. You can use this to (optionally) check: The PR...
Read more >
Lint Action - GitHub Marketplace
Lint Action. Shows linting errors on GitHub commits and PRs; Allows auto-fixing issues; Supports many linters and formatters. Note: The behavior of actions ......
Read more >
Marketplace Actions Lint Pull Request
Lint the pull request structure and leave a comment suggesting changes if linting fails.
Read more >
Marketplace Actions Pull Request Linter
Pull Request Linter code style: prettier. :octocat: A fast TypeScript GitHub Action to ensure that your PR title matches a given regex.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found