You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2021/02/18 11:55:52 UTC

[apisix-dashboard] branch master updated: feat: add a GitHub Action to check for trailing whitespace (#1474)

This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 20d5492  feat: add a GitHub Action to check for trailing whitespace (#1474)
20d5492 is described below

commit 20d549255d8d835e5838587eafff6bd91f52f497
Author: John Bampton <jb...@users.noreply.github.com>
AuthorDate: Thu Feb 18 21:55:43 2021 +1000

    feat: add a GitHub Action to check for trailing whitespace (#1474)
---
 .github/workflows/lint.yml                         |  27 ++++-
 .github/workflows/spellchecker.yml                 |  21 ----
 .../handler/data_loader/route_export_test.go       |  72 ++++++------
 api/test/e2e/route_export_test.go                  | 124 ++++++++++-----------
 api/test/e2e/service_test.go                       |  28 ++---
 api/test/shell/manager_smoking.sh                  |   6 +-
 web/cypress/fixtures/selector.json                 |   2 +-
 web/src/components/RightContent/index.tsx          |   2 +-
 web/src/pages/ServerInfo/typing.d.ts               |   2 +-
 9 files changed, 143 insertions(+), 141 deletions(-)

diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index a7f824d..88a53ec 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -11,9 +11,24 @@ jobs:
       - name: ๐Ÿš€ Use Node.js
         uses: actions/setup-node@v2.1.4
         with:
-          node-version: '12.x'
+          node-version: '14.x'
       - run: npm install -g markdownlint-cli@0.25.0
       - run: markdownlint '**/*.md' --ignore node_modules
+  misspell:
+    name: runner/misspell
+    runs-on: ubuntu-latest
+    steps:
+      - name: Check out code.
+        uses: actions/checkout@v1
+      - name: Install
+        run: |
+          wget -O - -q https://git.io/misspell | sh -s -- -b .
+      - name: Misspell
+        run: |
+          find . -type f -maxdepth 1 | xargs ./misspell -error
+          find . -name "*.go" -type f | xargs ./misspell -error
+          find docs -type f | xargs ./misspell -error
+          find web/src web/cypress -type f | xargs ./misspell -error
   yamllint:
     name: ๐Ÿ YAML
     runs-on: ubuntu-latest
@@ -29,4 +44,12 @@ jobs:
           pip install yamllint
       - name: ๐Ÿงน YAML Lint
         run: |
-          yamllint .
+          # return non-zero exit code on warnings
+          yamllint --strict .
+  trailing-whitespace:
+    name: Trailing whitespace
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Check for trailing whitespace
+        run: "! git grep -EIn $'[ \t]+$'"
diff --git a/.github/workflows/spellchecker.yml b/.github/workflows/spellchecker.yml
deleted file mode 100644
index 6b24651..0000000
--- a/.github/workflows/spellchecker.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-name: spellchecker
-on:
-  pull_request:
-    branches:
-      - master
-jobs:
-  misspell:
-    name: runner/misspell
-    runs-on: ubuntu-latest
-    steps:
-      - name: Check out code.
-        uses: actions/checkout@v1
-      - name: Install
-        run: |
-          wget -O - -q https://git.io/misspell | sh -s -- -b .
-      - name: Misspell
-        run: |
-          find . -type f -maxdepth 1 | xargs ./misspell -error
-          find . -name "*.go" -type f | xargs ./misspell -error
-          find docs -type f | xargs ./misspell -error
-          find web/src web/cypress -type f | xargs ./misspell -error
diff --git a/api/internal/handler/data_loader/route_export_test.go b/api/internal/handler/data_loader/route_export_test.go
index 5bb948b..fbec66a 100644
--- a/api/internal/handler/data_loader/route_export_test.go
+++ b/api/internal/handler/data_loader/route_export_test.go
@@ -304,13 +304,13 @@ func TestExportRoutesCreateByServiceId(t *testing.T) {
 			"version":"v2"
 		},
 		"enable_websocket":true,
-		"plugins": { 
-			"limit-count": { 
-				"count": 100, 
-				"time_window": 60, 
-				"rejected_code": 503, 
-				"key": "remote_addr" 
-			} 
+		"plugins": {
+			"limit-count": {
+				"count": 100,
+				"time_window": 60,
+				"rejected_code": 503,
+				"key": "remote_addr"
+			}
 		},
 		"upstream": {
 			"type": "roundrobin",
@@ -399,7 +399,7 @@ func TestExportRoutesCreateByServiceId2(t *testing.T) {
 		"uri": "/hello",
 		"service_id": "s1",
 		"enable_websocket":false,
-		"plugins": { 
+		"plugins": {
 			"prometheus": {
 				"disable": false
 			}
@@ -424,13 +424,13 @@ func TestExportRoutesCreateByServiceId2(t *testing.T) {
 			"version":"v2"
 		},
 		"enable_websocket":true,
-		"plugins": { 
-			"limit-count": { 
-				"count": 100, 
-				"time_window": 60, 
-				"rejected_code": 503, 
-				"key": "remote_addr" 
-			} 
+		"plugins": {
+			"limit-count": {
+				"count": 100,
+				"time_window": 60,
+				"rejected_code": 503,
+				"key": "remote_addr"
+			}
 		},
 		"upstream": {
 			"type": "roundrobin",
@@ -539,13 +539,13 @@ func TestExportRoutesCreateByServiceId3(t *testing.T) {
 			"version":"v2"
 		},
 		"enable_websocket":true,
-		"plugins": { 
-			"limit-count": { 
-				"count": 100, 
-				"time_window": 60, 
-				"rejected_code": 503, 
-				"key": "remote_addr" 
-			} 
+		"plugins": {
+			"limit-count": {
+				"count": 100,
+				"time_window": 60,
+				"rejected_code": 503,
+				"key": "remote_addr"
+			}
 		},
 		"upstream_id": "u1"
 	}`
@@ -555,7 +555,7 @@ func TestExportRoutesCreateByServiceId3(t *testing.T) {
 		"uri": "/hello",
 		"service_id": "s1",
 		"enable_websocket":false,
-		"plugins": { 
+		"plugins": {
 			"prometheus": {
 				"disable": false
 			}
@@ -669,7 +669,7 @@ func TestExportRoutesCreateByUpstreamId(t *testing.T) {
 		"methods": ["GET"],
 		"uri": "/hello",
 		"enable_websocket":false,
-		"plugins": { 
+		"plugins": {
 			"prometheus": {
 				"disable": false
 			}
@@ -766,13 +766,13 @@ func TestExportRoutesCreateByUpstreamIdandServiceId(t *testing.T) {
 			"version":"v2"
 		},
 		"enable_websocket":true,
-		"plugins": { 
-			"limit-count": { 
-				"count": 100, 
-				"time_window": 60, 
-				"rejected_code": 503, 
-				"key": "remote_addr" 
-			} 
+		"plugins": {
+			"limit-count": {
+				"count": 100,
+				"time_window": 60,
+				"rejected_code": 503,
+				"key": "remote_addr"
+			}
 		},
 		"upstream_id": "u1"
 	}`
@@ -793,7 +793,7 @@ func TestExportRoutesCreateByUpstreamIdandServiceId(t *testing.T) {
 		],
 		"uri": "/hello",
 		"enable_websocket":false,
-		"plugins": { 
+		"plugins": {
 			"prometheus": {
 				"disable": false
 			}
@@ -923,7 +923,7 @@ func TestExportRoutesCreateByServiceIdNoUpstream(t *testing.T) {
 		],
 		"uri": "/hello",
 		"enable_websocket":false,
-		"plugins": { 
+		"plugins": {
 			"prometheus": {
 				"disable": false
 			}
@@ -1110,8 +1110,8 @@ func TestExportRoutesCreateByLabel2(t *testing.T) {
 		"desc": "testservice_desc",
 		"enable_websocket":true,
 		"labels": {
-			"build": "16", 
-			"env": "production", 
+			"build": "16",
+			"env": "production",
 			"version": "v2"
 		}
 	}`
@@ -1628,7 +1628,7 @@ func TestExportRoutesCreateByUpstreamIDAndServiceID2(t *testing.T) {
 		],
 		"uri": "/hello",
 		"enable_websocket":false,
-		"plugins": { 
+		"plugins": {
 			"prometheus": {
 				"disable": false
 			}
diff --git a/api/test/e2e/route_export_test.go b/api/test/e2e/route_export_test.go
index 7a1d351..24cffa8 100644
--- a/api/test/e2e/route_export_test.go
+++ b/api/test/e2e/route_export_test.go
@@ -369,8 +369,8 @@ func TestRoute_Export(t *testing.T) {
 
 	// 4.Create a service that contains complete data and use the service_ id create route
 	serviceStrS1 := `
-	"name": "testservice", 
-	"desc": "testservice_desc", 
+	"name": "testservice",
+	"desc": "testservice_desc",
 	"upstream": {
 		"nodes": [{
 			"host": "172.16.238.20",
@@ -378,7 +378,7 @@ func TestRoute_Export(t *testing.T) {
 			"weight": 1
 		}],
 		"type": "roundrobin"
-	}, 
+	},
 	"plugins": {
 		"limit-count": {
 			"count": 100,
@@ -386,12 +386,12 @@ func TestRoute_Export(t *testing.T) {
 			"rejected_code": 503,
 			"time_window": 60
 		}
-	}, 
+	},
 	"labels": {
 		"build": "16",
 		"env": "production",
 		"version": "v2"
-	}, 
+	},
 	"enable_websocket": true
 	`
 	serviceStrS1 = replaceStr(serviceStrS1)
@@ -459,13 +459,13 @@ func TestRoute_Export(t *testing.T) {
 					"version":"v2"
 				},
 				"enable_websocket":true,
-				"plugins": { 
-					"limit-count": { 
-						"count": 100, 
-						"time_window": 60, 
-						"rejected_code": 503, 
-						"key": "remote_addr" 
-					} 
+				"plugins": {
+					"limit-count": {
+						"count": 100,
+						"time_window": 60,
+						"rejected_code": 503,
+						"key": "remote_addr"
+					}
 				},
 				"upstream": {
 					"type": "roundrobin",
@@ -549,8 +549,8 @@ func TestRoute_Export(t *testing.T) {
 	// However, if the data in the service plugins does not exist in the route, it will be fused and exported.
 	// If it exists, the data in route will be used first
 	serviceStrS2 := `
-	"name": "testservice", 
-	"desc": "testservice_desc", 
+	"name": "testservice",
+	"desc": "testservice_desc",
 	"upstream": {
 		"nodes": [{
 			"host": "172.16.238.20",
@@ -558,7 +558,7 @@ func TestRoute_Export(t *testing.T) {
 			"weight": 1
 		}],
 		"type": "roundrobin"
-	}, 
+	},
 	"plugins": {
 		"limit-count": {
 			"count": 100,
@@ -566,12 +566,12 @@ func TestRoute_Export(t *testing.T) {
 			"rejected_code": 503,
 			"time_window": 60
 		}
-	}, 
+	},
 	"labels": {
 		"build": "16",
 		"env": "production",
 		"version": "v2"
-	}, 
+	},
 	"enable_websocket": true`
 	serviceStrS2 = replaceStr(serviceStrS2)
 
@@ -642,13 +642,13 @@ func TestRoute_Export(t *testing.T) {
 					"version":"v2"
 				},
 				"enable_websocket":true,
-				"plugins": { 
-					"limit-count": { 
-						"count": 100, 
-						"time_window": 60, 
-						"rejected_code": 503, 
-						"key": "remote_addr" 
-					} 
+				"plugins": {
+					"limit-count": {
+						"count": 100,
+						"time_window": 60,
+						"rejected_code": 503,
+						"key": "remote_addr"
+					}
 				},
 				"upstream": {
 					"type": "roundrobin",
@@ -682,7 +682,7 @@ func TestRoute_Export(t *testing.T) {
 				"uri": "/hello",
 				"service_id": "s2",
 				"enable_websocket":false,
-				"plugins": { 
+				"plugins": {
 					"prometheus": {
 						"disable": false
 					}
@@ -744,9 +744,9 @@ func TestRoute_Export(t *testing.T) {
 	// The test export also contains the upstream.
 	// Use the upstream of route.
 	serviceStrS3 := `
-	"name": "testservice", 
-	"desc": "testservice_desc", 
-	"upstream_id": "1", 
+	"name": "testservice",
+	"desc": "testservice_desc",
+	"upstream_id": "1",
 	"plugins": {
 		"limit-count": {
 			"count": 100,
@@ -754,12 +754,12 @@ func TestRoute_Export(t *testing.T) {
 			"rejected_code": 503,
 			"time_window": 60
 		}
-	}, 
+	},
 	"labels": {
 		"build": "16",
 		"env": "production",
 		"version": "v2"
-	}, 
+	},
 	"enable_websocket": true`
 	serviceStrS3 = replaceStr(serviceStrS3)
 
@@ -848,13 +848,13 @@ func TestRoute_Export(t *testing.T) {
 					"version":"v2"
 				},
 				"enable_websocket":true,
-				"plugins": { 
-					"limit-count": { 
-						"count": 100, 
-						"time_window": 60, 
-						"rejected_code": 503, 
-						"key": "remote_addr" 
-					} 
+				"plugins": {
+					"limit-count": {
+						"count": 100,
+						"time_window": 60,
+						"rejected_code": 503,
+						"key": "remote_addr"
+					}
 				},
 				"upstream_id": "1"
 			}`,
@@ -879,7 +879,7 @@ func TestRoute_Export(t *testing.T) {
 				"uri": "/hello",
 				"service_id": "s3",
 				"enable_websocket":false,
-				"plugins": { 
+				"plugins": {
 					"prometheus": {
 						"disable": false
 					}
@@ -1004,7 +1004,7 @@ func TestRoute_Export(t *testing.T) {
 				"methods": ["GET"],
 				"uri": "/hello",
 				"enable_websocket":false,
-				"plugins": { 
+				"plugins": {
 					"prometheus": {
 						"disable": false
 					}
@@ -1058,9 +1058,9 @@ func TestRoute_Export(t *testing.T) {
 	// Create route according to upstream2 ID and service ID
 	// Export route
 	serviceStrS4 := `
-	"name": "testservice", 
-	"desc": "testservice_desc", 
-	"upstream_id": "4", 
+	"name": "testservice",
+	"desc": "testservice_desc",
+	"upstream_id": "4",
 	"enable_websocket": true`
 	serviceStrS4 = replaceStr(serviceStrS4)
 
@@ -1085,7 +1085,7 @@ func TestRoute_Export(t *testing.T) {
 					"summary": "ๆ‰€ๆœ‰",
 					"x-apisix-enable_websocket": false,
 					"x-apisix-labels": {
-						"API_VERSION": "v1", 
+						"API_VERSION": "v1",
 						"test": "1"
 					},
 					"x-apisix-plugins": {
@@ -1180,7 +1180,7 @@ func TestRoute_Export(t *testing.T) {
 				],
 				"uri": "/hello",
 				"enable_websocket":false,
-				"plugins": { 
+				"plugins": {
 					"prometheus": {
 						"disable": false
 					}
@@ -1249,9 +1249,9 @@ func TestRoute_Export(t *testing.T) {
 
 	// 10.Creating route10 using service ID does not contain upstream data
 	serviceStrS5 := `
-	"name": "testservice", 
-	"desc": "testservice_desc", 
-	"upstream_id": "6", 
+	"name": "testservice",
+	"desc": "testservice_desc",
+	"upstream_id": "6",
 	"enable_websocket": true`
 	serviceStrS5 = replaceStr(serviceStrS5)
 
@@ -1276,7 +1276,7 @@ func TestRoute_Export(t *testing.T) {
 					"summary": "ๆ‰€ๆœ‰",
 					"x-apisix-enable_websocket": false,
 					"x-apisix-labels": {
-						"API_VERSION": "v1", 
+						"API_VERSION": "v1",
 						"test": "1"
 					},
 					"x-apisix-plugins": {
@@ -1353,7 +1353,7 @@ func TestRoute_Export(t *testing.T) {
 				],
 				"uri": "/hello",
 				"enable_websocket":false,
-				"plugins": { 
+				"plugins": {
 					"prometheus": {
 						"disable": false
 					}
@@ -1886,11 +1886,11 @@ func TestRoute_Export_Label(t *testing.T) {
 	// 10.Create a service with label data and a route with label data, and export the route.
 	// Label is the original data of the route
 	serviceStrS1 := `
-	"name": "testservice", 
-	"desc": "testservice_desc", 
+	"name": "testservice",
+	"desc": "testservice_desc",
 	"labels": {
 		"build": "10"
-	}, 
+	},
 	"enable_websocket": true`
 	serviceStrS1 = replaceStr(serviceStrS1)
 
@@ -1914,8 +1914,8 @@ func TestRoute_Export_Label(t *testing.T) {
 					"summary": "ๆ‰€ๆœ‰",
 					"x-apisix-enable_websocket": false,
 					"x-apisix-labels": {
-						"build": "16", 
-						"env": "production", 
+						"build": "16",
+						"env": "production",
 						"version": "v2"
 					},
 					"x-apisix-priority": 0,
@@ -2025,11 +2025,11 @@ func TestRoute_Export_Label(t *testing.T) {
 	// 11.Create a service with label data and a route without label data, and export the route.
 	//  Label is the data of the service
 	serviceStrS2 := `
-	"name": "testservice", 
-	"desc": "testservice_desc", 
+	"name": "testservice",
+	"desc": "testservice_desc",
 	"labels": {
-		"build": "16", 
-		"env": "production", 
+		"build": "16",
+		"env": "production",
 		"version": "v2"
 	},
 	"enable_websocket": true`
@@ -2055,8 +2055,8 @@ func TestRoute_Export_Label(t *testing.T) {
 					"summary": "ๆ‰€ๆœ‰",
 					"x-apisix-enable_websocket": false,
 					"x-apisix-labels": {
-						"build": "16", 
-						"env": "production", 
+						"build": "16",
+						"env": "production",
 						"version": "v2"
 					},
 					"x-apisix-priority": 0,
@@ -2084,8 +2084,8 @@ func TestRoute_Export_Label(t *testing.T) {
 				"desc": "testservice_desc",
 				"enable_websocket":true,
 				"labels": {
-					"build": "16", 
-					"env": "production", 
+					"build": "16",
+					"env": "production",
 					"version": "v2"
 				}
 			}`,
diff --git a/api/test/e2e/service_test.go b/api/test/e2e/service_test.go
index 9a0cc43..36885ab 100644
--- a/api/test/e2e/service_test.go
+++ b/api/test/e2e/service_test.go
@@ -99,13 +99,13 @@ func TestService(t *testing.T) {
 			Headers: map[string]string{"Authorization": token},
 			Body: `{
 				"name": "testservice",
-				"plugins": { 
-					"limit-count": { 
-						"count": 100, 
-						"time_window": 60, 
-						"rejected_code": 503, 
-						"key": "remote_addr" 
-					} 
+				"plugins": {
+					"limit-count": {
+						"count": 100,
+						"time_window": 60,
+						"rejected_code": 503,
+						"key": "remote_addr"
+					}
 				},
 				"upstream": {
 					"type": "roundrobin",
@@ -176,13 +176,13 @@ func TestService(t *testing.T) {
 					"version":"v2"
 				},
 				"enable_websocket":true,
-				"plugins": { 
-					"limit-count": { 
-						"count": 100, 
-						"time_window": 60, 
-						"rejected_code": 503, 
-						"key": "remote_addr" 
-					} 
+				"plugins": {
+					"limit-count": {
+						"count": 100,
+						"time_window": 60,
+						"rejected_code": 503,
+						"key": "remote_addr"
+					}
 				},
 				"upstream": {
 					"type": "roundrobin",
diff --git a/api/test/shell/manager_smoking.sh b/api/test/shell/manager_smoking.sh
index d4d9475..60d2fef 100755
--- a/api/test/shell/manager_smoking.sh
+++ b/api/test/shell/manager_smoking.sh
@@ -32,7 +32,7 @@ while getopts "s:h:" opt
 do
    case "$opt" in
       s ) skip="$OPTARG" ;;
-      ? ) helpFunction ;; 
+      ? ) helpFunction ;;
    esac
 done
 
@@ -42,8 +42,8 @@ then
    helpFunction;
 fi
 
-if "$skip" 
-then 
+if "$skip"
+then
    echo "skip docker check"
 else
    # Version output
diff --git a/web/cypress/fixtures/selector.json b/web/cypress/fixtures/selector.json
index 8e21de7..e47045b 100644
--- a/web/cypress/fixtures/selector.json
+++ b/web/cypress/fixtures/selector.json
@@ -39,7 +39,7 @@
   "ruleCard": ".ant-modal",
   "operator": "#operator",
   "value": "#value",
-  
+
   "fileSelector": "[type=file]",
   "fileTypeRadio": "[type=radio]",
 
diff --git a/web/src/components/RightContent/index.tsx b/web/src/components/RightContent/index.tsx
index 9a59c08..7224f8e 100644
--- a/web/src/components/RightContent/index.tsx
+++ b/web/src/components/RightContent/index.tsx
@@ -40,7 +40,7 @@ const ENVTagColor = {
 
 const GlobalHeaderRight: React.FC = () => {
   const { initialState } = useModel('@@initialState');
-  
+
   useEffect(() => {
     fetchVersionMatch();
   }, []);
diff --git a/web/src/pages/ServerInfo/typing.d.ts b/web/src/pages/ServerInfo/typing.d.ts
index fc65ad5..025a40f 100644
--- a/web/src/pages/ServerInfo/typing.d.ts
+++ b/web/src/pages/ServerInfo/typing.d.ts
@@ -24,7 +24,7 @@ declare namespace ServerInfoModule {
     hostname: string;
     version: string;
   };
-  
+
   type DashboardInfo = {
     commit_hash: string,
     version: string