[k2] implement zip functions in light runtime #1530
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: "Check code formatting" | |
| permissions: | |
| contents: read | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| code_formatter: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check Newline at End of File | |
| run: | | |
| EXIT_CODE=0 | |
| for file in $(git grep --cached -I --files-with-matches ''); do | |
| if [[ $(tail -c 1 "$file") ]]; then | |
| echo "Missing new line at end of file '$file'" | |
| EXIT_CODE=1 | |
| fi | |
| done | |
| if [[ $EXIT_CODE -ne 0 ]]; then | |
| echo "Code is not formatted. Please fix the errors."; | |
| exit 1 | |
| fi | |
| - name: Check "#pragma once" in files | |
| run: | | |
| EXIT_CODE=0 | |
| for file in $(find . -name '*.h' -type f \( -path './common/*' -o -path './runtime/*' -o -path './runtime-common/*' -o -path './runtime-light/*' \)); do | |
| if [[ $( grep -q -E '^#pragma\ once' "$file" )$? -ne 0 ]]; then | |
| echo "Missing '#pragma once' in file '$file'" | |
| EXIT_CODE=1 | |
| fi | |
| done | |
| if [[ $EXIT_CODE -ne 0 ]]; then | |
| echo "There are errors in the files, please fix them."; | |
| exit 1 | |
| fi | |
| - name: Install clang-format | |
| run: sudo apt-get install -y clang-format-18 | |
| - name: Run clang-format on changed files | |
| run: | | |
| # Get list of changed files | |
| CHANGED_FILES=$(git diff --name-only --diff-filter=ACM origin/master...HEAD --) | |
| CHANGED_CPP_FILES=$(echo "$CHANGED_FILES" | (grep -E '^(common|runtime|runtime-common|runtime-light)/.*\.(cpp|hpp|h|inl)$' || :; )) | |
| # Apply clang-format to each changed source file | |
| echo "$CHANGED_CPP_FILES" | xargs -r clang-format-18 -i | |
| - name: Check for formatting changes | |
| run: | | |
| # Check if any files were modified by clang-format | |
| git diff --exit-code | |
| if [ $? -ne 0 ]; then | |
| echo "Code is not formatted. Please run clang-format." | |
| exit 1 | |
| fi |