Skip to content

Commit 004174e

Browse files
authored
ci: add misc linters (#28)
1 parent 1712ef8 commit 004174e

File tree

5 files changed

+76
-2
lines changed

5 files changed

+76
-2
lines changed

.editorconfig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
root = true
19+
20+
[*]
21+
charset = utf-8
22+
end_of_line = lf
23+
indent_style = space
24+
indent_size = 4
25+
insert_final_newline = true
26+
trim_trailing_whitespace = true
27+
28+
[Makefile]
29+
indent_style = tab
30+
31+
[*.go]
32+
indent_style = tab
33+
block_comment_start = /*
34+
block_comment = *
35+
block_comment_end = */
36+
37+
[**/go.mod]
38+
indent_style = tab

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
lua:
10+
lint:
1111
runs-on: "ubuntu-18.04"
1212

1313
steps:
@@ -21,4 +21,4 @@ jobs:
2121
2222
- name: Script
2323
run: |
24-
luacheck .
24+
make lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ wasmtime-c-api
1010
t/servroot
1111
node_modules/
1212
t/testdata/rust/target
13+
utils/reindex

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,16 @@ build.testdata:
1818
build.all.testdata: build.go.testdata
1919
@cd ./t/testdata/assemblyscript && npm install && npm run asbuild
2020
@cd ./t/testdata/rust && cargo build --target=wasm32-wasi
21+
22+
.PHONY: utils
23+
utils:
24+
ifeq ("$(wildcard utils/reindex)", "")
25+
wget -P utils https://raw.githubusercontent.com/iresty/openresty-devel-utils/master/reindex
26+
chmod a+x utils/reindex
27+
endif
28+
29+
30+
.PHONY: lint
31+
lint: utils
32+
luacheck .
33+
./utils/check-test-code-style.sh

utils/check-test-code-style.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
4+
set -x -euo pipefail
5+
6+
find t -name '*.t' -exec grep -E "\-\-\-\s+(SKIP|ONLY|LAST|FIRST)$" {} + > /tmp/error.log || true
7+
if [ -s /tmp/error.log ]; then
8+
echo "Forbidden directives to found. Bypass test cases without reason are not allowed."
9+
cat /tmp/error.log
10+
exit 1
11+
fi
12+
13+
find t -name '*.t' -exec ./utils/reindex {} + > \
14+
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
15+
16+
grep "done." /tmp/check.log > /tmp/error.log || true
17+
if [ -s /tmp/error.log ]; then
18+
echo "=====bad style====="
19+
cat /tmp/error.log
20+
echo "you need to run 'reindex' to fix them. Read CONTRIBUTING.md for more details."
21+
exit 1
22+
fi

0 commit comments

Comments
 (0)