[FEATURE] Reduction Kernel with Multi Blocks (p.s. I am too lazy to i… #26
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
| name: "[CI] Auto Format and Commit" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| # You should add a Personal Access Token (PAT) to the repository secrets | |
| token: ${{ secrets.PAT || github.token }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install formatter | |
| shell: bash | |
| # [TODO] It seems like ubuntu-latest (24.04) in github actions does not | |
| # have llvm-20 in the apt repository yet. I will change the | |
| # version to 20 when it is available. | |
| run: | | |
| wget https://apt.llvm.org/llvm.sh | |
| sudo chmod +x ./llvm.sh && sudo ./llvm.sh 19 && rm ./llvm.sh | |
| sudo apt-get update | |
| sudo apt-get install clang-format-19 | |
| sudo ln -sf $(which clang-format-19) /usr/bin/clang-format | |
| python -m pip install black | |
| - name: Run format script | |
| shell: bash | |
| run: | | |
| bash ./scripts/format.sh -cxx -py --clang-format-config=.clang-format | |
| - name: Check for Uncommitted Changes | |
| shell: bash | |
| id: format_check | |
| run: | | |
| # Check if clang-format introduced any changes | |
| if [[ `git status --porcelain` ]]; then | |
| echo "Files were not properly formatted. The changes will be pushed to branch main." | |
| echo "format_status=fail" >> $GITHUB_OUTPUT | |
| else | |
| echo "All files are properly formatted." | |
| echo "format_status=pass" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and Push to main | |
| shell: bash | |
| if : ${{ steps.format_check.outputs.format_status == 'fail' }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git commit -am "[skip ci] Auto-format code with clang-format and black" | |
| git push origin main |