Add cmakelint to CI (#35525)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/35525
Differential Revision: D20696655
Pulled By: malfet
fbshipit-source-id: 1b15cd730066c8a80440b39110f7f0d51f8ebad0
diff --git a/.cmakelintrc b/.cmakelintrc
new file mode 100644
index 0000000..c70a56f
--- /dev/null
+++ b/.cmakelintrc
@@ -0,0 +1 @@
+filter=-convention/filename,-linelength,-package/consistency,-readability/logic,+readability/mixedcase,-readability/wonkycase,-syntax,-whitespace/eol,+whitespace/extra,-whitespace/indent,-whitespace/mismatch,-whitespace/newline,-whitespace/tabs
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 5eed5a9..7358659 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -172,3 +172,32 @@
regex: '^(?<filename>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+): (?<errorDesc>.*?) \[(?<errorCode>.*)\]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ cmakelint:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Setup Python
+ uses: actions/setup-python@v1
+ with:
+ python-version: 3.x
+ architecture: x64
+ - name: Fetch PyTorch
+ uses: actions/checkout@v1
+ - name: Checkout PR tip
+ run: |
+ set -eux
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
+ # We are on a PR, so actions/checkout leaves us on a merge commit.
+ # Check out the actual tip of the branch.
+ git checkout ${{ github.event.pull_request.head.sha }}
+ fi
+ echo ::set-output name=commit_sha::$(git rev-parse HEAD)
+ id: get_pr_tip
+ - name: Run cmakelint
+ run: |
+ set -eux
+ pip install cmakelint
+ cmakelint --version
+ git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | \
+ grep -E -z -v '^(cmake/Modules/|cmake/Modules_CUDA_fix/)' | \
+ xargs -0 cmakelint --config=.cmakelintrc --spaces=2 --quiet