[Github] Make pr-code-format.yml use ci-*-format container #234933
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" | |
| permissions: | |
| contents: read | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| - 'users/**' | |
| jobs: | |
| code_formatter: | |
| runs-on: ubuntu-24.04 | |
| container: | |
| image: 'ghcr.io/llvm/ci-ubuntu-24.04-format' | |
| timeout-minutes: 30 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| if: github.repository == 'llvm/llvm-project' | |
| steps: | |
| - name: Fetch LLVM sources | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 2 | |
| # We need to set the repo checkout as safe, otherwise tj-actions/changed-files | |
| # will fail due to the changed ownership inside the container. | |
| - name: Set Safe Directory | |
| run: | | |
| git config --global --add safe.directory '*' | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 | |
| with: | |
| separator: "," | |
| skip_initial_fetch: true | |
| base_sha: 'HEAD~1' | |
| sha: 'HEAD' | |
| - name: "Listed files" | |
| env: | |
| CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
| run: | | |
| echo "Formatting files:" | |
| echo "$CHANGED_FILES" | |
| - name: Run code formatter | |
| env: | |
| GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} | |
| CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
| # Create an empty comments file so the pr-write job doesn't fail. | |
| run: | | |
| echo "[]" > comments && | |
| python ./llvm/utils/git/code-format-helper.py \ | |
| --write-comment-to-file \ | |
| --token ${{ secrets.GITHUB_TOKEN }} \ | |
| --issue-number $GITHUB_PR_NUMBER \ | |
| --start-rev HEAD~1 \ | |
| --end-rev HEAD \ | |
| --changed-files "$CHANGED_FILES" | |
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: always() | |
| with: | |
| name: workflow-args | |
| path: | | |
| comments |