From 88868493151df3d78cd7153b4a2ecf764619b073 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 25 Apr 2019 12:15:41 +0200 Subject: [PATCH] lib: check that nongoogle.bzl doesn't grow new dependencies Change-Id: Ie5fbd18de68fca13f954ef4d05ea7acc7d9cfea9 --- lib/BUILD | 6 ++++++ lib/nongoogle_test.sh | 17 +++++++++++++++++ tools/BUILD | 2 ++ tools/nongoogle.bzl | 6 ++++-- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100755 lib/nongoogle_test.sh diff --git a/lib/BUILD b/lib/BUILD index 95ca4db461..b3c149a72b 100644 --- a/lib/BUILD +++ b/lib/BUILD @@ -504,3 +504,9 @@ java_library( visibility = ["//visibility:public"], exports = ["@postgresql//jar"], ) + +sh_test( + name = "nongoogle_test", + srcs = ["nongoogle_test.sh"], + data = ["//tools:nongoogle.bzl"], +) diff --git a/lib/nongoogle_test.sh b/lib/nongoogle_test.sh new file mode 100755 index 0000000000..23b40add7e --- /dev/null +++ b/lib/nongoogle_test.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# This test ensures that new dependencies in nongoogle.bzl go through LC review. + +set -eux + +bzl=$(pwd)/tools/nongoogle.bzl + +TMP=$(mktemp -d || mktemp -d -t /tmp/tmp.XXXXXX) + +grep 'name = "[^"]*"' ${bzl} | sed 's|^[^"]*"||g;s|".*$||g' | sort > $TMP/names + +cat << EOF > $TMP/want +tukaani-xz +EOF + +diff -u $TMP/names $TMP/want diff --git a/tools/BUILD b/tools/BUILD index aefb867277..d4ab2a8c02 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -4,6 +4,8 @@ load( "default_java_toolchain", ) +exports_files(["nongoogle.bzl"]) + py_binary( name = "merge_jars", srcs = ["merge_jars.py"], diff --git a/tools/nongoogle.bzl b/tools/nongoogle.bzl index 047469e292..2e84717abb 100644 --- a/tools/nongoogle.bzl +++ b/tools/nongoogle.bzl @@ -1,9 +1,11 @@ -load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "maven_jar") +load("//tools/bzl:maven_jar.bzl", "maven_jar") def declare_nongoogle_deps(): """loads dependencies that are not used at Google. - These are exempt from library compliance review. + Changes to versions are exempt from library compliance review. New + dependencies must pass through library compliance review. This is + enforced by //lib:nongoogle_test. """ # Transitive dependency of commons-compress