kyuubi/.github/workflows/style.yml
liangbowen 06e69ddb2b [KYUUBI #4295] Introduce super-linter action for linting JSON, XML, ENV files and bash_exec
### _Why are the changes needed?_

- introduce `action/super-linter` with multiple linters, (https://github.com/marketplace/actions/super-linter)
- using the smaller size version of image `github/super-linter/slim` for faster image pulling
- enable linting for `bash_exec` for checking executable of bash scripts, with fixed `tools/spark-block-cleaner/kubernetes/docker/entrypoint.sh`
- enable  integrity checks for JSON files in JSONC style
- enable integrity checks for XML files
- enable linting for ENV files

### _How was this patch tested?_
- [x] Pass CI jobs

Closes #4295 from bowenliang123/superlinter-action.

Closes #4295

321d24912 [liangbowen] update
497bf801c [liangbowen] use JSONC instead of JSON to support comments
43787e233 [liangbowen] use superlinter

Authored-by: liangbowen <liangbowen@gf.com.cn>
Signed-off-by: liangbowen <liangbowen@gf.com.cn>
2023-03-18 21:54:45 +08:00

141 lines
5.5 KiB
YAML

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Style
on:
pull_request:
branches:
- master
- branch-*
concurrency:
group: linter-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
linter:
name: Style check
runs-on: ubuntu-22.04
strategy:
matrix:
profiles:
- '-Pflink-provided,hive-provided,spark-provided,spark-block-cleaner,spark-3.3,spark-3.2,spark-3.1,tpcds,kubernetes-it'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup JDK 8
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
cache: 'maven'
check-latest: false
- name: Setup Maven and Mvnd
uses: ./.github/actions/setup-mvnd
- name: Setup Python 3
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Check kyuubi modules available
id: modules-check
run: build/mvnd dependency:resolve -DincludeGroupIds="org.apache.kyuubi" -DincludeScope="compile" -DexcludeTransitive=true -q ${{ matrix.profiles }}
continue-on-error: true
- name: Install
# When a continue-on-error step fails, the outcome is failure, but the final conclusion is success.
# for more details, please visit: https://github.com/actions/toolkit/issues/399#issuecomment-666147717
if: steps.modules-check.conclusion == 'success' && steps.modules-check.outcome == 'failure'
run: |
MVN_OPT="-DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=warn -Dmaven.javadoc.skip=true -Drat.skip=true -Dscalastyle.skip=true -Dspotless.check.skip"
build/mvnd clean install ${MVN_OPT} -Pflink-provided,hive-provided,spark-provided,spark-block-cleaner,spark-3.2,tpcds
build/mvnd clean install ${MVN_OPT} -pl extensions/spark/kyuubi-extension-spark-3-1 -Pspark-3.1
build/mvnd clean install ${MVN_OPT} -pl extensions/spark/kyuubi-extension-spark-3-3,extensions/spark/kyuubi-spark-connector-kudu,extensions/spark/kyuubi-spark-connector-hive -Pspark-3.3
- name: Scalastyle with maven
id: scalastyle-check
run: build/mvnd scalastyle:check -q ${{ matrix.profiles }}
- name: Print scalastyle error report
if: failure() && steps.scalastyle-check.outcome != 'success'
run: >-
for log in `find * -name "scalastyle-output.xml"`;
do
if grep -q "error" $log; then
cat $log;
fi
done
- name: Spotless style check
run: |
SPOTLESS_BLACK_VERSION=$(build/mvn help:evaluate -Dexpression=spotless.python.black.version -q -DforceStdout)
pip install black==$SPOTLESS_BLACK_VERSION
build/mvnd spotless:check -q ${{ matrix.profiles }} -Pspotless-python
- name: setup npm
uses: actions/setup-node@v3
with:
node-version: 16
- name: Web UI Style with node
run: |
cd ./kyuubi-server/web-ui
npm install pnpm -g
pnpm install
pnpm run lint
echo "---------------------------------------Notice------------------------------------"
echo "If this style check fail, you should follow these commands for a tentative fix"
echo "* cd ./kyuubi-server/web-ui"
echo "* npm run lint-fix"
echo "Following the above steps can solve many style problems. "
echo "If there is a problem that cannot be fixed by the command, "
echo "you need to manually fix it by following the information told by the command above"
echo "---------------------------------------------------------------------------------"
shellcheck:
name: Super Linter and Shellcheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Super Linter Checks
uses: github/super-linter/slim@v4
env:
CREATE_LOG_FILE: true
ERROR_ON_MISSING_EXEC_BIT: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IGNORE_GENERATED_FILES: true
IGNORE_GITIGNORED_FILES: true
LINTER_RULES_PATH: /
LOG_LEVEL: NOTICE
SUPPRESS_POSSUM: true
VALIDATE_BASH_EXEC: true
VALIDATE_ENV: true
VALIDATE_JSONC: true
VALIDATE_POWERSHELL: true
VALIDATE_XML: true
- name: Upload Super Linter logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: super-linter-log
path: super-linter.log
- name: check bin directory
uses: ludeeus/action-shellcheck@1.1.0
with:
# TODO: enable for all folders step by step
scandir: './bin'
severity: error