| # Copyright 2019 The IREE Authors |
| # |
| # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| # See https://llvm.org/LICENSE.txt for license information. |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| |
| # Keep this in sync with build_tools/scripts/lint.sh |
| |
| name: Lint |
| |
| on: [pull_request] |
| |
| permissions: |
| contents: read |
| |
| jobs: |
| pre-commit: |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Checking out repository |
| uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 |
| - name: Setting up python |
| uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 |
| - name: Running pre-commit |
| uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 |
| |
| buildifier: |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Checking out repository |
| uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 |
| - name: Fetching Base Branch |
| # We have to explicitly fetch the base branch as well |
| run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}" |
| - name: Downloading Buildifier |
| run: | |
| mkdir -p "${HOME?}/bin" |
| wget https://github.com/bazelbuild/buildtools/releases/download/4.0.1/buildifier -O "${HOME?}/bin/buildifier" |
| chmod +x "${HOME?}/bin/buildifier" |
| echo "${HOME?}/bin" >> $GITHUB_PATH |
| - name: Running buildifier on changed files |
| run: | |
| # Fail if the script fails (unfixable lint warnings) or it creates a |
| # diff (fixable lint warnings or formatting). |
| EXIT_CODE=0 |
| ./build_tools/scripts/run_buildifier.sh "${GITHUB_BASE_REF?}" || EXIT_CODE=1 |
| git diff --exit-code |
| exit "${EXIT_CODE?}" |
| |
| pytype: |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Checking out repository |
| uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 |
| - name: Setting up python |
| uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 |
| - name: Fetching Base Branch |
| # We have to explicitly fetch the base branch as well |
| run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}" |
| - name: Install pytype |
| run: python3 -m pip install pytype |
| - name: Run pytype on changed files |
| run: ./build_tools/pytype/check_diff.sh "${GITHUB_BASE_REF?}" |
| |
| generated_cmake_files: |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Checking out repository |
| uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 |
| - name: Generating CMake files |
| run: | |
| ./build_tools/scripts/generate_cmake_files.sh |
| - name: Checking Diff |
| run: | |
| # Make sure to run build_tools/scripts/generate_cmake_files.sh and |
| # pick up new files that have been added. |
| git add -A |
| git diff HEAD --exit-code |