lint.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. name: Lint
  2. on:
  3. pull_request:
  4. push:
  5. branches:
  6. - nightly
  7. - main
  8. - release/*
  9. workflow_dispatch:
  10. jobs:
  11. python-source-and-configs:
  12. uses: pytorch/test-infra/.github/workflows/linux_job.yml@release/2.1
  13. with:
  14. repository: pytorch/vision
  15. script: |
  16. set -euo pipefail
  17. echo '::group::Setup environment'
  18. CONDA_PATH=$(which conda)
  19. eval "$(${CONDA_PATH} shell.bash hook)"
  20. conda create --name ci --quiet --yes python=3.8 pip
  21. conda activate ci
  22. echo '::endgroup::'
  23. echo '::group::Install lint tools'
  24. pip install --progress-bar=off pre-commit
  25. echo '::endgroup::'
  26. set +e
  27. pre-commit run --all-files
  28. if [ $? -ne 0 ]; then
  29. git --no-pager diff
  30. exit 1
  31. fi
  32. c-source:
  33. uses: pytorch/test-infra/.github/workflows/linux_job.yml@release/2.1
  34. with:
  35. repository: pytorch/vision
  36. script: |
  37. set -euo pipefail
  38. echo '::group::Setup environment'
  39. CONDA_PATH=$(which conda)
  40. eval "$(${CONDA_PATH} shell.bash hook)"
  41. # clang-format needs some shared libraries that conflict with the system ones. Thus, we install them from conda
  42. # and prepend the libraries to linker path to prioritize them. `ncurses=5` is only available on the conda-forge
  43. # channel. Since we are not building or testing here, this is fine.
  44. conda create --name ci --quiet --yes -c conda-forge python=3.8 ncurses=5 libgcc
  45. conda activate ci
  46. export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}"
  47. echo '::endgroup::'
  48. echo '::group::Install lint tools'
  49. curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o ./clang-format
  50. chmod +x ./clang-format
  51. echo '::endgroup::'
  52. echo '::group::Lint C source'
  53. set +e
  54. ./.github/scripts/run-clang-format.py -r torchvision/csrc --clang-format-executable ./clang-format
  55. if [ $? -ne 0 ]; then
  56. git --no-pager diff
  57. exit 1
  58. fi
  59. echo '::endgroup::'
  60. python-types:
  61. uses: pytorch/test-infra/.github/workflows/linux_job.yml@release/2.1
  62. with:
  63. repository: pytorch/vision
  64. script: |
  65. set -euo pipefail
  66. export PYTHON_VERSION=3.8
  67. export GPU_ARCH_TYPE=cpu
  68. export GPU_ARCH_VERSION=''
  69. ./.github/scripts/setup-env.sh
  70. CONDA_PATH=$(which conda)
  71. eval "$(${CONDA_PATH} shell.bash hook)"
  72. conda activate ci
  73. echo '::group::Install lint tools'
  74. pip install --progress-bar=off mypy
  75. echo '::endgroup::'
  76. echo '::group::Lint Python types'
  77. mypy --install-types --non-interactive --config-file mypy.ini
  78. echo '::endgroup::'
  79. bc:
  80. if: github.event.pull_request
  81. runs-on: ubuntu-latest
  82. steps:
  83. - name: Run BC Lint Action
  84. uses: pytorch/test-infra/.github/actions/bc-lint@release/2.1
  85. with:
  86. repo: ${{ github.event.pull_request.head.repo.full_name }}
  87. base_sha: ${{ github.event.pull_request.base.sha }}
  88. head_sha: ${{ github.event.pull_request.head.sha }}