mirror of
https://github.com/cocos/cocos-engine.git
synced 2026-09-06 15:48:37 +08:00
103 lines
3.9 KiB
YAML
103 lines
3.9 KiB
YAML
name: <Native> Linter
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'templates/**'
|
|
- 'native/**'
|
|
|
|
# github.head_ref is only defined on pull_request events
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# Set the job key. The key is displayed as the job name
|
|
# when a job name is not provided
|
|
super-lint:
|
|
# Name the Job
|
|
name: ClangTidy Android
|
|
# Set the type of machine to run on
|
|
if:
|
|
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Checks out a copy of your repository on the ubuntu-latest machine
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
- name: Install CMake & Clang Tidy
|
|
run: |
|
|
sudo apt update --fix-missing
|
|
sudo apt install -y cmake llvm clang-tidy-11 ninja-build
|
|
- name: Download external
|
|
run: |
|
|
EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
|
|
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
|
|
- uses: nttld/setup-ndk@v1
|
|
id: setup-ndk
|
|
with:
|
|
ndk-version: r21e
|
|
add-to-path: false
|
|
local-cache: true
|
|
- name: Get changed files
|
|
uses: PatriceJiang/paths-filter@master
|
|
id: listchanged
|
|
with:
|
|
list-files: shell
|
|
filters: |
|
|
source:
|
|
- added|modified: '**/*.cpp'
|
|
- added|modified: '**/*.h'
|
|
- added|modified: '**/*.hpp'
|
|
- added|modified: '**/*.m'
|
|
- added|modified: '**/*.mm'
|
|
- added|modified: '**/*.c'
|
|
- exclude: 'native/cocos/editor-support/**'
|
|
- exclude: 'native/cocos/base/etc1.*'
|
|
- exclude: 'native/cocos/base/etc2.*'
|
|
- exclude: 'native/cocos/bindings/manual/jsb_global.cpp'
|
|
- exclude: 'native/cocos/bindings/manual/jsb_dragonbones_manual.cpp'
|
|
- exclude: 'native/cocos/bindings/manual/jsb_spine_manual.cpp'
|
|
- exclude: 'native/cocos/bindings/manual/jsb_socketio.cpp'
|
|
- exclude: 'native/cocos/bindings/manual/jsb_conversions.*'
|
|
- exclude: 'native/cocos/bindings/jswrapper/v8/debugger/**'
|
|
- exclude: 'native/cocos/audio/android/audio_utils/**'
|
|
- exclude: 'native/cocos/audio/android/AudioMixer.cpp'
|
|
- exclude: 'native/cocos/audio/android/AudioResampler.cpp'
|
|
- exclude: 'native/cocos/audio/common/utils/**'
|
|
allChanges:
|
|
- added|modified|deleted: '**'
|
|
skipedDebug:
|
|
- added|modified|deleted: '**'
|
|
- exclude: 'native/cocos/editor-support/**'
|
|
|
|
- name: Generate Compile database
|
|
shell: bash
|
|
env:
|
|
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
|
run: |
|
|
cd native
|
|
./utils/generate_compile_commands_android.sh
|
|
ninja -C build -t targets |grep -E ".*jsb_.*auto.*" |awk -F": " '{print $1}' |xargs ninja -C build
|
|
|
|
- name: Generate clang-fix.yaml
|
|
shell: bash
|
|
if: ${{ steps.listchanged.outputs.source == 'true' }}
|
|
run: |
|
|
CPP="${{ steps.listchanged.outputs.source_files }}"
|
|
FILTERED=`node .github/workflows/filter_by_cdb.js $CPP`
|
|
if [[ "$FILTERED-xxx" == "-xxx" ]]; then
|
|
echo "no source files match"
|
|
else
|
|
clang-tidy-11 --format-style=file --export-fixes=clang-fixes.yaml $FILTERED
|
|
fi
|
|
- name: clang-tidy-action
|
|
uses: PatriceJiang/clang-tidy-action@master
|
|
if: hashFiles('clang-fixes.yaml') != ''
|
|
with:
|
|
fixesFile: clang-fixes.yaml
|
|
noFailOnIssue: false
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
error-limit: 200
|