From 61f5facddd12ada53def33472efbf5231a072a46 Mon Sep 17 00:00:00 2001 From: Huy Do Date: Wed, 26 Oct 2022 20:08:29 +0000 Subject: [PATCH] Set check-latest to false when setup python and pip cache in CI (#87621) I missed the fine print in https://github.com/actions/setup-python/blob/main/README.md#caching-packages-dependencies when setting up the cache using setup-python GHA > Restored cache will not be used if the requirements.txt file is not updated for a long time and a newer version of the dependency is available which can lead to an increase in total build time. The latter part is important because it implies that even with the cache, pip will still try to check if a newer version exists and that part can be flaky, i.e. https://github.com/pytorch/pytorch/actions/runs/3313764038/jobs/5472180293 This undesired behavior can be turned off by setting the advance option `check-latest` to false https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#check-latest-version. Per my understanding, this should tell pip install in these workflows to use the local cached copy of the package avoiding the need to query pypi every single time. `check-latest` was added quite recently https://github.com/actions/setup-python/pull/406, so `actionlint-1.6.15` fails to recognize it. Thus, this PR also upgrades `actionlint` to the latest 1.6.21 to pass the linter check. Here is an example error from 1.6.15 from https://github.com/pytorch/pytorch/actions/runs/3315388073/jobs/5475918454: ``` >>> Lint for .github/workflows/lint.yml: Error (ACTIONLINT) [action] input "check-latest" is not defined in action "actions/setup-python@v4". available inputs are "architecture", "cache", "cache-dependency-path", "python-version", "python-version-file", "token" 25 | with: 26 | python-version: 3.8 27 | architecture: x64 >>> 28 | check-latest: false 29 | cache: pip 30 | cache-dependency-path: | 31 | **/.github/requirements-gha-cache.txt ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/87621 Approved by: https://github.com/ZainRizvi --- .github/actions/setup-win/action.yml | 3 +- .github/workflows/lint.yml | 37 +++++++++++++---------- .github/workflows/pr-labels.yml | 1 + .github/workflows/revert.yml | 5 +-- .github/workflows/trymerge.yml | 5 +-- .github/workflows/tryrebase.yml | 5 +-- .github/workflows/update-viablestrict.yml | 3 +- tools/linter/adapters/s3_init_config.json | 8 ++--- 8 files changed, 39 insertions(+), 28 deletions(-) diff --git a/.github/actions/setup-win/action.yml b/.github/actions/setup-win/action.yml index d442343430c7..6dc1a1b6c6fe 100644 --- a/.github/actions/setup-win/action.yml +++ b/.github/actions/setup-win/action.yml @@ -57,7 +57,8 @@ runs: - name: Setup Python3 uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: '3.x' + check-latest: false cache: pip cache-dependency-path: | **/requirements.txt diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 669977b143a5..cff22d72d4d2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,18 +23,16 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.8' architecture: x64 + check-latest: false cache: pip cache-dependency-path: | **/.github/requirements-gha-cache.txt - - name: Install lintrunner - uses: nick-fields/retry@3e91a01664abd3c5cd539100d10d33b9c5b68482 - with: - timeout_minutes: 5 - max_attempts: 3 - command: pip install lintrunner==0.9.2 + - name: Install requirements + run: | + pip install -r .github/requirements-gha-cache.txt --user - name: Initialize lint dependencies run: lintrunner init @@ -85,8 +83,9 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.x + python-version: '3.x' architecture: x64 + check-latest: false cache: pip cache-dependency-path: | **/requirements.txt @@ -149,8 +148,9 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.x + python-version: '3.x' architecture: x64 + check-latest: false cache: pip cache-dependency-path: | **/requirements.txt @@ -240,9 +240,10 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.8' architecture: x64 - cache: 'pip' + check-latest: false + cache: pip cache-dependency-path: | **/.github/requirements-gha-cache.txt @@ -273,8 +274,9 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.8' architecture: x64 + check-latest: false cache: pip cache-dependency-path: | **/requirements.txt @@ -318,23 +320,26 @@ jobs: if: matrix.test_type == 'older_python_version' uses: actions/setup-python@v4 with: - python-version: 3.5 + python-version: '3.5' architecture: x64 + check-latest: false cache: pip cache-dependency-path: | - **/.github/requirements-gha-cache.txt + **/requirements.txt - name: Setup Python 3.8 if: matrix.test_type != 'older_python_version' uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.8' architecture: x64 + check-latest: false cache: pip cache-dependency-path: | - **/.github/requirements-gha-cache.txt + **/requirements.txt - name: Install torch if: matrix.test_type == 'with_torch' run: | + pip install -r requirements.txt # Doesn't really matter what torch version, we just need ANY torch installed pip install 'torch==1.*' - name: Run collect_env.py diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml index aa8cf4472b78..9afa0e721ac6 100644 --- a/.github/workflows/pr-labels.yml +++ b/.github/workflows/pr-labels.yml @@ -18,6 +18,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.10' + check-latest: false cache: pip cache-dependency-path: | **/.github/requirements-gha-cache.txt diff --git a/.github/workflows/revert.yml b/.github/workflows/revert.yml index d207840f383b..2a2fff27044e 100644 --- a/.github/workflows/revert.yml +++ b/.github/workflows/revert.yml @@ -21,9 +21,10 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.8' architecture: x64 - cache: 'pip' + check-latest: false + cache: pip - run: pip install pyyaml==6.0 - name: Setup committer id diff --git a/.github/workflows/trymerge.yml b/.github/workflows/trymerge.yml index dff92303f505..3d1d92967d88 100644 --- a/.github/workflows/trymerge.yml +++ b/.github/workflows/trymerge.yml @@ -21,8 +21,9 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 - cache: 'pip' + python-version: '3.8' + check-latest: false + cache: pip architecture: x64 - run: pip install pyyaml==6.0 diff --git a/.github/workflows/tryrebase.yml b/.github/workflows/tryrebase.yml index fed9000c420e..53434310c3d0 100644 --- a/.github/workflows/tryrebase.yml +++ b/.github/workflows/tryrebase.yml @@ -20,9 +20,10 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.8' architecture: x64 - cache: 'pip' + check-latest: false + cache: pip - run: pip install pyyaml==6.0 - name: Setup committer id diff --git a/.github/workflows/update-viablestrict.yml b/.github/workflows/update-viablestrict.yml index 5901b1f4cda1..12bf4e271f92 100644 --- a/.github/workflows/update-viablestrict.yml +++ b/.github/workflows/update-viablestrict.yml @@ -22,8 +22,9 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.8' architecture: x64 + check-latest: false cache: pip cache-dependency-path: | **/.circleci/docker/requirements-ci.txt diff --git a/tools/linter/adapters/s3_init_config.json b/tools/linter/adapters/s3_init_config.json index 0b0e87e8e26c..d48f264f83d5 100644 --- a/tools/linter/adapters/s3_init_config.json +++ b/tools/linter/adapters/s3_init_config.json @@ -27,12 +27,12 @@ }, "actionlint": { "Darwin": { - "download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/actionlint/1.6.15/Darwin_amd64/actionlint", - "hash": "e9a0e0b17e54cfefe7964b6aa1da8921b1f8f2318c31c0eb1a17ea3e8ab10db2" + "download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/actionlint/1.6.21/Darwin_amd64/actionlint", + "hash": "b354db83815384d3c3a07f68f44b30cb0a70899757a0d185d7322de9952e8813" }, "Linux": { - "download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/actionlint/1.6.15/Linux_arm64/actionlint", - "hash": "d6b45ae67f29a2bf9ddd226071ddd8f158fdf2992e8515a06838e5fef90f3a2d" + "download_url": "https://oss-clang-format.s3.us-east-2.amazonaws.com/actionlint/1.6.21/Linux_arm64/actionlint", + "hash": "025ac157db121b33971ef24af72d73d71cda3cb1e3a94795bb2708ef4032ca76" } } }