This is an automated email from the ASF dual-hosted git repository. pierrejeambrun pushed a commit to branch v2-5-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 459412b1833665370b14f44dfbfb2a5845d971d5 Author: Jarek Potiuk <[email protected]> AuthorDate: Fri Jan 13 14:34:32 2023 +0100 Switch pull-request-target to base branch of pull request (#28921) When pull request target workflow runs, we used build scripts from main - to couple it with github workflows, but GitHub actually uses base branch now for the workflows, so we should also use the target branch for that. This PR changes it and also extracts the code to do the checkout to a separate composite action. (cherry picked from commit 50f20037e8793913c6da2b296462a744dd02e23c) --- .../get-target-branch-build-scripts/action.yml | 44 ++++++++++++ .github/workflows/build-images.yml | 80 +++------------------- .gitignore | 3 + 3 files changed, 55 insertions(+), 72 deletions(-) diff --git a/.github/actions/get-target-branch-build-scripts/action.yml b/.github/actions/get-target-branch-build-scripts/action.yml new file mode 100644 index 0000000000..3d32578a2f --- /dev/null +++ b/.github/actions/get-target-branch-build-scripts/action.yml @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +--- +name: 'Gets target branch build scripts' +description: 'Checks out target branch build scripts (including breeze) and replaces the current version' +runs: + using: "composite" + steps: + - name: Checkout target branch to 'target-airflow' folder to use ci/scripts and breeze from there. + uses: actions/checkout@v3 + with: + path: "target-airflow" + ref: ${{ github.base_ref }} + persist-credentials: false + submodules: recursive + - name: > + Override "scripts/ci", "dev" and "./github/actions" with the target branch + so that the PR does not override it + # We should not override those scripts which become part of the image as they will not be + # changed in the image built - we should only override those that are executed to build + # the image. + shell: bash + run: | + rm -rfv "scripts/ci" + mv -v "target-airflow/scripts/ci" "scripts" + rm -rfv "dev" + mv -v "target-airflow/dev" "." + rm -rfv "./github/actions" + mv -v "target-airflow/.github/actions" "actions" diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index b6934b6555..78f8468493 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -138,12 +138,8 @@ jobs: # Stdout is redirected to GITHUB_ENV but we also print it to stderr to see it in ci log print(output, file=sys.stderr) EOF - - name: Checkout main branch to use breeze from there. - uses: actions/checkout@v3 - with: - ref: "main" - persist-credentials: false - submodules: recursive + - name: "Get target branch build scripts" + uses: ./.github/actions/get-target-branch-build-scripts - name: "Install Breeze" uses: ./.github/actions/breeze - name: Selective checks @@ -183,28 +179,8 @@ jobs: ref: ${{ needs.build-info.outputs.target-commit-sha }} persist-credentials: false submodules: recursive - - name: > - Checkout "main branch to 'main-airflow' folder - to use ci/scripts from there. - uses: actions/checkout@v3 - with: - path: "main-airflow" - ref: "main" - persist-credentials: false - submodules: recursive - - name: > - Override "scripts/ci", "dev" and "./github/actions" with the "main" branch - so that the PR does not override it - # We should not override those scripts which become part of the image as they will not be - # changed in the image built - we should only override those that are executed to build - # the image. - run: | - rm -rfv "scripts/ci" - mv -v "main-airflow/scripts/ci" "scripts" - rm -rfv "dev" - mv -v "main-airflow/dev" "." - rm -rfv "./github/actions" - mv -v "main-airflow/.github/actions" "actions" + - name: "Get target branch build scripts" + uses: ./.github/actions/get-target-branch-build-scripts - name: > Build CI Images ${{needs.build-info.outputs.all-python-versions-list-as-string}}:${{env.IMAGE_TAG}} uses: ./.github/actions/build-ci-images @@ -239,28 +215,8 @@ jobs: ref: ${{ needs.build-info.outputs.target-commit-sha }} persist-credentials: false submodules: recursive - - name: > - Checkout "main" branch to 'main-airflow' folder - to use ci/scripts from there. - uses: actions/checkout@v3 - with: - path: "main-airflow" - ref: "main" - persist-credentials: false - submodules: recursive - - name: > - Override "scripts/ci", "dev" and "./github/actions" with the "main" branch - so that the PR does not override it - # We should not override those scripts which become part of the image as they will not be - # changed in the image built - we should only override those that are executed to build - # the image. - run: | - rm -rfv "scripts/ci" - mv -v "main-airflow/scripts/ci" "scripts" - rm -rfv "dev" - mv -v "main-airflow/dev" "." - rm -rfv "./github/actions" - mv -v "main-airflow/.github/actions" "actions" + - name: "Get target branch build scripts" + uses: ./.github/actions/get-target-branch-build-scripts - name: > Build PROD Images ${{needs.build-info.outputs.all-python-versions-list-as-string}}:${{env.IMAGE_TAG}} @@ -296,28 +252,8 @@ jobs: ref: ${{ needs.build-info.outputs.target-commit-sha }} persist-credentials: false submodules: recursive - - name: > - Checkout "main" branch to 'main-airflow' folder - to use ci/scripts from there. - uses: actions/checkout@v3 - with: - path: "main-airflow" - ref: "main" - persist-credentials: false - submodules: recursive - - name: > - Override "scripts/ci", "dev" and "./github/actions" with the "main" branch - so that the PR does not override it - # We should not override those scripts which become part of the image as they will not be - # changed in the image built - we should only override those that are executed to build - # the image. - run: | - rm -rfv "scripts/ci" - mv -v "main-airflow/scripts/ci" "scripts" - rm -rfv "dev" - mv -v "main-airflow/dev" "." - rm -rfv "./github/actions" - mv -v "main-airflow/.github/actions" "actions" + - name: "Get target branch build scripts" + uses: ./.github/actions/get-target-branch-build-scripts - name: "Start ARM instance" run: ./scripts/ci/images/ci_start_arm_instance_and_connect_to_docker.sh - name: "Install Breeze" diff --git a/.gitignore b/.gitignore index edd1362f96..ebce7707b6 100644 --- a/.gitignore +++ b/.gitignore @@ -230,3 +230,6 @@ licenses/LICENSES-ui.txt # files generated by memray *.py.*.html *.py.*.bin + +# used to checkout target-branch in CI +/target-airflow
