Skip to content

Commit f31bef4

Browse files
authored
ci: add shellcheck linter (#6428)
1 parent c4229d1 commit f31bef4

4 files changed

+42
-2
lines changed

.github/workflows/code-lint.yml

+15
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@ jobs:
2828
. ./ci/common.sh
2929
export_or_prefix
3030
make lint
31+
32+
sc-lint:
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 5
35+
steps:
36+
- name: Checkout code
37+
uses: actions/[email protected]
38+
39+
- name: Shellcheck code
40+
run: |
41+
scversion="latest"
42+
wget -O- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
43+
cp -av "shellcheck-${scversion}/shellcheck" /usr/local/bin/
44+
shellcheck --version
45+
git ls-files | grep ".sh$" | xargs -t shellcheck

.shellcheckrc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
# wiki link pattern https://github.com/koalaman/shellcheck/wiki/{code}
19+
# like SC2148, links to https://github.com/koalaman/shellcheck/wiki/SC2148
20+
21+
disable=SC1083,SC1091
22+
disable=SC2002,SC2004,SC2006,SC2009,SC2010,SC2016,SC2024,SC2027,SC2034,SC2046,SC2048,SC2059
23+
disable=SC2068,SC2076,SC2086,SC2089,SC2090
24+
disable=SC2103,SC2126,SC2143,SC2148,SC2155,SC2157,SC2164,SC2181
25+
disable=SC2215,SC2216,SC2251,SC2260,SC3037

ci/linux_apisix_current_luarocks_runner.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ script() {
4848
sudo PATH=$PATH apisix start
4949
sudo PATH=$PATH apisix stop
5050

51-
cat /usr/local/apisix/logs/error.log | grep '\[error\]' > /tmp/error.log | true
51+
grep '\[error\]' /usr/local/apisix/logs/error.log > /tmp/error.log | true
5252
if [ -s /tmp/error.log ]; then
5353
echo "=====found error log====="
5454
cat /usr/local/apisix/logs/error.log

ci/linux_apisix_master_luarocks_runner.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ script() {
5353
# apisix cli test
5454
# todo: need a more stable way
5555

56-
cat /usr/local/apisix/logs/error.log | grep '\[error\]' > /tmp/error.log | true
56+
grep '\[error\]' /usr/local/apisix/logs/error.log > /tmp/error.log | true
5757
if [ -s /tmp/error.log ]; then
5858
echo "=====found error log====="
5959
cat /usr/local/apisix/logs/error.log

0 commit comments

Comments
 (0)