Format #1653
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2020 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Format | |
on: | |
pull_request: | |
branches: | |
- main | |
- 'envoy-release/**' | |
- 'istio-release/**' | |
push: | |
branches: | |
- main | |
- 'envoy-release/**' | |
- 'istio-release/**' | |
schedule: | |
- cron: '0 0 * * *' | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
addlicense: | |
name: verify licenses | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: '^1.16' | |
- name: Install dependencies | |
run: | | |
go install github.com/google/addlicense@latest | |
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" | |
- name: Format (addlicense) | |
run: addlicense -ignore "bazel/cargo/*/remote/**" -check . | |
buildifier: | |
name: check format with buildifier | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: '^1.16' | |
- name: Install dependencies | |
run: | | |
go install github.com/bazelbuild/buildtools/buildifier@latest | |
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" | |
- name: Format (buildifier) | |
run: find . -name "WORKSPACE" -o -name "*BUILD*" -o -name "*.bzl" | xargs -n1 buildifier -mode=check | |
rules_rust: | |
name: check format with rules_rust | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Format (bazel query) | |
run: | | |
bazel query 'deps(//bazel/cargo/...)' | |
- name: Format (rules_rust) | |
run: | | |
bazel run //bazel/cargo/wasmsign:crates_vendor | |
bazel run //bazel/cargo/wasmtime:crates_vendor | |
git diff --exit-code | |
clang_format: | |
name: check format with clang-format | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies (Linux) | |
run: sudo apt update -y && sudo apt install -y clang-format-12 | |
- name: Format (clang-format) | |
run: | | |
find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-12 -i | |
git diff --exit-code | |
clang_tidy: | |
name: check format with clang-tidy | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies (Linux) | |
run: sudo apt update -y && sudo apt install -y clang-tidy-12 lld-12 && sudo ln -sf /usr/bin/lld-12 /usr/bin/lld | |
- name: Bazel cache | |
uses: PiotrSikora/[email protected] | |
with: | |
path: | | |
~/.cache/bazel | |
key: clang_tidy-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/dependencies.bzl', 'bazel/repositories.bzl', 'bazel/cargo/wasmsign/remote/crates.bzl') }} | |
- name: Bazel build | |
run: > | |
bazel build | |
--config clang-tidy | |
--define engine=multi | |
--copt=-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" | |
//... | |
- name: Skip Bazel cache update | |
if: ${{ github.ref != 'refs/heads/main' }} | |
run: echo "CACHE_SKIP_SAVE=true" >> $GITHUB_ENV | |
- name: Cleanup Bazel cache | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
export OUTPUT=$(${{ matrix.run_under }} bazel info output_base) | |
echo "===== BEFORE =====" | |
du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20 | |
# BoringSSL's test data (90 MiB). | |
rm -rf ${OUTPUT}/external/boringssl/crypto_test_data.cc | |
rm -rf ${OUTPUT}/external/boringssl/src/crypto/*/test/ | |
rm -rf ${OUTPUT}/external/boringssl/src/third_party/wycheproof_testvectors/ | |
# LLVM's tests (500 MiB). | |
rm -rf ${OUTPUT}/external/llvm*/test/ | |
# V8's tests (100 MiB). | |
if [ -d "${OUTPUT}/external/v8/test/torque" ]; then | |
mv ${OUTPUT}/external/v8/test/torque ${OUTPUT}/external/v8/test_torque | |
rm -rf ${OUTPUT}/external/v8/test/* | |
mv ${OUTPUT}/external/v8/test_torque ${OUTPUT}/external/v8/test/torque | |
fi | |
# Unnecessary CMake tools (65 MiB). | |
rm -rf ${OUTPUT}/external/cmake-*/bin/{ccmake,cmake-gui,cpack,ctest} | |
# Distfiles for Rust toolchains (350 MiB). | |
rm -rf ${OUTPUT}/external/rust_*/*.tar.gz | |
# Bazel's repository cache (650-800 MiB) and install base (155 MiB). | |
rm -rf ${OUTPUT}/../cache | |
rm -rf ${OUTPUT}/../install | |
echo "===== AFTER =====" | |
du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20 |