PowerShell / DscResources

Central repository for PowerShell Desired State Configuration (DSC) resources.
http://blogs.msdn.com/b/powershell/
MIT License
777 stars 205 forks source link

Add Stale to DSC Resource Kit repositories #401

Closed johlju closed 6 years ago

johlju commented 6 years ago

After testing Stale in my test repo DebugApps it seems to work very well for part of our workflow. I suggest we add this GitHub App to DSC Resource Kit.

It will not be enabled until each repo opt-in by adding the below configuration to .github/stale.yml. The below configuration will handle issues and pull request differently. Each repository can set this individually.

Issues

It will remind that there haven't been activity on an issue for 30 days. If there are no further activity withing 40 days it will close the issue. It will not close an issue if the issue is assigned one of the labels under exemptLabels (the last two of them is only needed for DscResources repo). Neither will it close issues that are part of a milestone or project (that is just a precaution, because those issues should have a work label assigned too). Any other label, like a "waiting..."-label, 'needs more information', 'question' or 'discussion' label will be kept when the issue is labeled 'stale'. If a comment (activity) is made on the issue the 'needs more information' label is removed. See example: https://github.com/PowerShell/SqlServerDsc/issues/811

Pull Request (PR)

PR's that are not labeled with 'needs review', 'on hold' or 'waiting for CLA pass' will be labeled as abandoned after 14 days of inactivity. Any other label, like a "waiting..."-label will be kept when the issue is labeled 'abandoned'. If activity is made on the abandoned PR the 'abandoned' label is removed. See example: https://github.com/PowerShell/SqlServerDsc/pull/1045

Note: Pull requests that are labeled as 'waiting for CLA pass' should be closed after 14 days. But his app cannot handle that.

Configuration

# Configuration for probot-stale - https://github.com/probot/stale

limitPerRun: 30

pulls:
  daysUntilStale: 14
  daysUntilClose: false
  exemptProjects: true
  exemptMilestones: true
  staleLabel: abandoned
  exemptLabels:
    - needs review
    - on hold
    - waiting for CLA pass

  markComment: >
    Labeling this pull request (PR) as abandoned since it has gone 14 days or more
    since the last update. An abandoned PR can be continued by another contributor.
    The abandoned label will be removed if work on this PR is taken up again.

issues:
  daysUntilStale: 30
  daysUntilClose: 40
  exemptProjects: true
  exemptMilestones: true
  staleLabel: stale
  exemptLabels:
    - bug
    - enhancement
    - tests
    - documentation
    - resource proposal
    - on hold
    - new module submission
    - module proposal

  markComment: >
    This issue has been automatically marked as stale because
    it has not had activity from the community in the last 30 days. It will be
    closed if no further activity occurs within 10 days. If the issue is labelled
    with any of the work labels (e.g bug, enhancement, documentation, or tests)
    then the issue will not auto-close.

  closeComment: >
    This issue has been automatically closed because it is has not had activity
    from the community in the last 40 days.
johlju commented 6 years ago

After activating this in SqlServerDsc an issues was found, the configuration above is updated. 'resource proposal' was added as an work-label.

Configuration has been updated with the review comments from PR #402.

johlju commented 6 years ago

Updated configuration not to close PR's (daysUntilClose: false). I thought leaving the key out would accomplish that, and for some reason it worked in my tests, but it closed PRs in SqlServerDsc. Reading the documentation it clearly says it should be set to false.

johlju commented 6 years ago

So it seems there is a bug or an unsupported scenario in the Stale app. It keeps closing PR's even when setting daysUntilClose: false (see https://github.com/johlju/DebugApps/pull/11). Reported it in issue https://github.com/probot/stale/issues/129, so hopefully someone in the community can shed some light on this .

johlju commented 6 years ago

I'm testing another configuration in my DebugApps repo , adding only: key too - if that does not work, then we have to remove the pulls: part of the configuration since it does not work as intended.

johlju commented 6 years ago

We need to remove the pulls: part of the configuration. It doesn't seem it works as intended. I will resolve this by temporary uncomment that part of the configuration and referencing to https://github.com/PowerShell/DscResources/issues/401#issuecomment-395050731.

Also, Stale needs it's own label to work properly. The labels used for marking issues and PR's as stale cannot be set manually by a maintainer - Stale will always remove the label on activity. For this purpose we need to add a new label 'stale' and update the configuration accordingly. I will add a new label to the list in issue #364, and also the configuration in the issue description is updated.

johlju commented 6 years ago

Happy times! We got the https://github.com/probot/stale/pull/132 merged so that the issue https://github.com/probot/stale/issues/129 is solved! Also tested in my test repo and still the PR is just being labeled as stale and not being closed. Yay!

johlju commented 6 years ago

To get where the Stale app adds in the automation context I added this code2flow flowchart. This is so we can document this.

This only shows the schedule part. I will create another one for the "on edit"

On Schedule flowchart

This is the code to build the flowchart.

// Runs approx. every hour.
// Checks each issue and
// pull request.
// Max 30 items per run.
On Schedule;
switch(Type)
{
  case Issue:
  {
    if(Is labeled with 'stale'?)
    {
      if(Inactive for 10 days?)
      {
        Close issue;
      }
    }
    else
    {
      if(Inactive for 30 days?)
      {
        if(Is part of project?)
        {
        } 
        elseif(Is part of milestone?)
        {
        }
        // **Labels:**
        // needs review
        // on hold
        // waiting for CLA pass
        elseif(Has exempt label?)
        {
        }
        else
        {
          // Any existing labels will be kept.
          Label 'Stale';
          Write stale
          issue comment;
        }
      }
    }
    break;
  }

  case Pull Request:
  {
    if(Inactive for 14 days?)
    {
      if(Is part of project?)
      {
      } 
      elseif(Is part of milestone?)
      {
      }
      // **Labels:**
      // bug
      // enhancement
      // tests
      // documentation
      // resource proposal
      // on hold
      // -
      // **Special labels:**
      // new module submission
      // module proposal
      elseif(Has exempt label?)
      {
      }
      else
      {
        // Any existing labels will be kept.
        Label 'abandoned';
        Write stale pull
        request comment;
      }
    }
    break;
  }
};
Finished;
johlju commented 6 years ago

This shows what the Stale app does when there is activity on a issue or pull request.

On activity flowchart

This is the code to build the flowchart.

On pull request 
or issue activity
(except close);
switch(Type)
{
  case Issue:
  {
    if(Is labeled
    with 'stale'?)
    {
        Remove label
        'stale';
    }
    break;
  }

  case Pull Request:
  {
    if(Is labeled with
      'abandoned'?)
    {
        Remove label
        'abandoned';
    }
    break;
  }
};
Finished;
johlju commented 6 years ago

I have added the Stale app to all repositories in DSC Resource Kit, but it is not activated until .github/stale.yml is added to the default branch (dev branch). Maintainers feel free to activate this.

Anyone know of/used a tool that could PR to several repos? There are ~50 repos that would need this and any future app we want to activate. Need a quicker way than manually adding these, and I don't like the idea of pushing directly to dev (which would be easiest to automate).

/cc @athaynes, @ld0614, @PlagueHO, @NikCharlebois, @jcwalker, @ykuijs, @mhendric, @mbreakey3, @kwirkykat

PlagueHO commented 6 years ago

Awesome @johlju - that will be extremely helpful! I'll get onto adding the .github/stale.yml to the repos I maintain. Thank you for adding this feature!

johlju commented 6 years ago

I found a tool that can send in PR's; https://github.com/jd/git-pull-request

It works very well, although I need to run it in PS Core in my Ubuntu WSL, it failed on Windows reading a temp file itself created. Small thing looping through all repos now. I can't update the change log automatically without a lot of logic, so I think for the sake of speed I will ignore that for this, any objections to that?

sudo git clone https://github.com/PowerShell/xActiveDirectory
sudo git clone https://github.com/PowerShell/xSCVMM
cd ./xSCVMM/
sudo git checkout -b activate-stale --track origin/dev
sudo mkdir .github
cd ./.github/
sudo cp ../../xActiveDirectory/.github/stale.yml .
cd ..
sudo git add .github/stale.yml
sudo git commit -m "Activate the GitHub App Stale on the GitHub repository"
sudo git pull-request --title "Activate the GitHub App Stale on the GitHub repository" --no-tag-previous-revision

And the result of the last command.

Forked repository: https://github.com/johlju/xSCVMM
Added forked repository as remote `github'
Fetching origin
Rebasing branch `activate-stale' on branch `origin/dev'
Current branch activate-stale is up to date.
Force-pushing branch `activate-stale' to remote `github'
Counting objects: 4, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 917 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/johlju/xSCVMM.git
 * [new branch]      activate-stale -> activate-stale
$EDITOR is unset, you will not be able to edit the pull-request message
Activate the GitHub App Stale on the GitHub repository

Pull-request created: https://github.com/PowerShell/xSCVMM/pull/9

And the finished PR: https://github.com/PowerShell/xSCVMM/pull/9

johlju commented 6 years ago

I have now sent in a PR to activate Stale to all repos.

/cc @athaynes, @ld0614, @PlagueHO, @NikCharlebois, @jcwalker, @ykuijs, @mhendric, @mbreakey3, @kwirkykat

PlagueHO commented 6 years ago

Thank you very much @johlju !

johlju commented 6 years ago

Stale is now activated on all repos except PSDscResources (waiting for @kwirkykat to merge that one).

johlju commented 6 years ago

Seems there is another bug with Stale when using the configuration we are using; https://github.com/probot/stale/issues/134. The abandoned label will not remove automatically on PR's when there is activity, as is suppose to do.

I will see if I have time to look into it during a weekend. The fix is probably simple, but writing the regression tests is a bit trickier.