Copilot commented on code in PR #13535: URL: https://github.com/apache/gluten/pull/13535#discussion_r4490125236
########## .github/actions/squash-merge-upstream/action.yml: ########## @@ -0,0 +1,78 @@ +# 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: Squash-merge onto apache/gluten main +description: >- + On a fork push, squash-merge the pushed commit onto the current apache/gluten + main, which is what a pull request merge ref would hold, and leave HEAD at the + result. If anything in `paths` changed, upload the merged tree for the + workflow's other jobs to swap in with .github/actions/checkout-merged. Use it + after actions/checkout with fetch-depth 0. +inputs: + paths: + description: >- + Extended regex for the files the workflow covers. A `paths:` filter on push + diffs against the branch's previous push, not against main, so fork runs + apply the list here. + required: true + paths-ignore: + description: Extended regex for files to leave out before matching `paths`. + default: '^$' +outputs: + base_sha: + description: The apache/gluten main commit the branch was merged onto. + value: ${{ steps.merge.outputs.base_sha }} + relevant: + description: "'false' if nothing in `paths` changed." + value: ${{ steps.merge.outputs.relevant }} +runs: + using: composite + steps: + - name: Squash-merge the pushed commit + id: merge + shell: bash + env: + PATHS: ${{ inputs.paths }} + PATHS_IGNORE: ${{ inputs.paths-ignore }} + run: | + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + git fetch --no-tags https://github.com/apache/gluten.git main + base_sha=$(git rev-parse FETCH_HEAD) + git checkout --quiet --detach "$base_sha" + if ! git merge --squash --no-commit "$GITHUB_SHA"; then + echo "::error::$GITHUB_REF_NAME does not merge cleanly into apache/gluten main ($base_sha). Rebase it and push again." + exit 1 + fi + git commit --quiet --allow-empty -m "Squash-merge $GITHUB_SHA onto $base_sha" + echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT" + if git diff --name-only "$base_sha" HEAD | grep -vE "$PATHS_IGNORE" | grep -qE "$PATHS"; then Review Comment: With Bash's `pipefail`, `grep -qE` can exit after the first match and cause an upstream command to fail with SIGPIPE on a large changed-path list. This reports `relevant=false` despite matching files, silently skipping the x86 and ARM builds. Use a matcher that consumes all input, such as `grep -E` with its output redirected to `/dev/null`. ########## .github/actions/squash-merge-upstream/action.yml: ########## @@ -0,0 +1,78 @@ +# 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: Squash-merge onto apache/gluten main +description: >- + On a fork push, squash-merge the pushed commit onto the current apache/gluten + main, which is what a pull request merge ref would hold, and leave HEAD at the + result. If anything in `paths` changed, upload the merged tree for the + workflow's other jobs to swap in with .github/actions/checkout-merged. Use it + after actions/checkout with fetch-depth 0. +inputs: + paths: + description: >- + Extended regex for the files the workflow covers. A `paths:` filter on push + diffs against the branch's previous push, not against main, so fork runs + apply the list here. + required: true + paths-ignore: + description: Extended regex for files to leave out before matching `paths`. + default: '^$' +outputs: + base_sha: + description: The apache/gluten main commit the branch was merged onto. + value: ${{ steps.merge.outputs.base_sha }} + relevant: + description: "'false' if nothing in `paths` changed." + value: ${{ steps.merge.outputs.relevant }} +runs: + using: composite + steps: + - name: Squash-merge the pushed commit + id: merge + shell: bash + env: + PATHS: ${{ inputs.paths }} + PATHS_IGNORE: ${{ inputs.paths-ignore }} + run: | + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + git fetch --no-tags https://github.com/apache/gluten.git main + base_sha=$(git rev-parse FETCH_HEAD) + git checkout --quiet --detach "$base_sha" + if ! git merge --squash --no-commit "$GITHUB_SHA"; then + echo "::error::$GITHUB_REF_NAME does not merge cleanly into apache/gluten main ($base_sha). Rebase it and push again." + exit 1 + fi + git commit --quiet --allow-empty -m "Squash-merge $GITHUB_SHA onto $base_sha" + echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT" + if git diff --name-only "$base_sha" HEAD | grep -vE "$PATHS_IGNORE" | grep -qE "$PATHS"; then + echo "relevant=true" >> "$GITHUB_OUTPUT" + else + echo "Nothing this workflow covers changed -- skipping." + echo "relevant=false" >> "$GITHUB_OUTPUT" + fi + - name: Pack the merged tree + if: steps.merge.outputs.relevant == 'true' + shell: bash + run: git archive --format=tar.gz -o "$RUNNER_TEMP/merged-tree.tar.gz" HEAD + - uses: actions/upload-artifact@v7 + if: steps.merge.outputs.relevant == 'true' + with: + name: merged-tree + path: ${{ runner.temp }}/merged-tree.tar.gz + compression-level: 0 + if-no-files-found: error + retention-days: 1 Review Comment: After `merged-tree` expires in one day, rerunning failed jobs fails in `checkout-merged` because the successful `detect-changes` job is not rerun to recreate it. This blocks retries even for ARM jobs whose native artifacts still exist. Remove the one-day override so the merged tree uses the repository's normal retention period. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
