This is needed for #187905. Unless we disable the check, Zizmor will flag uses of `actions/checkout` without an explicit `persist-credentials` setting. Of course, some workflows could rely on the credentials persisted by `actions/checkout`. I asked Claude to check each affected job, and it flagged only `prune-branches.yml`. The script `prune-unused-branches.py` relies on the persisted credentials, so I've left that as `persist-credentials: true` for now.
66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
with:
|
|
persist-credentials: false
|
|
fetch-depth: 2
|
|
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@e0021407031f5be11a464abee9a0776171c79891 # v47.0.1
|
|
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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
if: always()
|
|
with:
|
|
name: workflow-args
|
|
path: |
|
|
comments
|