[submodule-sync] bot-submodule-sync-main to main [skip ci] [bot] #278
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright (c) 2026, NVIDIA CORPORATION. | |
| # | |
| # Licensed 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. | |
| # A workflow to sync the clang-format version between spark-rapids-jni and cudf | |
| name: sync clang-format version with cudf | |
| on: | |
| pull_request_target: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| paths: | |
| - 'thirdparty/cudf' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync-clang-format-version: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: NVIDIA/spark-rapids-common/checkout@main | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| submodules: true | |
| - name: Update clang-format version | |
| id: update_clang_format_version | |
| run: | | |
| # Get the clang-format version from cudf | |
| PATTERN="https://github.com/pre-commit/mirrors-clang-format" | |
| CUDF_VER=$(grep -A1 "repo: $PATTERN" "thirdparty/cudf/.pre-commit-config.yaml" | grep "rev:" | tail -1 | sed "s/.*rev: *//") | |
| if [ -z "$CUDF_VER" ]; then | |
| echo "ERROR: Failed to extract clang-format version from cudf" | |
| exit 1 | |
| fi | |
| echo "Extracted cudf clang-format version: ${CUDF_VER}" | |
| echo "new_ver=${CUDF_VER}" >> $GITHUB_OUTPUT | |
| # Replace the rev for mirrors-clang-format only (next line after the repo URL) | |
| sed -i "\|repo: $PATTERN|{n;s|^\( *rev: *\).*|\1${CUDF_VER}|}" .pre-commit-config.yaml | |
| echo "Changes after sed:" | |
| git diff .pre-commit-config.yaml | |
| - name: Create PR if changed | |
| env: | |
| GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} | |
| NEW_VER: ${{ steps.update_clang_format_version.outputs.new_ver }} | |
| GIT_AUTHOR_NAME: "spark-rapids automation" | |
| GIT_COMMITTER_NAME: "spark-rapids automation" | |
| GIT_AUTHOR_EMAIL: "70000568+nvauto@users.noreply.github.com" | |
| GIT_COMMITTER_EMAIL: "70000568+nvauto@users.noreply.github.com" | |
| run: | | |
| # Skip if no changes | |
| git diff --quiet && exit 0 | |
| # Check if a PR already exists for this version | |
| BRANCH="auto/sync-clang-format-${NEW_VER}-${{ github.event.pull_request.base.ref }}" | |
| echo "Branch: ${BRANCH}" | |
| EXISTING=$( | |
| gh pr list \ | |
| --head "$BRANCH" \ | |
| --base "${{ github.event.pull_request.base.ref }}" \ | |
| --state open \ | |
| --json number \ | |
| --jq 'length' | |
| ) | |
| if [ "$EXISTING" -gt 0 ]; then | |
| echo "PR already exists for $BRANCH" | |
| exit 0 | |
| fi | |
| # Create branch, commit, push, and open PR | |
| git checkout -b "$BRANCH" | |
| git add .pre-commit-config.yaml | |
| git commit -s -m "Sync clang-format version with cudf and update version to ${NEW_VER}" | |
| git push -u origin "$BRANCH" | |
| BODY="## Summary" | |
| BODY="${BODY}\nThe cudf submodule was updated and its mirrors-clang-format version changed to ${NEW_VER}." | |
| BODY="${BODY}\nThis PR updates .pre-commit-config.yaml to match." | |
| BODY="${BODY}\nPlease delete the branch when merging this PR." | |
| BODY="${BODY}\n\nAuto-generated by the sync-clang-format-version workflow." | |
| gh pr create \ | |
| --base "${{ github.event.pull_request.base.ref }}" \ | |
| --title "Sync clang-format to ${NEW_VER} [skip ci] [bot]" \ | |
| --body "$(echo -e "$BODY")" | |