Add lint to ensure .github/ pypi dependencies are pinned (#64463)

Summary:
Example failing run: https://github.com/pytorch/pytorch/pull/64463/checks?check_run_id=3501249102

Pull Request resolved: https://github.com/pytorch/pytorch/pull/64463

Reviewed By: janeyx99

Differential Revision: D30744930

Pulled By: driazati

fbshipit-source-id: 4dd97054db1d4c776a4512bc3d664987cd7b6d23
This commit is contained in:
driazati 2021-09-07 15:15:32 -07:00 committed by Facebook GitHub Bot
parent 7e88d0b370
commit a22c936b63
23 changed files with 47 additions and 34 deletions

View File

@ -90,7 +90,7 @@ on:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Test PyTorch - name: Test PyTorch
run: | run: |

View File

@ -170,7 +170,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -232,7 +232,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix
@ -338,7 +338,7 @@ jobs:
{%- if is_coverage %} {%- if is_coverage %}
- name: Report coverage - name: Report coverage
run: | run: |
python3 -mpip install codecov python3 -mpip install codecov==2.1.12
python3 -mcodecov python3 -mcodecov
{%- endif %} {%- endif %}
- name: Zip test reports for upload - name: Zip test reports for upload

View File

@ -170,7 +170,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -107,7 +107,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
concurrency: concurrency:

View File

@ -106,7 +106,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
concurrency: concurrency:

View File

@ -105,7 +105,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
concurrency: concurrency:

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -302,7 +302,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -302,7 +302,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -302,7 +302,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix
@ -446,7 +446,7 @@ jobs:
docker run --rm -v "$(pwd)":/v -w /v "${ALPINE_IMAGE}" chown -R "$(id -u):$(id -g)" . docker run --rm -v "$(pwd)":/v -w /v "${ALPINE_IMAGE}" chown -R "$(id -u):$(id -g)" .
- name: Report coverage - name: Report coverage
run: | run: |
python3 -mpip install codecov python3 -mpip install codecov==2.1.12
python3 -mcodecov python3 -mcodecov
- name: Zip test reports for upload - name: Zip test reports for upload
if: always() if: always()

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -302,7 +302,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -302,7 +302,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -229,7 +229,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -302,7 +302,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -249,7 +249,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Test PyTorch - name: Test PyTorch
run: | run: |

View File

@ -227,7 +227,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |

View File

@ -227,7 +227,7 @@ jobs:
run: | run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME export COMMIT_TIME
pip3 install requests pip3 install requests==2.26
python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 python3 -m tools.stats.upload_binary_size_to_scuba || exit 0
- name: Chown workspace - name: Chown workspace
run: | run: |
@ -300,7 +300,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -150,7 +150,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -142,7 +142,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -152,7 +152,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -152,7 +152,7 @@ jobs:
image: python:3.9 image: python:3.9
steps: steps:
- name: Install dependencies - name: Install dependencies
run: pip install typing-extensions run: pip install typing-extensions==3.10
- name: Clone pytorch/pytorch - name: Clone pytorch/pytorch
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
- name: Generating test matrix - name: Generating test matrix

View File

@ -64,6 +64,18 @@ jobs:
run: | run: |
# shellcheck disable=SC2016 # shellcheck disable=SC2016
(! git --no-pager grep -InP '# type:\s*ignore(?!\[)' -- '**.py' '**.pyi' ':(exclude)test/test_jit.py' || (echo 'The above lines have unqualified `type: ignore`; please convert them to `type: ignore[xxxx]`'; false)) (! git --no-pager grep -InP '# type:\s*ignore(?!\[)' -- '**.py' '**.pyi' ':(exclude)test/test_jit.py' || (echo 'The above lines have unqualified `type: ignore`; please convert them to `type: ignore[xxxx]`'; false))
- name: Ensure GitHub PyPi dependencies are pinned
if: always()
run: |
(! git --no-pager grep --color=always -InP \
'(pip|pip3|python -m pip|python3 -m pip|python3 -mpip|python -mpip) install ([a-z][\.a-z-0-9]*+(?!(=|.*\.whl))([[:blank:]]|))+' \
-- .github \
':(exclude)**.rst' \
':(exclude)**.py' \
':(exclude)**.md' \
':(exclude)**.diff' \
':(exclude)third_party' ||
(echo "The above lines have unpinned PyPi installs; please pin them to a specific version: e.g. 'thepackage==1.2'"; false))
# note that this next step depends on a clean checkout; # note that this next step depends on a clean checkout;
# if you run it locally then it will likely to complain # if you run it locally then it will likely to complain
# about all the generated files in torch/test # about all the generated files in torch/test
@ -287,7 +299,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
set -eux set -eux
pip3 install typing-extensions --user # for tools/linter/translate_annotations.py pip3 install typing-extensions==3.10 --user # for tools/linter/translate_annotations.py
pip3 install -r requirements-flake8.txt --user pip3 install -r requirements-flake8.txt --user
flake8 --version flake8 --version
- name: Run flake8 - name: Run flake8
@ -416,7 +428,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
set -eux set -eux
pip3 install cmakelint --user pip3 install cmakelint==1.4.1 --user
cmakelint --version cmakelint --version
- name: Run cmakelint - name: Run cmakelint
run: | run: |
@ -442,7 +454,7 @@ jobs:
pip3 install numpy==1.20 --user # https://github.com/pytorch/pytorch/pull/60472 pip3 install numpy==1.20 --user # https://github.com/pytorch/pytorch/pull/60472
pip3 install expecttest==0.1.3 mypy==0.812 --user pip3 install expecttest==0.1.3 mypy==0.812 --user
# Needed to check tools/render_junit.py # Needed to check tools/render_junit.py
pip3 install junitparser rich --user pip3 install junitparser==2.1.1 rich==10.9.0 --user
- name: Run autogen - name: Run autogen
run: | run: |
set -eux set -eux

View File

@ -85,6 +85,7 @@ quick_checks:
--step 'Ensure canonical include' \ --step 'Ensure canonical include' \
--step 'Ensure no versionless Python shebangs' \ --step 'Ensure no versionless Python shebangs' \
--step 'Ensure no unqualified noqa' \ --step 'Ensure no unqualified noqa' \
--step 'Ensure GitHub PyPi dependencies are pinned' \
--step 'Ensure no unqualified type ignore' \ --step 'Ensure no unqualified type ignore' \
--step 'Ensure no direct cub include' \ --step 'Ensure no direct cub include' \
--step 'Ensure correct trailing newlines' \ --step 'Ensure correct trailing newlines' \