-
Notifications
You must be signed in to change notification settings - Fork 92
104 lines (90 loc) · 3.65 KB
/
checkstyle.yaml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Check Style
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
checkstyle:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'style skip')"
steps:
- name: Checkout
uses: actions/checkout@v3
# TODO(https://github.com/tj-actions/changed-files/issues/809): Re-enable
# - name: Get changed files
# id: changed-files
# uses: tj-actions/[email protected]
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: "1.21.3" # Keep in sync with WORKSPACE
- name: gofmt
run: |
gofmt -d . > gofmt-diff.txt || true
echo "gofmt diff:"
cat gofmt-diff.txt
- name: buildifier
run: |
go install github.com/bazelbuild/buildtools/[email protected]
"$(go env GOPATH)/bin/buildifier" -d -r . > buildifier-diff.txt || true
echo "buildifier diff:"
cat buildifier-diff.txt
- name: go deps
# Keep Gazelle version in sync with WORKSPACE
run: |
go install github.com/bazelbuild/bazel-gazelle/cmd/[email protected]
GAZELLE_PATH="$(go env GOPATH)/bin/gazelle" \
GO_PATH="$(go env GOROOT)/bin/go" \
./tools/fix_go_deps.sh --diff &> go-deps-diff.txt || true
echo "go deps diff:"
cat go-deps-diff.txt
- name: gazelle
run: |
# Invoke gazelle via bb fix for TypeScript support
cli/install.sh tags/5.0.21 # keep in sync with buildfix.sh
bb version
bb fix -mode diff &> gazelle-diff.txt || true
echo "gazelle diff:"
cat gazelle-diff.txt
- name: clang-format
run: |
git ls-files | grep '\.proto$' | xargs --no-run-if-empty -d'\n' clang-format -i --style=Google --dry-run &> clang-format-errors.txt || true
clang-format --version
echo "clang format errors:"
cat clang-format-errors.txt
- name: prettier
# NOTE: Only run prettier on files that differ from master, since
# prettier can be slow.
run: |
yarn global add [email protected]
# TODO(https://github.com/tj-actions/changed-files/issues/809):
# Use changed-files instead of git ls-files
# printf '%s\n' ${{ steps.changed-files.outputs.all_changed_files }}
git ls-files |
grep -P '(README|\.(js|jsx|ts|tsx|html|css|yaml|yml|json|md))$' |
( xargs --no-run-if-empty --delimiter='\n' "$(yarn global bin)/prettier" --check 1>/dev/null || true ) &> prettier-errors.txt
echo "prettier errors:"
cat prettier-errors.txt
- name: Check
run: |
echo "===== gofmt diff (fix with ./buildfix.sh) ====="
cat gofmt-diff.txt
echo "===== buildifier diff (fix with ./buildfix.sh) ====="
cat buildifier-diff.txt
echo "===== gazelle diff (fix with ./buildfix.sh --gazelle) ====="
cat gazelle-diff.txt
echo "===== go deps diff (fix with ./buildfix.sh --go_deps) ====="
cat go-deps-diff.txt
echo "===== clang-format errors (fix with ./buildfix.sh) ====="
cat clang-format-errors.txt
echo "===== prettier errors (fix with ./buildfix.sh) ====="
cat prettier-errors.txt
if [ -s gazelle-diff.txt ]; then exit 1; fi
if [ -s go-deps-diff.txt ]; then exit 1; fi
if [ -s gofmt-diff.txt ]; then exit 1; fi
if [ -s buildifier-diff.txt ]; then exit 1; fi
if [ -s clang-format-errors.txt ]; then exit 1; fi
if [ -s prettier-errors.txt ]; then exit 1; fi