onnxruntime
122 строки · 4.0 Кб
1name: Lint
2
3on:
4push:
5branches:
6- main
7- rel-*
8pull_request:
9
10jobs:
11optional-lint:
12name: Optional Lint
13runs-on: ubuntu-latest
14steps:
15- uses: actions/checkout@v4
16- name: misspell # Check spellings as well
17uses: reviewdog/action-misspell@v1
18with:
19github_token: ${{ secrets.github_token }}
20locale: "US"
21reporter: github-pr-check
22level: info
23filter_mode: diff_context
24- name: shellcheck # Static check shell scripts
25uses: reviewdog/action-shellcheck@v1
26with:
27github_token: ${{ secrets.github_token }}
28reporter: github-pr-check
29level: info
30filter_mode: file
31
32lint-python-format:
33# Required workflow
34name: Python format
35runs-on: ubuntu-latest
36steps:
37- uses: actions/checkout@v4
38- name: Setup Python
39uses: actions/setup-python@v5
40with:
41# Version range or exact version of Python to use, using SemVer's version range syntax. Reads from .python-version if unset.
42python-version: "3.10"
43- name: Setup Rust
44uses: actions-rs/toolchain@v1
45with:
46toolchain: stable
47components: rustfmt
48- name: Install dependencies
49run: |
50python -m pip install -r requirements-dev.txt
51python -m pip install lintrunner lintrunner-adapters
52lintrunner init
53- name: Run lintrunner on all files
54run: |
55set +e
56if ! lintrunner --force-color --all-files --tee-json=lint.json -v; then
57echo ""
58echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`. To set up lintrunner locally, see https://github.com/microsoft/onnxruntime/blob/main/docs/Coding_Conventions_and_Standards.md#linting .\e[0m"
59exit 1
60fi
61- name: Produce SARIF
62if: always()
63run: |
64python -m lintrunner_adapters to-sarif lint.json lintrunner.sarif
65- name: Upload SARIF file
66if: always()
67continue-on-error: true
68uses: github/codeql-action/upload-sarif@v3
69with:
70# Path to SARIF file relative to the root of the repository
71sarif_file: lintrunner.sarif
72category: lintrunner
73checkout_path: ${{ github.workspace }}
74
75lint-cpp:
76name: Optional Lint C++
77runs-on: ubuntu-latest
78steps:
79- uses: actions/checkout@master
80- name: Install ninja
81run: python -m pip install --upgrade ninja
82- name: Generate compile_commands.json
83run: |
84python tools/ci_build/build.py \
85--cmake_generator "Ninja" \
86--build_dir build \
87--update \
88--cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON
89- name: Generate ONNX protobuf files
90run: cmake --build build/Debug --config Debug --target onnx_proto
91- uses: reviewdog/action-cpplint@master
92continue-on-error: true
93with:
94github_token: ${{ secrets.github_token }}
95reporter: github-pr-check
96level: info
97flags: --linelength=120
98--exclude=java/src/main/native/*.c
99--exclude=onnxruntime/core/mlas/inc/*
100--exclude=onnxruntime/core/mlas/lib/*
101--exclude=onnxruntime/contrib_ops/cuda/bert/flash_attention/*
102--exclude=build/Debug/*
103--exclude=cmake/*
104--exclude=csharp/test/*
105--exclude=onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/GeneratedShaders/*
106--exclude=orttraining/orttraining/test/*
107--exclude=onnxruntime/test/*
108--exclude=winml/*
109filter: "-runtime/references"
110
111lint-js:
112name: Lint JavaScript
113runs-on: ubuntu-latest
114steps:
115- uses: actions/checkout@v4
116- uses: reviewdog/action-eslint@v1
117with:
118reporter: github-pr-check
119level: error
120filter_mode: file
121eslint_flags: "--ext .ts --ext .tsx"
122workdir: "js/"
123