pre_commit.yaml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. name: pre-commit
  5. on:
  6. pull_request:
  7. merge_group:
  8. push:
  9. branches: [trunk]
  10. jobs:
  11. pre-commit:
  12. runs-on: ubuntu-latest
  13. steps:
  14. - uses: actions/checkout@v4
  15. - uses: actions/setup-python@v4
  16. - uses: pre-commit/action@v3.0.0
  17. # We want to automatically create github suggestions for pre-commit file
  18. # changes for a pull request. But `pull_request` actions never have write
  19. # permissions to the repository, so we create the suggestions in a separate
  20. # privileged `workflow_run` action in pre_commit_suggestions.yaml. Here,
  21. # we upload the diffs and event configuration to an artifact for use by
  22. # that action.
  23. - name: Collect pre-commit output
  24. if: failure()
  25. run: |
  26. mkdir -p pre-commit-output
  27. git diff > pre-commit-output/diff
  28. cp $GITHUB_EVENT_PATH pre-commit-output/event
  29. - uses: actions/upload-artifact@v4
  30. if: failure()
  31. with:
  32. name: pre-commit output
  33. path: pre-commit-output/*