name: Lint on: push: branches: - main - rel-* pull_request: workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }} cancel-in-progress: true jobs: optional-lint: name: Optional Lint runs-on: ubuntu-latest timeout-minutes: 120 steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: misspell # Check spellings as well uses: reviewdog/action-misspell@ba7ac4030fa6812f8c8b2d4e516af8bc99553c32 # v1.28.0 with: github_token: ${{ secrets.github_token }} locale: "US" reporter: github-pr-check level: info filter_mode: diff_context - name: shellcheck # Static check shell scripts uses: reviewdog/action-shellcheck@0722bbdb0d47f04c1b53b8734d2422ac63a45ec6 # v1.32.1 with: github_token: ${{ secrets.github_token }} reporter: github-pr-check level: info filter_mode: file lint-python-format: # Required workflow name: Python format runs-on: [ "self-hosted", "1ES.Pool=onnxruntime-github-Ubuntu2204-AMD-CPU", "JobId=lint-python-format-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" ] timeout-minutes: 120 permissions: contents: read security-events: write steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Setup Python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: # Use a version pre-installed in the runner pool's read-only tool cache; requesting an # uncached version makes setup-python fail trying to write to /opt/hostedtoolcache. # This is only the interpreter lintrunner runs on. The Python syntax the linters target # is set by target-version under [tool.ruff] in pyproject.toml, independently of this. python-version: "3.12" - name: Setup Rust uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 with: toolchain: stable components: rustfmt - name: Update PATH run: | echo "$HOME/.local/bin" >> "$GITHUB_PATH" - name: Install dependencies run: | set -e -x python -m pip install --user -r requirements-dev.txt lintrunner init - name: Run lintrunner on all files run: | set +e if ! lintrunner --force-color --all-files --tee-json=lint.json -v; then echo "" echo -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" exit 1 fi - name: Produce SARIF if: always() run: | python -m lintrunner_adapters to-sarif lint.json lintrunner.sarif - name: Upload SARIF file if: always() continue-on-error: true uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 with: # Path to SARIF file relative to the root of the repository sarif_file: lintrunner.sarif category: lintrunner checkout_path: ${{ github.workspace }} lint-cpp: name: Optional Lint C++ runs-on: ubuntu-latest timeout-minutes: 120 steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Update PATH run: | echo "$HOME/.local/bin" >> "$GITHUB_PATH" - name: Install ninja run: python -m pip install --user --upgrade ninja - name: Generate compile_commands.json run: | python tools/ci_build/build.py \ --cmake_generator "Ninja" \ --build_dir build \ --update \ --cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON - name: Generate ONNX protobuf files run: cmake --build build/Debug --config Debug --target onnx_proto - uses: reviewdog/action-cpplint@5f1bbc6ecc3dc6d9b2cb8ddae490464240ae415d # v1.12.0 continue-on-error: true with: github_token: ${{ secrets.github_token }} reporter: github-pr-check level: info flags: --linelength=120 --exclude=java/src/main/native/*.c --exclude=onnxruntime/core/mlas/inc/* --exclude=onnxruntime/core/mlas/lib/* --exclude=onnxruntime/contrib_ops/cuda/bert/flash_attention/* --exclude=build/Debug/* --exclude=cmake/* --exclude=csharp/test/* --exclude=onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/GeneratedShaders/* --exclude=orttraining/orttraining/test/* --exclude=onnxruntime/test/* --exclude=winml/* filter: "-runtime/references"