potiuk commented on code in PR #73182:
URL: https://github.com/apache/airflow/pull/73182#discussion_r4025107421


##########
.github/actions/install-prek/action.yml:
##########
@@ -143,16 +137,67 @@ runs:
       shell: bash
       run: cat ~/.cache/prek/prek.log || true
       if: always()
+    - name: "Decide whether to refresh prek cache"
+      id: cache-policy
+      shell: bash
+      env:
+        EVENT_NAME: ${{ github.event_name }}
+        SAVE_CACHE: ${{ inputs.save-cache }}
+        STASH_HIT: ${{ steps.restore-prek-cache.outputs.stash-hit }}
+        TAR_RESTORED: ${{ steps.restore-prek-tar.outputs.tar-restored }}
+      run: |
+        SAVE=false
+        if [[ "${SAVE_CACHE}" == "true" ]]; then
+          if [[ "${STASH_HIT}" != "true" || "${TAR_RESTORED}" != "true" || \

Review Comment:
   This condition and the "always validate" step above it disagree with each 
other.
   
   The stated reason for running `prek install-hooks` unconditionally is that a 
successfully extracted archive can still hold a partial or unusable 
environment. But in precisely that situation `STASH_HIT` and `TAR_RESTORED` are 
both `true`, so `save` is `false` and whatever install-hooks just repaired is 
thrown away. The cache key has not changed, so the next run restores the same 
partial archive and repairs it again — and so on indefinitely, except on 
`schedule`.
   
   Consider having the install-hooks step signal whether it actually had to 
build anything, and OR that into this condition.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to