From eae57200b6b8b5ce39c89779e2bb6f5705feb292 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 18 Dec 2017 20:46:20 +0000 Subject: [PATCH 1/9] Added open-bot.yml configuration file for open bot, plus two npm scripts --- open-bot.yml | 351 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 +- 2 files changed, 355 insertions(+), 1 deletion(-) create mode 100644 open-bot.yml diff --git a/open-bot.yml b/open-bot.yml new file mode 100644 index 00000000000..a32f20e4406 --- /dev/null +++ b/open-bot.yml @@ -0,0 +1,351 @@ +bot: "webpack-bot" +rules: + +# Add ci-ok, ci-not-ok labels depending on travis status +# comment to point the user to the results +# comment in case of success +- filters: + open: true + pull_request: + mergeable: true + status_1: + context: "continuous-integration/travis-ci/pr" + ensure_1: + value: "{{status_1.state}}" + equals: "success" + actions: + label: + add: "PR: CI-ok" + remove: "PR: CI-not-ok" + comment: + identifier: "ci-result" + message: |- + Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. +- filters: + open: true + pull_request: + mergeable: true + status_1: + context: "continuous-integration/travis-ci/pr" + any: + ensure_1: + value: "{{status_1.state}}" + equals: "failure" + not: + any: + ensure_3: + value: "{{status_1.state}}" + equals: "pending" + actions: + label: + add: "PR: CI-not-ok" + remove: "PR: CI-ok" + set: + id: report_ci + value: yep + + + +# Report specific error message if mocha for unit tests fails +- filters: + ensure: + value: "{{report_ci}}" + equals: yep + commit: true + status: + context: "continuous-integration/travis-ci/pr" + travis_job: + state: "failed" + allow_failure: false + config: + env: JOB_PART=unit + fetch: travis_job.log + string_cleanup: + id: logResult + value: "{{{fetch}}}" + remove: + - "^[\\s\\S]+?npm run travis:\\$JOB_PART\n*" + - "npm ERR!.*\n" + - "\n*=============================================================================\n[\\s\\S]*" + actions: + comment: + identifier: "ci-result" + message: |- + @{{commit.author.login}} Please review the following output log for errors: + + ``` text + {{{logResult}}} + ``` + + Instead of updating these (outdated?) unit tests, you can choose to delete them and add integration tests instead. That would be great. + + See [complete report here]({{status.target_url}}). + set: + id: report_ci + value: nope + + + +# Report specific error message if linting fails +- filters: + ensure: + value: "{{report_ci}}" + equals: yep + commit: true + status: + context: "continuous-integration/travis-ci/pr" + travis_job: + state: "failed" + config: + env: JOB_PART=lint + fetch: travis_job.log + string_cleanup: + id: logResult + value: "{{{fetch}}}" + remove: + - "^[\\s\\S]+?npm run travis:\\$JOB_PART\n*" + - "npm ERR!.*\n" + - "\n*The command \"npm run travis:\\$JOB_PART\" exited [\\s\\S]*" + actions: + comment: + identifier: "ci-result" + message: |- + @{{commit.author.login}} The tests look fine, but there are code style issue in your Pull Request. Please review the following: + + ``` text + {{{logResult}}} + ``` + + See [complete report here]({{status.target_url}}). + set: + id: report_ci + value: nope + + + + +# Report a general error message +- filters: + ensure: + value: "{{report_ci}}" + equals: yep + commit: true + status_1: + context: "continuous-integration/travis-ci/pr" + actions: + comment: + identifier: "ci-result" + message: |- + @{{commit.author.login}} The most important CI builds failed. This way your PR can't be merged. + + Please take a look at the CI results from [travis]({{status_1.target_url}}) ({{status_1.state}}) and [appveyor]({{status_2.target_url}}) ({{status_2.state}}) and fix these issues. + + +# add conflict label to pull requests with conflict +# on conflict all result labels are removed +- filters: + open: true + pull_request: + mergeable: false + actions: + label: + add: "PR: conflict" + remove: + - "PR: tests-needed" + - "PR: CI-ok" + - "PR: CI-not-ok" +- filters: + open: true + pull_request: + mergeable: true + actions: + label: + remove: "PR: conflict" + + + +# add unreviewed, reviewed, review-outdated labels +# comment to ping reviewer +# comment on new PR +- filters: + open: true + in_order: + commit: true + review: + state: APPROVED|CHANGES_REQUESTED + ensure: + value: "{{review.state}}" + equals: APPROVED + actions: + label: + add: "PR: reviewed-approved" + remove: + - "PR: review-outdated" + - "PR: unreviewed" + - "PR: reviewed" +- filters: + open: true + in_order: + commit: true + review: + state: APPROVED|CHANGES_REQUESTED + ensure: + value: "{{review.state}}" + equals: CHANGES_REQUESTED + actions: + label: + add: "PR: reviewed-changes-requested" + remove: + - "PR: review-outdated" + - "PR: unreviewed" + - "PR: reviewed" +- filters: + open: true + in_order: + review: + state: APPROVED|CHANGES_REQUESTED + commit: true + not: + label: "review-outdated" + ensure: + value: "{{commit.author.login}}" + notEquals: "{{review.user.login}}" + actions: + label: + add: "PR: review-outdated" + remove: + - "PR: reviewed-approved" + - "PR: reviewed-changes-requested" + - "PR: unreviewed" + - "PR: reviewed" + comment: + identifier: "review-outdated" + message: |- + @{{commit.author.login}} Thanks for your update. + + I labeled the Pull Request so reviewers will review it again. + + @{{review.user.login}} Please review the new changes. +- filters: + open: true + commit: true + not: + review: + state: APPROVED|CHANGES_REQUESTED + actions: + label: "PR: unreviewed" + + + +# add small label to small pull requests +- filters: + open: true + pull_request: + additions: "<= 10" + deletions: "<= 10" + changed_files: "<= 2" + actions: + label: "PR: small" + + + +# add non-master label to pull request to other branch +- filters: + open: true + age: + minimum: 1d + maximum: 1w + pull_request: + head_ref: "^master$" + permission: "read|none" + actions: + comment: + identifier: "head-master" + edit: true + message: |- + Hi @{{pull_request.user.login}}. + + Just a little hint from a friendly bot about the best practice when submitting pull requests: + + > Don't submit pull request from your own `master` branch. It's recommended to create a feature branch for the PR. + + *You don't have to change it for this PR, just make sure to follow this hint the next time you submit a PR.* + + +# Move issue task +- filters: + open: true + comment: "\\s*@webpack-bot\\s+move\\s+(?:to\\s+)?([a-z0-9_\\-\\.]+/[a-z0-9_\\-\\.]+)\\s*([\\s\\S]*)$" + not: + comment_1: + matching: "moved\\-by\\-bot" + author: "." + permission: + user: "{{comment.actor.login}}" + actions: + new_issue: + target: "{{{comment_match.[1]}}}" + body: |- + {{{issue.body}}} + + --- + + This issue was moved from {{owner}}/{{repo}}#{{issue.number}} by @{{comment.actor.login}}. Orginal issue was by @{{issue.user.login}}. + + {{{comment_match.[2]}}} + comment: + identifier: moved-by-bot + message: |- + I've moved it to {{comment_match.[1]}}. + close: true + + +# mark inactive issues with inactive label +# close them when no activity after warning +- filters: + issue: true + open: true + not: + label: inactive + ensure: + value: "{{issue.reactions.[+1]}}" + range: "< 10" + last_action_age: 26w # half a year + actions: + comment: + identifer: inactive-warning + message: |- + **This issue had no activity for at least half a year.** + + It's subject to automatic issue closing if there is no activity in the next 15 days. + label: inactive +- filters: + open: true + label: inactive + last_action_age: + maximum: 26w # half a year + actions: + label: + remove: + - inactive +- filters: + open: true + label: inactive + last_action_age: + minimum: 15d + includeBotActions: true + actions: + close: true + comment: + identifer: inactive-close + message: |- + Issue was closed because of inactivity. + + If you think this is still a valid issue, please file a new issue with additional information. + + +# Check issues every week +- filters: + open: true + actions: + schedule: 1d \ No newline at end of file diff --git a/package.json b/package.json index 93e9d8fdb26..7a1d0717417 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,10 @@ "pretest": "yarn lint", "test": "jest", "test:ci": "jest --ci && codecov -f coverage/coverage-final.json", - "jsdoc": "jsdoc -c jsdoc.json -r -d docs" + "jsdoc": "jsdoc -c jsdoc.json -r -d docs", + "prepublish": "flow-remove-types lib/ -d dist/ && npm run format:dist", + "travis:unit": "npm run test", + "travis:lint": "npm run lint" }, "lint-staged": { "{lib,bin}/**/!(__testfixtures__)/**.js": [ From e27679bfa6ded16a8c4cbdc98408496137bf06a6 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 18 Dec 2017 20:52:24 +0000 Subject: [PATCH 2/9] Added open-bot.yml configuration file for open bot, plus two npm scripts --- open-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-bot.yml b/open-bot.yml index a32f20e4406..8e075415d3e 100644 --- a/open-bot.yml +++ b/open-bot.yml @@ -46,7 +46,7 @@ rules: -# Report specific error message if mocha for unit tests fails +# Report specific error message if jest tests fails - filters: ensure: value: "{{report_ci}}" From 2349bfb29452427e8210e519952965a5c12d6772 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Tue, 19 Dec 2017 12:28:31 +0000 Subject: [PATCH 3/9] Updated open-bot configuration --- open-bot.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/open-bot.yml b/open-bot.yml index 8e075415d3e..713ca0ac788 100644 --- a/open-bot.yml +++ b/open-bot.yml @@ -31,11 +31,6 @@ rules: ensure_1: value: "{{status_1.state}}" equals: "failure" - not: - any: - ensure_3: - value: "{{status_1.state}}" - equals: "pending" actions: label: add: "PR: CI-not-ok" @@ -77,8 +72,6 @@ rules: {{{logResult}}} ``` - Instead of updating these (outdated?) unit tests, you can choose to delete them and add integration tests instead. That would be great. - See [complete report here]({{status.target_url}}). set: id: report_ci @@ -138,7 +131,7 @@ rules: message: |- @{{commit.author.login}} The most important CI builds failed. This way your PR can't be merged. - Please take a look at the CI results from [travis]({{status_1.target_url}}) ({{status_1.state}}) and [appveyor]({{status_2.target_url}}) ({{status_2.state}}) and fix these issues. + Please take a look at the CI results from [travis]({{status_1.target_url}}) ({{status_1.state}}) and fix these issues. # add conflict label to pull requests with conflict @@ -348,4 +341,4 @@ rules: - filters: open: true actions: - schedule: 1d \ No newline at end of file + schedule: 1d From bee60846b1fc2fefd4288a7a6bd393df3ef65bd8 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Tue, 19 Dec 2017 12:29:48 +0000 Subject: [PATCH 4/9] Added new dist command Added new dist command to generate a clean distribution folder --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7a1d0717417..281a8549f7e 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "test:ci": "jest --ci && codecov -f coverage/coverage-final.json", "jsdoc": "jsdoc -c jsdoc.json -r -d docs", "prepublish": "flow-remove-types lib/ -d dist/ && npm run format:dist", - "travis:unit": "npm run test", - "travis:lint": "npm run lint" + "travis:integration": "yarn prepare && npm run test:ci", + "travis:lint": "yarn prepare && yarn lint" }, "lint-staged": { "{lib,bin}/**/!(__testfixtures__)/**.js": [ From 09026c869bb32728661be50c53876aa1488fe6ce Mon Sep 17 00:00:00 2001 From: Emanuele Date: Tue, 19 Dec 2017 12:30:40 +0000 Subject: [PATCH 5/9] Update travis configuration, runnable from the bot --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3378f68959c..b0bbe5f10ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,7 @@ before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start -script: - - yarn prepare - - yarn lint - - yarn test:ci - after_success: - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" + +script: npm run travis:$JOB_PART From 1ad3cbb10ceee658906714385dd61290c1c4cde4 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Tue, 19 Dec 2017 12:32:42 +0000 Subject: [PATCH 6/9] Updated job from 'unit' to 'integration' --- open-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-bot.yml b/open-bot.yml index 713ca0ac788..35a5399eac2 100644 --- a/open-bot.yml +++ b/open-bot.yml @@ -53,7 +53,7 @@ rules: state: "failed" allow_failure: false config: - env: JOB_PART=unit + env: JOB_PART=integration fetch: travis_job.log string_cleanup: id: logResult From 910222262aebdf2bd51d40fdc094162751eaf19a Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 20 Dec 2017 20:29:21 +0000 Subject: [PATCH 7/9] Moved to yarn and updated the matrix --- .travis.yml | 22 +++++++++++++++++----- package.json | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0bbe5f10ea..28f78be54f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,22 @@ language: node_js -node_js: - - "6" - - "7" - - "8" - - "stable" +matrix: + include: + - os: linux + node_js: "stable" + env: JOB_PART=lint + - os: linux + node_js: "stable" + env: JOB_PART=integration + - os: linux + node_js: "8" + env: JOB_PART=integration + - os: linux + node_js: "7" + env: JOB_PART=integraton + - os: linux + node_js: "6" + env: JOB_PART=integraton sudo: false diff --git a/package.json b/package.json index 281a8549f7e..36bb5e5e653 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "test:ci": "jest --ci && codecov -f coverage/coverage-final.json", "jsdoc": "jsdoc -c jsdoc.json -r -d docs", "prepublish": "flow-remove-types lib/ -d dist/ && npm run format:dist", - "travis:integration": "yarn prepare && npm run test:ci", + "travis:integration": "yarn prepare && yarn test:ci", "travis:lint": "yarn prepare && yarn lint" }, "lint-staged": { From e26ceeca293695a834a90b9821b8363716240b47 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Thu, 21 Dec 2017 09:24:05 +0000 Subject: [PATCH 8/9] Removed 'prepublish' --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 36bb5e5e653..96c26e1d45c 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "test": "jest", "test:ci": "jest --ci && codecov -f coverage/coverage-final.json", "jsdoc": "jsdoc -c jsdoc.json -r -d docs", - "prepublish": "flow-remove-types lib/ -d dist/ && npm run format:dist", "travis:integration": "yarn prepare && yarn test:ci", "travis:lint": "yarn prepare && yarn lint" }, From 32e37bee16aabb501e5bc7f1647b163a6db48c0a Mon Sep 17 00:00:00 2001 From: Emanuele Date: Thu, 21 Dec 2017 10:56:06 +0000 Subject: [PATCH 9/9] Fixed typo inside the configuration --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28f78be54f6..40161397885 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ matrix: env: JOB_PART=integration - os: linux node_js: "7" - env: JOB_PART=integraton + env: JOB_PART=integration - os: linux node_js: "6" - env: JOB_PART=integraton + env: JOB_PART=integration sudo: false