From 288b9985c608613d149a563c247aeec485ae81e0 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Mon, 6 Jan 2025 18:45:50 -0800 Subject: [PATCH] Run bant as build-cleaner from our bazel_dep() --- .github/bin/make-compilation-db.sh | 4 +-- .github/bin/run-build-cleaner.sh | 37 +++++++++++++++++++++++++++ .github/workflows/verible-ci.yml | 40 ++++-------------------------- 3 files changed, 44 insertions(+), 37 deletions(-) create mode 100755 .github/bin/run-build-cleaner.sh diff --git a/.github/bin/make-compilation-db.sh b/.github/bin/make-compilation-db.sh index 75694d893..de58da3bb 100755 --- a/.github/bin/make-compilation-db.sh +++ b/.github/bin/make-compilation-db.sh @@ -20,16 +20,16 @@ set -e BAZEL=${BAZEL:-bazel} BANT=${BANT:-needs-to-be-compiled-locally} -BAZEL_OPTS="-c opt --noshow_progress" if [ "${BANT}" = "needs-to-be-compiled-locally" ]; then # Bant not given, compile from bzlmod dep. We need to do that before # we run other bazel rules below as we change the cxxopt flags. Remember # the full realpath of the resulting binary to be immune to symbolic-link # switcharoo by bazel. - ${BAZEL} build ${BAZEL_OPTS} --cxxopt=-std=c++20 @bant//bant:bant + ${BAZEL} build -c opt --cxxopt=-std=c++20 @bant//bant:bant >/dev/null 2>&1 BANT=$(realpath bazel-bin/external/bant*/bant/bant) fi +BAZEL_OPTS="-c opt --noshow_progress" # Bazel-build all targets that generate files, so that they can be # seen in dependency analysis. ${BAZEL} build ${BAZEL_OPTS} $(${BANT} list-targets | \ diff --git a/.github/bin/run-build-cleaner.sh b/.github/bin/run-build-cleaner.sh new file mode 100755 index 000000000..ff5c347d5 --- /dev/null +++ b/.github/bin/run-build-cleaner.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Copyright 2024 The Verible Authors. +# +# 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. + +set -u +set -e + +# Which bazel and bant to use can be chosen by environment variables +BAZEL=${BAZEL:-bazel} +BANT=${BANT:-needs-to-be-compiled-locally} + +if [ "${BANT}" = "needs-to-be-compiled-locally" ]; then + # Bant not given, compile from bzlmod dep. + ${BAZEL} build -c opt --cxxopt=-std=c++20 @bant//bant:bant >/dev/null 2>&1 + BANT=$(realpath bazel-bin/external/bant*/bant/bant) +fi + +DWYU_OUT="${TMPDIR:-/tmp}/dwyu.out" + +if "${BANT}" -q dwyu ... ; then + echo "Dependencies ok" +else + echo + echo "^ Please run buildozer commands to fix the dependencies and amend PR" + exit 1 +fi diff --git a/.github/workflows/verible-ci.yml b/.github/workflows/verible-ci.yml index bed08ba83..3ef8d4aa7 100644 --- a/.github/workflows/verible-ci.yml +++ b/.github/workflows/verible-ci.yml @@ -25,7 +25,7 @@ env: jobs: - VerifyFormatting: + CheckFormatAndBuildClean: runs-on: ubuntu-24.04 steps: @@ -41,7 +41,11 @@ jobs: - name: Run formatting style check run: | + echo "--- check formatting ---" CLANG_FORMAT=clang-format-17 ./.github/bin/run-format.sh + echo "--- check build dependencies ---" + ./.github/bin/run-build-cleaner.sh + echo "--- check potential problems ---" ./.github/bin/check-potential-problems.sh - name: 📤 Upload performance graphs @@ -117,40 +121,6 @@ jobs: name: "diag" path: "**/plot_*.svg" - RunBantBuildCleaner: - # Running http://bant.build/ to check all dependencies in BUILD files. - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Get Bant - run: | - # TODO: provide this as action where we simply say with version=... - VERSION="v0.1.9" - STATIC_VERSION="bant-${VERSION}-linux-static-x86_64" - wget "https://github.com/hzeller/bant/releases/download/${VERSION}/${STATIC_VERSION}.tar.gz" - tar xvzf "${STATIC_VERSION}.tar.gz" - mkdir -p bin - ln -sf ../"${STATIC_VERSION}/bin/bant" bin/ - bin/bant -V - - - name: Build Project genrules - run: | - # Fetch all dependencies and run genrules for bant to see every file - # that makes it into the compile. Use bant itself to find genrules. - bazel build $(bin/bant -q genrule-outputs | awk '{print $2}') \ - //verible/common/analysis:command-file-lexer \ - //verible/verilog/parser:verilog-lex \ - //verible/verilog/parser:verilog-y \ - //verible/verilog/parser:verilog-y-final - - - name: Run bant build-cleaner - run: | - bin/bant dwyu ... - Check: container: ubuntu:jammy runs-on: [self-hosted, Linux, X64, gcp-custom-runners]