[202x] Enable auto return types
#6745
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
| name: "Check code formatting" | |
| on: | |
| pull_request: | |
| types: [opened, synchronize] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: clang-format-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| code_formatter: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Fetch DirectXShaderCompiler sources | |
| uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| - name: Checkout through merge base | |
| uses: rmacklin/fetch-through-merge-base@bfe4d03a86f9afa52bc1a70e9814fc92a07f7b75 # v0.3.0 | |
| with: | |
| base_ref: ${{ github.event.pull_request.base.ref }} | |
| head_ref: ${{ github.event.pull_request.head.sha }} | |
| deepen_length: 500 | |
| - name: Install clang-format | |
| uses: aminya/setup-cpp@8170d66c458f4a045220b7b0966c10940bb2a15d # v1.8.1 | |
| with: | |
| clangformat: 17.0.1 | |
| - name: Check code formatting | |
| env: | |
| START_REV: ${{ github.event.pull_request.base.sha }} | |
| END_REV: ${{ github.event.pull_request.head.sha }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| patch_file="$RUNNER_TEMP/clang-format.patch" | |
| rm -f "$patch_file" | |
| merge_base="$(git merge-base "$START_REV" "$END_REV")" | |
| formatter_status=0 | |
| git-clang-format \ | |
| --verbose \ | |
| --diff \ | |
| "$merge_base" \ | |
| "$END_REV" || formatter_status=$? | |
| if [[ "$formatter_status" -gt 1 ]]; then | |
| echo "::error::git-clang-format failed: $formatter_status" | |
| exit "$formatter_status" | |
| fi | |
| if [[ "$formatter_status" -eq 1 ]]; then | |
| patch_status=0 | |
| git-clang-format \ | |
| --diff \ | |
| "$merge_base" \ | |
| "$END_REV" >"$patch_file" || patch_status=$? | |
| if [[ "$patch_status" -ne 1 ]]; then | |
| rm -f "$patch_file" | |
| echo "::error::Could not create the clang-format patch." | |
| exit 2 | |
| fi | |
| echo "::error::C/C++ formatting changes are required." | |
| echo "Download clang-format-patch from this run or run 'git clang-format $merge_base' locally." >&2 | |
| exit 1 | |
| fi | |
| - name: Upload formatting patch | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | |
| with: | |
| name: clang-format-patch | |
| path: ${{ runner.temp }}/clang-format.patch | |
| if-no-files-found: ignore | |
| retention-days: 7 |