You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2019/07/23 10:57:45 UTC
[incubator-weex] branch master updated: [Danger] Add some static
check rules in dangerfile (#2676)
This is an automated email from the ASF dual-hosted git repository.
kyork pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 0898c8f [Danger] Add some static check rules in dangerfile (#2676)
0898c8f is described below
commit 0898c8f574dca2d8d65e5b455e01188f220be676
Author: Renmin <33...@users.noreply.github.com>
AuthorDate: Tue Jul 23 18:57:40 2019 +0800
[Danger] Add some static check rules in dangerfile (#2676)
The check rules are described in https://github.com/apache/incubator-weex/blob/master/CONTRIBUTING.md#publish-your-change
---
.github/PULL_REQUEST_TEMPLATE.md | 11 +++++----
dangerfile.js | 53 ++++++++++++++++++++++++++++++++++++++--
2 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 472844a..848d5d7 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -5,14 +5,15 @@ All PRs should be submitted to master branch -->
<!-- Please follow the template below:
* If you are going to fix a bug of Weex, check whether it already exists in [Github Issue](https://github.com/apache/incubator-weex/issues). If it exists, make sure to write down the link to the corresponding Github issue in the PR you are going to create.
* If you are going to add a feature for weex, reference the following recommend procedure:
- 1. Writing a email to [mailing list](https://weex.io/guide/contribute/how-to-contribute.html#mailing-list) to talk about what you'd like to do.
- 1. Write the corresponding [document](https://weex.io/guide/contribute/how-to-contribute.html#contribute-code-or-document) -->
+ 1. Writing a email to [mailing list](https://github.com/apache/incubator-weex/blob/master/CONTRIBUTING.md#mailing-list) to talk about what you'd like to do.
+ 1. Write the corresponding [Documentation](https://github.com/apache/incubator-weex/blob/master/CONTRIBUTING.md#contribute-documentation)
+ 1. Write the corresponding Changelogs at the end of changelog.md -->
# Brief Description of the PR
# Checklist
-* [] Demo
-* [] Document
+* Demo:
+* Documentation:
-<!-- # Additional content -->
\ No newline at end of file
+<!-- # Additional content -->
diff --git a/dangerfile.js b/dangerfile.js
index f8d2245..cd7e70e 100644
--- a/dangerfile.js
+++ b/dangerfile.js
@@ -16,15 +16,64 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { schedule, danger, fail, warn, message, markdown } from "danger";
+// Removed import
import fs from "fs";
import path from 'path';
import GitHubApi from 'github';
import parseDiff from 'parse-diff';
+// check if pr submitted to master branch
+console.log("checkMasterBranch")
+const isMergeRefMaster = danger.github.pr.base.ref === 'master';
+if(!isMergeRefMaster){
+ warn("You'd better to submit PR to master branch as the development of Weex is on master branch.");
+}
+
+// match regex line by line
+function matchRegex(pr_body,regex){
+ const lines = pr_body.split("\n");
+ for (let i = 0; i < lines.length; i++) {
+ if(lines[i].match(regex)){
+ return true;
+ }
+ }
+ return false;
+}
+
+var pr_body = danger.github.pr.body.toLowerCase();
+// Because Pr description template include the following lineļ¼
+// 1. Write the corresponding [documentation](https://github.com/apache/incubator-weex/blob/master/CONTRIBUTING.md#contribute-code-or-document)
+// so we should check the documentation below the ### checklist
+console.log("checkDocumentation");
+const index = pr_body.indexOf("checklist")
+const includeChecklist = (index!=-1)
+if(includeChecklist && !matchRegex(pr_body.substring(index),/documentation.*http/)){
+ const msg = "If you update the code, "+
+ "maybe you should update the documentation and add the documentation link in the PR description. \n" +
+ "here is the guide about how to contribute documentation:https://github.com/apache/incubator-weex/blob/master/CONTRIBUTING.md#contribute-code-or-document \n";
+ warn(msg);
+}
+
+// check if pr contains a demo link
+console.log("checkDemo");
+if(!matchRegex(pr_body,/demo.*http/)){
+ const msg = "If your PR is about fixing a bug excluding crash the code,"+
+ "you should add the demo link in the PR description. \n "+
+ "here is a demo link:http://dotwe.org/vue?spm=a2c7j.-guide-contribute-contribute-code.0.0.3e93748cmxz3yt";
+ warn(msg);
+}
+
+// check if pr bind the github milestone
+console.log("checkMileStone");
+if(!danger.github.pr.milestone){
+ warn("Current pr not bind the milestone");
+}
+
// Make sure there are changelog entries
const hasChangelog = danger.git.modified_files.includes("changelog.md")
-if (!hasChangelog) { warn("No Changelog changes!") }
+if (!hasChangelog) {
+ warn(`No Changelog changes! - <i>Can you add a Changelog? To do so,append your changes to the changelog.md</i>`);
+}
const jsFiles = danger.git.created_files.filter(path => path.endsWith("js"));