You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2021/11/03 04:50:21 UTC

[apisix] branch master updated: ci: lint for editorconfig (#5391)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 25ee29d  ci: lint for editorconfig (#5391)
25ee29d is described below

commit 25ee29d41b4310d8c2168a74025ada3ffd9aab9e
Author: leslie <59...@users.noreply.github.com>
AuthorDate: Wed Nov 3 12:50:17 2021 +0800

    ci: lint for editorconfig (#5391)
---
 utils/install_yaml_conf.sh => .editorconfig        | 36 +++++++--
 .../actions/.editorconfig                          | 10 +--
 .github/workflows/lint.yml                         | 21 +++++
 apisix/plugins/zipkin/random_sampler.lua           |  3 +-
 conf/config-default.yaml                           | 94 +++++++++++-----------
 t/admin/routes4.t                                  |  2 +-
 t/admin/services.t                                 |  2 +-
 t/admin/upstream4.t                                |  4 +-
 t/grpc_server_example                              |  2 +-
 t/plugin/consumer-restriction.t                    |  4 +-
 t/plugin/error-log-logger.t                        |  6 +-
 t/plugin/prometheus2.t                             | 30 +++----
 t/toolkit                                          |  2 +-
 utils/install_yaml_conf.sh                         |  2 +-
 14 files changed, 127 insertions(+), 91 deletions(-)

diff --git a/utils/install_yaml_conf.sh b/.editorconfig
old mode 100755
new mode 100644
similarity index 65%
copy from utils/install_yaml_conf.sh
copy to .editorconfig
index 879aa51..0096ce7
--- a/utils/install_yaml_conf.sh
+++ b/.editorconfig
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -17,9 +15,33 @@
 # limitations under the License.
 #
 
-target_file=$1
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[.gitmodules]
+indent_style = tab
+
+[Makefile]
+indent_style = tab
+
+[*.{yml,yaml}]
+indent_size = 2
+
+[*.go]
+indent_style = tab
+## ignore ASF license
+block_comment_start = /*
+block_comment = *
+block_comment_end = */
+
+[**go.mod]
+indent_style = tab
 
-if [ ! -f "$target_file" ]; then
-    cp  ./conf/config.yaml  $target_file
-	chmod 644 $target_file
-fi
+[t/coredns/db.test.local]
+indent_style = unset
diff --git a/utils/install_yaml_conf.sh b/.github/actions/.editorconfig
old mode 100755
new mode 100644
similarity index 85%
copy from utils/install_yaml_conf.sh
copy to .github/actions/.editorconfig
index 879aa51..94f13f3
--- a/utils/install_yaml_conf.sh
+++ b/.github/actions/.editorconfig
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -17,9 +15,5 @@
 # limitations under the License.
 #
 
-target_file=$1
-
-if [ ! -f "$target_file" ]; then
-    cp  ./conf/config.yaml  $target_file
-	chmod 644 $target_file
-fi
+# ignore third-party actions
+root = true
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index f4ed245..5995b86 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -29,3 +29,24 @@ jobs:
       - name: Plugin Code
         run: |
           sudo bash ./utils/check-plugins-code.sh
+
+  ci-eclint:
+    runs-on: ubuntu-latest
+    timeout-minutes: 5
+
+    steps:
+      - name: Check out code
+        uses: actions/checkout@v2.3.5
+
+      - name: Setup Nodejs env
+        uses: actions/setup-node@v2
+        with:
+          node-version: '12'
+
+      - name: Install eclint
+        run: |
+          sudo npm install -g eclint
+
+      - name: Run eclint
+        run: |
+          eclint check
diff --git a/apisix/plugins/zipkin/random_sampler.lua b/apisix/plugins/zipkin/random_sampler.lua
index cfed3f9..d458bce 100644
--- a/apisix/plugins/zipkin/random_sampler.lua
+++ b/apisix/plugins/zipkin/random_sampler.lua
@@ -24,8 +24,7 @@ local _M = {}
 local mt = { __index = _M }
 
 function _M.new(conf)
-    return setmetatable({
-	}, mt)
+    return setmetatable({}, mt)
 end
 
 function _M.sample(self, sample_ratio)
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index 54e760d..236d50b 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -20,48 +20,48 @@
 #
 
 apisix:
-  # node_listen: 9080              # APISIX listening port
-  node_listen:                     # This style support multiple ports
+  # node_listen: 9080               # APISIX listening port
+  node_listen:                      # This style support multiple ports
     - 9080
   #   - port: 9081
-  #     enable_http2: true         # If not set, the default value is `false`.
-  #   - ip: 127.0.0.2              # Specific IP, If not set, the default value is `0.0.0.0`.
+  #     enable_http2: true          # If not set, the default value is `false`.
+  #   - ip: 127.0.0.2               # Specific IP, If not set, the default value is `0.0.0.0`.
   #     port: 9082
   #     enable_http2: true
   enable_admin: true
-  enable_admin_cors: true          # Admin API support CORS response headers.
-  enable_dev_mode: false           # Sets nginx worker_processes to 1 if set to true
-  enable_reuseport: true           # Enable nginx SO_REUSEPORT switch if set to true.
+  enable_admin_cors: true           # Admin API support CORS response headers.
+  enable_dev_mode: false            # Sets nginx worker_processes to 1 if set to true
+  enable_reuseport: true            # Enable nginx SO_REUSEPORT switch if set to true.
   enable_ipv6: true
-  config_center: etcd              # etcd: use etcd to store the config value
-                                   # yaml: fetch the config value from local yaml file `/your_path/conf/apisix.yaml`
+  config_center: etcd               # etcd: use etcd to store the config value
+                                    # yaml: fetch the config value from local yaml file `/your_path/conf/apisix.yaml`
 
-  #proxy_protocol:                 # Proxy Protocol configuration
-  #listen_http_port: 9181          # The port with proxy protocol for http, it differs from node_listen and port_admin.
-                                   # This port can only receive http request with proxy protocol, but node_listen & port_admin
-                                   # can only receive http request. If you enable proxy protocol, you must use this port to
-                                   # receive http request with proxy protocol
-  #listen_https_port: 9182         # The port with proxy protocol for https
-  #enable_tcp_pp: true             # Enable the proxy protocol for tcp proxy, it works for stream_proxy.tcp option
-  #enable_tcp_pp_to_upstream: true # Enables the proxy protocol to the upstream server
-  enable_server_tokens: true       # Whether the APISIX version number should be shown in Server header.
-                                   # It's enabled by default.
+  #proxy_protocol:                  # Proxy Protocol configuration
+  #listen_http_port: 9181           # The port with proxy protocol for http, it differs from node_listen and port_admin.
+                                    # This port can only receive http request with proxy protocol, but node_listen & port_admin
+                                    # can only receive http request. If you enable proxy protocol, you must use this port to
+                                    # receive http request with proxy protocol
+  #listen_https_port: 9182          # The port with proxy protocol for https
+  #enable_tcp_pp: true              # Enable the proxy protocol for tcp proxy, it works for stream_proxy.tcp option
+  #enable_tcp_pp_to_upstream: true  # Enables the proxy protocol to the upstream server
+  enable_server_tokens: true        # Whether the APISIX version number should be shown in Server header.
+                                    # It's enabled by default.
 
   # configurations to load third party code and/or override the builtin one.
-  extra_lua_path: ""               # extend lua_package_path to load third party code
-  extra_lua_cpath: ""              # extend lua_package_cpath to load third party code
+  extra_lua_path: ""                # extend lua_package_path to load third party code
+  extra_lua_cpath: ""               # extend lua_package_cpath to load third party code
   #lua_module_hook: "my_project.my_hook"  # the hook module which will be used to inject third party code into APISIX
 
-  proxy_cache:                     # Proxy Caching configuration
-    cache_ttl: 10s                 # The default caching time in disk if the upstream does not specify the cache time
-    zones:                         # The parameters of a cache
-      - name: disk_cache_one       # The name of the cache, administrator can specify
-                                   # which cache to use by name in the admin api (disk|memory)
-        memory_size: 50m           # The size of shared memory, it's used to store the cache index for
-                                   # disk strategy, store cache content for memory strategy (disk|memory)
-        disk_size: 1G              # The size of disk, it's used to store the cache data (disk)
+  proxy_cache:                      # Proxy Caching configuration
+    cache_ttl: 10s                  # The default caching time in disk if the upstream does not specify the cache time
+    zones:                          # The parameters of a cache
+      - name: disk_cache_one        # The name of the cache, administrator can specify
+                                    # which cache to use by name in the admin api (disk|memory)
+        memory_size: 50m            # The size of shared memory, it's used to store the cache index for
+                                    # disk strategy, store cache content for memory strategy (disk|memory)
+        disk_size: 1G               # The size of disk, it's used to store the cache data (disk)
         disk_path: /tmp/disk_cache_one  # The path to store the cache data (disk)
-        cache_levels: 1:2        # The hierarchy levels of a cache (disk)
+        cache_levels: 1:2           # The hierarchy levels of a cache (disk)
       #- name: disk_cache_two
       #  memory_size: 50m
       #  disk_size: 1G
@@ -100,8 +100,8 @@ apisix:
       role: viewer
 
   delete_uri_tail_slash: false    # delete the '/' at the end of the URI
-  global_rule_skip_internal_api: true    # does not run global rule in internal apis
-                                         # api that path starts with "/apisix" is considered to be internal api
+  global_rule_skip_internal_api: true     # does not run global rule in internal apis
+                                          # api that path starts with "/apisix" is considered to be internal api
   router:
     http: radixtree_uri         # radixtree_uri: match route by uri(base on radixtree)
                                   # radixtree_host_uri: match route by host + uri(base on radixtree)
@@ -202,16 +202,16 @@ nginx_config:                     # config for render the template to generate n
     # The configuration should be well indented!
 
   http:
-    enable_access_log: true        # enable access log or not, default true
+    enable_access_log: true         # enable access log or not, default true
     access_log: logs/access.log
     access_log_format: "$remote_addr - $remote_user [$time_local] $http_host \"$request\" $status $body_bytes_sent $request_time \"$http_referer\" \"$http_user_agent\" $upstream_addr $upstream_status $upstream_response_time \"$upstream_scheme://$upstream_host$upstream_uri\""
     access_log_format_escape: default       # allows setting json or default characters escaping in variables
-    keepalive_timeout: 60s         # timeout during which a keep-alive client connection will stay open on the server side.
-    client_header_timeout: 60s     # timeout for reading client request header, then 408 (Request Time-out) error is returned to the client
-    client_body_timeout: 60s       # timeout for reading client request body, then 408 (Request Time-out) error is returned to the client
-    client_max_body_size: 0        # The maximum allowed size of the client request body.
-                                   # If exceeded, the 413 (Request Entity Too Large) error is returned to the client.
-                                   # Note that unlike Nginx, we don't limit the body size by default.
+    keepalive_timeout: 60s          # timeout during which a keep-alive client connection will stay open on the server side.
+    client_header_timeout: 60s      # timeout for reading client request header, then 408 (Request Time-out) error is returned to the client
+    client_body_timeout: 60s        # timeout for reading client request body, then 408 (Request Time-out) error is returned to the client
+    client_max_body_size: 0         # The maximum allowed size of the client request body.
+                                    # If exceeded, the 413 (Request Entity Too Large) error is returned to the client.
+                                    # Note that unlike Nginx, we don't limit the body size by default.
 
     send_timeout: 10s              # timeout for transmitting a response to the client.then the connection is closed
     underscores_in_headers: "on"   # default enables the use of underscores in client request header fields
@@ -227,14 +227,14 @@ nginx_config:                     # config for render the template to generate n
     # when establishing a connection with the proxied HTTPS server.
     proxy_ssl_server_name: true
     upstream:
-      keepalive: 320               # Sets the maximum number of idle keepalive connections to upstream servers that are preserved in the cache of each worker process.
-                                   # When this number is exceeded, the least recently used connections are closed.
-      keepalive_requests: 1000     # Sets the maximum number of requests that can be served through one keepalive connection.
-                                   # After the maximum number of requests is made, the connection is closed.
-      keepalive_timeout: 60s       # Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
-    charset: utf-8                 # Adds the specified charset to the "Content-Type" response header field, see
-                                   # http://nginx.org/en/docs/http/ngx_http_charset_module.html#charset
-    variables_hash_max_size: 2048  # Sets the maximum size of the variables hash table.
+      keepalive: 320                # Sets the maximum number of idle keepalive connections to upstream servers that are preserved in the cache of each worker process.
+                                    # When this number is exceeded, the least recently used connections are closed.
+      keepalive_requests: 1000      # Sets the maximum number of requests that can be served through one keepalive connection.
+                                    # After the maximum number of requests is made, the connection is closed.
+      keepalive_timeout: 60s        # Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
+    charset: utf-8                  # Adds the specified charset to the "Content-Type" response header field, see
+                                    # http://nginx.org/en/docs/http/ngx_http_charset_module.html#charset
+    variables_hash_max_size: 2048   # Sets the maximum size of the variables hash table.
 
     lua_shared_dict:
       internal-status: 10m
diff --git a/t/admin/routes4.t b/t/admin/routes4.t
index e425df3..158d6ad 100644
--- a/t/admin/routes4.t
+++ b/t/admin/routes4.t
@@ -754,7 +754,7 @@ passed
                         "methods": ["GET"],
                         "uri": "/index.html",
                         "labels": {
-	                        "env": ["production", "release"]
+                            "env": ["production", "release"]
                         }
                 }]]
                 )
diff --git a/t/admin/services.t b/t/admin/services.t
index dcb7c7a..8493b51 100644
--- a/t/admin/services.t
+++ b/t/admin/services.t
@@ -1220,7 +1220,7 @@ passed
                 ngx.HTTP_PATCH,
                 [[{
                     "labels": {
-	                    "build": "17"
+                        "build": "17"
                     }
                 }]],
                 [[{
diff --git a/t/admin/upstream4.t b/t/admin/upstream4.t
index f3078a1..c829fd2 100644
--- a/t/admin/upstream4.t
+++ b/t/admin/upstream4.t
@@ -344,7 +344,7 @@ passed
                 ngx.HTTP_PATCH,
                 [[{
                     "labels": {
-	                    "build": "17"
+                        "build": "17"
                     }
                 }]],
                 [[{
@@ -388,7 +388,7 @@ passed
                     },
                     "type": "roundrobin",
                     "labels": {
-	                    "env": ["production", "release"]
+                        "env": ["production", "release"]
                     }
                 }]]
                 )
diff --git a/t/grpc_server_example b/t/grpc_server_example
index 2df0e72..f7ee318 160000
--- a/t/grpc_server_example
+++ b/t/grpc_server_example
@@ -1 +1 @@
-Subproject commit 2df0e72ebacfb306fcfb3d61f27583017d0c3c10
+Subproject commit f7ee318f701e04bf21bf000baab539f5a8bc7eaa
diff --git a/t/plugin/consumer-restriction.t b/t/plugin/consumer-restriction.t
index c8d954a..21c26cc 100644
--- a/t/plugin/consumer-restriction.t
+++ b/t/plugin/consumer-restriction.t
@@ -31,8 +31,8 @@ __DATA__
         content_by_lua_block {
             local plugin = require("apisix.plugins.consumer-restriction")
             local conf = {
-		title = "whitelist",
-		whitelist = {
+        title = "whitelist",
+        whitelist = {
                     "jack1",
                     "jack2"
                 }
diff --git a/t/plugin/error-log-logger.t b/t/plugin/error-log-logger.t
index 9dd1c13..7aa37a4 100644
--- a/t/plugin/error-log-logger.t
+++ b/t/plugin/error-log-logger.t
@@ -57,9 +57,9 @@ _EOC_
     $block->set_value("stream_config", $stream_single_server);
 
     my $stream_default_server = <<_EOC_;
-	    content_by_lua_block {
-	    	ngx.log(ngx.INFO, "a stream server")
-	    }
+        content_by_lua_block {
+            ngx.log(ngx.INFO, "a stream server")
+        }
 _EOC_
 
     $block->set_value("stream_server_config", $stream_default_server);
diff --git a/t/plugin/prometheus2.t b/t/plugin/prometheus2.t
index 5749f2f..25fa21e 100644
--- a/t/plugin/prometheus2.t
+++ b/t/plugin/prometheus2.t
@@ -354,21 +354,21 @@ GET /apisix/prometheus/metrics
                         "plugins": {
                             "prometheus": {},
                             "syslog": {
-			                    "host": "127.0.0.1",
-			                    "include_req_body": false,
-			                    "max_retry_times": 1,
-			                    "tls": false,
-			                    "retry_interval": 1,
-			                    "batch_max_size": 1000,
-			                    "buffer_duration": 60,
-			                    "port": 1000,
-			                    "name": "sys-logger",
-			                    "flush_limit": 4096,
-			                    "sock_type": "tcp",
-			                    "timeout": 3,
-			                    "drop_limit": 1048576,
-			                    "pool_size": 5
-		                    }
+                                "host": "127.0.0.1",
+                                "include_req_body": false,
+                                "max_retry_times": 1,
+                                "tls": false,
+                                "retry_interval": 1,
+                                "batch_max_size": 1000,
+                                "buffer_duration": 60,
+                                "port": 1000,
+                                "name": "sys-logger",
+                                "flush_limit": 4096,
+                                "sock_type": "tcp",
+                                "timeout": 3,
+                                "drop_limit": 1048576,
+                                "pool_size": 5
+                            }
                         },
                         "upstream": {
                             "nodes": {
diff --git a/t/toolkit b/t/toolkit
index ab2471c..94f471d 160000
--- a/t/toolkit
+++ b/t/toolkit
@@ -1 +1 @@
-Subproject commit ab2471cc9cbeec6fe605120160eeb9dd17ddda2c
+Subproject commit 94f471d3a9045667bc1f1784a21f89315cd64f7e
diff --git a/utils/install_yaml_conf.sh b/utils/install_yaml_conf.sh
index 879aa51..c369487 100755
--- a/utils/install_yaml_conf.sh
+++ b/utils/install_yaml_conf.sh
@@ -21,5 +21,5 @@ target_file=$1
 
 if [ ! -f "$target_file" ]; then
     cp  ./conf/config.yaml  $target_file
-	chmod 644 $target_file
+    chmod 644 $target_file
 fi