forked from Tokutek/tokumxse
-
Notifications
You must be signed in to change notification settings - Fork 68
51 lines (45 loc) · 1.57 KB
/
format.yml
File metadata and controls
51 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: format
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
permissions:
contents: read
security-events: write
jobs:
analyze:
name: Check code formatting
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci-skip-format') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run bazel format
run: |
# The --include_autogenerated_targets=True is needed to create the autogenerated targets.
# Without it, bazel wrapper hook scripts append some additional args that break the formatting check.
bazel run format --include_autogenerated_targets=True -- --origin-branch=origin/${{ github.base_ref }}
- name: Verify formatting
run: |
# Ignore changes to MODULE.bazel.lock as it may be updated by bazel
git checkout -- MODULE.bazel.lock 2>/dev/null || true
if ! git diff --quiet; then
echo "::error::Formatting issues detected."
echo ""
echo "Your PR is not properly formatted."
echo ""
echo "To fix the problem locally, run:"
echo ""
echo " bazel run format"
echo ""
echo "and commit the resulting changes."
echo ""
echo "Affected files:"
git diff --stat
echo "Diff:"
git diff | head -n 1000
exit 1
fi