github.com/prysmaticlabs/prysm@v1.4.4/scripts/check_visibility.sh (about)

     1  #!/bin/bash
     2  
     3  # Continous Integration script to check that BUILD.bazel files have the correct
     4  # visibility.
     5  
     6  # Protected packages are:
     7  #   //beacon-chain/...
     8  #   //validator/...
     9  
    10  # Duplicate redirect 5 to stdout so that it can be captured, but still printed
    11  # nicely.
    12  exec 5>&1
    13  
    14  # Run gazelle while piping a copy of the output to stdout via 5.
    15  changes=$(
    16  bazel --batch --bazelrc=.buildkite-bazelrc query 'visible(//... except (//beacon-chain/... union //validator/...), (//beacon-chain/... union //validator/...)) except attr("tags", "manual", //...)' | tee >(cat - >&5)
    17  )
    18  
    19  # If the captured stdout is not empty then targets are exposed!
    20  if [ -z "$changes" ]
    21  then
    22    echo "OK: Visibility is good."
    23    exit 0
    24  else
    25    echo "FAIL: The above targets belong to protected packages and the targets \
    26  are visible outside of their package!"
    27    echo "Please reduce the target visibility."
    28    exit 1
    29  fi