You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/02/24 22:14:13 UTC

[airflow] branch master updated: Pre-commit cache is tied to a specific python version (#14430)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new f3bc8ab  Pre-commit cache is tied to a specific python version (#14430)
f3bc8ab is described below

commit f3bc8ab7826cf88968269f26081461543506394f
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Wed Feb 24 23:13:55 2021 +0100

    Pre-commit cache is tied to a specific python version (#14430)
    
    The Pre-commit cache did not work when there is a change in
    version of host python version used. When python version changed
    from 3.6.12 to 3.6.13, the cache rendered useless.
    
    This change adds python versio to the cache key specification,
    including fallback value also including the python version, so
    that even after changing pre-commit, the cache can be rebuilt
    from the last-good cache but for the same python version.
---
 .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e958aa4..255d15d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -293,18 +293,25 @@ jobs:
         if: "!contains(needs.build-info.outputs.runsOn, 'self-hosted')"
       - name: "Prepare CI image ${{env.PYTHON_MAJOR_MINOR_VERSION}}:${{ env.GITHUB_REGISTRY_PULL_IMAGE_TAG }}"
         run: ./scripts/ci/images/ci_prepare_ci_image_on_ci.sh
+      - name: "Get Python version"
+        run: "echo \"::set-output name=host-python-version::$(python -c
+ 'import platform; print(platform.python_version())')\""
+        id: host-python-version
       - name: "Cache pre-commit local-installation"
         uses: actions/cache@v2
         with:
           path: ~/.local
-          key: pre-commit-local-installation-${{ hashFiles('setup.py', 'setup.cfg') }}
-          restore-keys: pre-commit-local-installation-
+          key: "pre-commit-local-installation-${{steps.host-python-version.outputs.host-python-version}}-\
+${{ hashFiles('setup.py', 'setup.cfg') }}"
+          restore-keys: "\
+pre-commit-local-installation-${{steps.host-python-version.outputs.host-python-version}}-"
       - name: "Cache pre-commit envs: no-pylint"
         uses: actions/cache@v2
         with:
           path: ~/.cache/pre-commit
-          key: pre-commit-no-pylint-${{ hashFiles('.pre-commit-config.yaml') }}
-          restore-keys: pre-commit-no-pylint-
+          key: "pre-commit-no-pylint-${{steps.host-python-version.outputs.host-python-version}}-\
+${{ hashFiles('.pre-commit-config.yaml') }}"
+          restore-keys: pre-commit-no-pylint-${{steps.host-python-version.outputs.host-python-version}}
       - name: "Static checks: except pylint"
         run: ./scripts/ci/static_checks/run_static_checks.sh
         env:
@@ -339,18 +346,25 @@ jobs:
           ref: ${{ github.sha }}
           fetch-depth: 2
           persist-credentials: false
-      - name: "Cache pre-commit local installation"
+      - name: "Get Python version"
+        run: "echo \"::set-output name=host-python-version::$(python -c
+ 'import platform; print(platform.python_version())')\""
+        id: host-python-version
+      - name: "Cache pre-commit local-installation"
         uses: actions/cache@v2
         with:
           path: ~/.local
-          key: pre-commit-local-installation-${{ hashFiles('setup.py', 'setup.cfg') }}
-          restore-keys: pre-commit-local-installation-
-      - name: "Cache pre-commit envs - basic"
+          key: "pre-commit-local-installation-${{steps.host-python-version.outputs.host-python-version}}-\
+${{ hashFiles('setup.py', 'setup.cfg') }}"
+          restore-keys: "\
+pre-commit-local-installation-${{steps.host-python-version.outputs.host-python-version}}-"
+      - name: "Cache pre-commit envs: no-pylint"
         uses: actions/cache@v2
         with:
           path: ~/.cache/pre-commit
-          key: pre-commit-basic-${{ hashFiles('.pre-commit-config.yaml') }}
-          restore-keys: pre-commit-basic-
+          key: "pre-commit-no-pylint-${{steps.host-python-version.outputs.host-python-version}}-\
+${{ hashFiles('.pre-commit-config.yaml') }}"
+          restore-keys: pre-commit-no-pylint-${{steps.host-python-version.outputs.host-python-version}}
       - name: "Static checks: basic checks only"
         run: ./scripts/ci/static_checks/run_basic_static_checks.sh "${{ github.sha }}"
         env:
@@ -383,18 +397,25 @@ jobs:
         if: "!contains(needs.build-info.outputs.runsOn, 'self-hosted')"
       - name: "Prepare CI image ${{env.PYTHON_MAJOR_MINOR_VERSION}}:${{ env.GITHUB_REGISTRY_PULL_IMAGE_TAG }}"
         run: ./scripts/ci/images/ci_prepare_ci_image_on_ci.sh
+      - name: "Get Python version"
+        run: "echo \"::set-output name=host-python-version::$(python -c
+ 'import platform; print(platform.python_version())')\""
+        id: host-python-version
       - name: "Cache pre-commit local-installation"
         uses: actions/cache@v2
         with:
           path: ~/.local
-          key: pre-commit-local-installation-${{ hashFiles('setup.py', 'setup.cfg') }}
-          restore-keys: pre-commit-local-installation-
+          key: "pre-commit-local-installation-${{steps.host-python-version.outputs.host-python-version}}-\
+${{ hashFiles('setup.py', 'setup.cfg') }}"
+          restore-keys: "\
+pre-commit-local-installation-${{steps.host-python-version.outputs.host-python-version}}-"
       - name: "Cache pre-commit envs - pylint"
         uses: actions/cache@v2
         with:
           path: ~/.cache/pre-commit
-          key: pre-commit-pylint-${{ hashFiles('.pre-commit-config.yaml') }}
-          restore-keys: pre-commit-pylint-
+          key: "pre-commit-pylint-${{steps.host-python-version.outputs.host-python-version}}-\
+${{ hashFiles('.pre-commit-config.yaml') }}"
+          restore-keys: pre-commit-pylint-${{steps.host-python-version.outputs.host-python-version}}
       - name: "Static checks: pylint"
         run: ./scripts/ci/static_checks/run_static_checks.sh pylint
         env: