dotnet / arcade

Tools that provide common build infrastructure for multiple .NET Foundation projects.
MIT License
662 stars 336 forks source link

Poison bot commit messages #14457

Open richlander opened 6 months ago

richlander commented 6 months ago

We've talked about being able to better reason about commits and PRs. That's really hard, in part because of all the bot activity.

We should consider adding a marker to commits/PRs that should never participate in automated "Feature and fix reports". Many projects auto-generate lists of improvements directly out of GitHub. We do not.

As you can see, we have many bot-generated PRs.

https://github.com/dotnet/runtime/pulls/app%2Fdotnet-maestro

Certainly, we can block-list all the bot accounts.

We could also consider adding other markers for other purposes, like community PRs.

danmoseley commented 6 months ago

community PR's should already have the community label auto-applied -- @jeffhandley does that happen through some GH action on all repos?

bots are generally "marked" as automation. so afaik, the GH API can be used to identify both.

jeffhandley commented 4 months ago

@danmoseley Many of our repositories use Policy Service to label community contributions, but this isn't centralized or uniform across the repositories. The label-prs.yml (dotnet/docs) policy is a good example though.

Policy Service can't detect bots through the user type, but it could have the list of authors we want to label as such. Alternatively, we could pursue a GitHub workflow with an implementation like this, that checks the type of user that authored the PR, triggering this when PRs are created:

jobs:
  label-bot-pr:
    runs-on: ubuntu-latest
    steps:
      - name: Label Bot PRs
        uses: actions/github-script@v5
        with:
          script: |
            const author = context.payload.pull_request.user;

            if (author.type == 'Bot') {
              const prNumber = context.payload.pull_request.number;
              console.log(`Labeling PR #${prNumber}. Author '${user.login}' is a Bot.`);

              await github.issues.addLabels({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: prNumber,
                labels: ['bot'],
              });
            }