Skip to content

Commit d95dd62

Browse files
committed
review: split format jobs and enable cache for clang-tidy.
Signed-off-by: Piotr Sikora <[email protected]>
1 parent eeb424b commit d95dd62

File tree

1 file changed

+93
-15
lines changed

1 file changed

+93
-15
lines changed

.github/workflows/cpp.yml

Lines changed: 93 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,120 @@ on:
3333

3434
jobs:
3535

36-
format:
36+
addlicense:
37+
name: verify liceses
38+
3739
runs-on: ubuntu-20.04
3840

3941
steps:
4042
- uses: actions/checkout@v2
43+
4144
- uses: actions/setup-go@v2
4245
with:
4346
go-version: '^1.16'
4447

45-
- name: Format (addlicense)
48+
- name: Install dependencies (Linux)
4649
run: |
4750
go install github.com/google/addlicense@latest
48-
export PATH=$PATH:$(go env GOPATH)/bin
49-
addlicense -check .
51+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
5052
51-
- name: Format (buildifier)
53+
- name: Format (addlicense)
54+
run: addlicense -check .
55+
56+
buildifier:
57+
name: check format with buildifier
58+
59+
runs-on: ubuntu-20.04
60+
61+
steps:
62+
- uses: actions/checkout@v2
63+
64+
- uses: actions/setup-go@v2
65+
with:
66+
go-version: '^1.16'
67+
68+
- name: Install dependencies (Linux)
5269
run: |
5370
go install github.com/bazelbuild/buildtools/buildifier@latest
54-
export PATH=$PATH:$(go env GOPATH)/bin
55-
find . -name "WORKSPACE" -o -name "*BUILD*" -o -name "*.bzl" | xargs -n1 buildifier -mode=check
71+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
72+
73+
- name: Format (buildifier)
74+
run: find . -name "WORKSPACE" -o -name "*BUILD*" -o -name "*.bzl" | xargs -n1 buildifier -mode=check
75+
76+
clang_format:
77+
name: check format with clang-format
78+
79+
runs-on: ubuntu-20.04
80+
81+
steps:
82+
- uses: actions/checkout@v2
83+
84+
- name: Install dependencies (Linux)
85+
run: sudo apt-get install -y clang-format-12
5686

5787
- name: Format (clang-format)
5888
run: |
59-
sudo apt-get install -y clang-format-12
6089
find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-12 -i
6190
git diff --exit-code
6291
63-
- name: Format (clang-tidy)
64-
run: |
65-
sudo apt-get install -y clang-tidy-12
66-
bazel build \
67-
--config clang-tidy \
68-
--define engine=multi \
69-
--copt=-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" \
92+
clang_tidy:
93+
name: check format with clang-tidy
94+
95+
runs-on: ubuntu-20.04
96+
97+
steps:
98+
- uses: actions/checkout@v2
99+
100+
- name: Install dependencies (Linux)
101+
run: sudo apt-get install -y clang-tidy-12
102+
103+
- name: Bazel cache
104+
uses: PiotrSikora/[email protected]
105+
with:
106+
path: |
107+
~/.cache/bazel
108+
key: clang_tidy-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/dependencies.bzl', 'bazel/repositories.bzl', 'bazel/cargo/wasmsign/crates.bzl') }}
109+
110+
- name: Bazel build
111+
run: >
112+
bazel build
113+
--config clang-tidy
114+
--define engine=multi
115+
--copt=-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\"
70116
//...
71117
118+
- name: Skip Bazel cache update
119+
if: ${{ github.ref != 'refs/heads/master' }}
120+
run: echo "CACHE_SKIP_SAVE=true" >> $GITHUB_ENV
121+
122+
- name: Cleanup Bazel cache
123+
if: ${{ github.ref == 'refs/heads/master' }}
124+
run: |
125+
export OUTPUT=$(${{ matrix.run_under }} bazel info output_base)
126+
echo "===== BEFORE ====="
127+
du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20
128+
# BoringSSL's test data (90 MiB).
129+
rm -rf ${OUTPUT}/external/boringssl/crypto_test_data.cc
130+
rm -rf ${OUTPUT}/external/boringssl/src/crypto/*/test/
131+
rm -rf ${OUTPUT}/external/boringssl/src/third_party/wycheproof_testvectors/
132+
# LLVM's tests (500 MiB).
133+
rm -rf ${OUTPUT}/external/llvm*/test/
134+
# V8's tests (100 MiB).
135+
if [ -d "${OUTPUT}/external/v8/test/torque" ]; then
136+
mv ${OUTPUT}/external/v8/test/torque ${OUTPUT}/external/v8/test_torque
137+
rm -rf ${OUTPUT}/external/v8/test/*
138+
mv ${OUTPUT}/external/v8/test_torque ${OUTPUT}/external/v8/test/torque
139+
fi
140+
# Unnecessary CMake tools (65 MiB).
141+
rm -rf ${OUTPUT}/external/cmake-*/bin/{ccmake,cmake-gui,cpack,ctest}
142+
# Distfiles for Rust toolchains (350 MiB).
143+
rm -rf ${OUTPUT}/external/rust_*/*.tar.gz
144+
# Bazel's repository cache (650-800 MiB) and install base (155 MiB).
145+
rm -rf ${OUTPUT}/../cache
146+
rm -rf ${OUTPUT}/../install
147+
echo "===== AFTER ====="
148+
du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20
149+
72150
test_data:
73151
name: build test data
74152

0 commit comments

Comments
 (0)