|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +# |
| 18 | +--- |
| 19 | +name: Refresh image cache |
| 20 | +# Refreshes the CI image cache in the GitHub registry, in its own workflow run. |
| 21 | +# |
| 22 | +# It lives outside `ci-amd.yml` / `ci-arm.yml` because those cancel in progress runs on the next |
| 23 | +# push (`cancel-in-progress: true`), and a cache refresh is precisely the job that must not be |
| 24 | +# cancelled: a branch with no cache builds cold (~20 minutes per Python version), which widens the |
| 25 | +# window in which the next push cancels the run, which leaves the cache missing. `v3-3-test` sat in |
| 26 | +# exactly that loop -- its `linux/amd64` cache existed for the default Python version only, because |
| 27 | +# that was the single matrix entry that finished before the next push killed the rest. |
| 28 | +# |
| 29 | +# Cancelling here would recreate the loop, so this workflow does not cancel. A newer run queues |
| 30 | +# behind the one in flight instead of replacing it. |
| 31 | +on: # yamllint disable-line rule:truthy |
| 32 | + workflow_dispatch: |
| 33 | + inputs: |
| 34 | + platform: |
| 35 | + description: "Platform to refresh the cache for" |
| 36 | + type: choice |
| 37 | + options: |
| 38 | + - "both" |
| 39 | + - "linux/amd64" |
| 40 | + - "linux/arm64" |
| 41 | + default: "both" |
| 42 | + push: |
| 43 | + # Release-prep and providers branches only. `main` refreshes its cache through the scheduled |
| 44 | + # canary in `ci-amd.yml` / `ci-arm.yml`, which nothing cancels -- it is not built on push. |
| 45 | + branches: |
| 46 | + - v[0-9]+-[0-9]+-test |
| 47 | + - providers-[a-z]+-?[a-z]*/v[0-9]+-[0-9]+ |
| 48 | +permissions: |
| 49 | + contents: read |
| 50 | +concurrency: |
| 51 | + group: refresh-image-cache-${{ github.ref }} |
| 52 | + cancel-in-progress: false |
| 53 | +jobs: |
| 54 | + build-info: |
| 55 | + name: "Build info" |
| 56 | + # No outputs yet at this stage, so the runner has to be hard-coded to a public one. |
| 57 | + runs-on: ["ubuntu-22.04"] |
| 58 | + outputs: |
| 59 | + default-branch: ${{ steps.selective-checks.outputs.default-branch }} |
| 60 | + default-constraints-branch: ${{ steps.selective-checks.outputs.default-constraints-branch }} |
| 61 | + disable-airflow-repo-cache: ${{ steps.selective-checks.outputs.disable-airflow-repo-cache }} |
| 62 | + docker-cache: ${{ steps.selective-checks.outputs.docker-cache }} |
| 63 | + include-success-outputs: ${{ steps.selective-checks.outputs.include-success-outputs }} |
| 64 | + python-versions: ${{ steps.selective-checks.outputs.python-versions }} |
| 65 | + use-uv: ${{ steps.selective-checks.outputs.force-pip == 'true' && 'false' || 'true' }} |
| 66 | + steps: |
| 67 | + - name: "Cleanup repo" |
| 68 | + shell: bash |
| 69 | + run: sudo rm -rf ${GITHUB_WORKSPACE}/* |
| 70 | + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" |
| 71 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 72 | + with: |
| 73 | + persist-credentials: false |
| 74 | + - name: "Install Breeze" |
| 75 | + uses: ./.github/actions/breeze |
| 76 | + - name: Selective checks |
| 77 | + id: selective-checks |
| 78 | + env: |
| 79 | + # A cache is only useful for the Python versions that are actually built, so the refresh |
| 80 | + # always covers all of them. Selective checks would otherwise narrow `python-versions` |
| 81 | + # down to the default one -- on a push where only text files changed it does exactly |
| 82 | + # that (`_should_run_all_tests_and_versions`), which is the other way a branch ends up |
| 83 | + # with cache for one Python version and nothing for the rest. |
| 84 | + PR_LABELS: '["all versions"]' |
| 85 | + COMMIT_REF: "${{ github.sha }}" |
| 86 | + VERBOSE: "false" |
| 87 | + run: breeze ci selective-check 2>> ${GITHUB_OUTPUT} |
| 88 | + |
| 89 | + refresh-ci-cache-amd: |
| 90 | + name: "Refresh cache linux/amd64" |
| 91 | + needs: [build-info] |
| 92 | + uses: ./.github/workflows/push-image-cache.yml |
| 93 | + permissions: |
| 94 | + contents: read |
| 95 | + # Only granted for `push` / `workflow_dispatch` on apache/airflow itself, never for forks. |
| 96 | + packages: write |
| 97 | + with: |
| 98 | + runners: '["ubuntu-22.04"]' |
| 99 | + platform: "linux/amd64" |
| 100 | + cache-type: "Refresh" |
| 101 | + # PROD cache is built from distributions prepared earlier in a CI run, which a standalone |
| 102 | + # refresh has no artifact for. CI cache is also where the build time actually goes. |
| 103 | + include-prod-images: "false" |
| 104 | + # `latest` is what CI pulls when it has no cache at all; moving it belongs to a full canary |
| 105 | + # run that ran the tests, not to a cache refresh. |
| 106 | + push-latest-images: "false" |
| 107 | + python-versions: ${{ needs.build-info.outputs.python-versions }} |
| 108 | + branch: ${{ needs.build-info.outputs.default-branch }} |
| 109 | + constraints-branch: ${{ needs.build-info.outputs.default-constraints-branch }} |
| 110 | + use-uv: ${{ needs.build-info.outputs.use-uv }} |
| 111 | + include-success-outputs: ${{ needs.build-info.outputs.include-success-outputs }} |
| 112 | + docker-cache: ${{ needs.build-info.outputs.docker-cache }} |
| 113 | + disable-airflow-repo-cache: ${{ needs.build-info.outputs.disable-airflow-repo-cache }} |
| 114 | + if: inputs.platform == 'both' || inputs.platform == 'linux/amd64' || github.event_name == 'push' |
| 115 | + |
| 116 | + refresh-ci-cache-arm: |
| 117 | + name: "Refresh cache linux/arm64" |
| 118 | + needs: [build-info] |
| 119 | + uses: ./.github/workflows/push-image-cache.yml |
| 120 | + permissions: |
| 121 | + contents: read |
| 122 | + packages: write |
| 123 | + with: |
| 124 | + runners: '["ubuntu-22.04-arm"]' |
| 125 | + platform: "linux/arm64" |
| 126 | + cache-type: "Refresh" |
| 127 | + include-prod-images: "false" |
| 128 | + push-latest-images: "false" |
| 129 | + python-versions: ${{ needs.build-info.outputs.python-versions }} |
| 130 | + branch: ${{ needs.build-info.outputs.default-branch }} |
| 131 | + constraints-branch: ${{ needs.build-info.outputs.default-constraints-branch }} |
| 132 | + use-uv: ${{ needs.build-info.outputs.use-uv }} |
| 133 | + include-success-outputs: ${{ needs.build-info.outputs.include-success-outputs }} |
| 134 | + docker-cache: ${{ needs.build-info.outputs.docker-cache }} |
| 135 | + disable-airflow-repo-cache: ${{ needs.build-info.outputs.disable-airflow-repo-cache }} |
| 136 | + if: inputs.platform == 'both' || inputs.platform == 'linux/arm64' || github.event_name == 'push' |
0 commit comments