Ensure assets are rebuilt in presubmit

This commit is contained in:
Tim St. Clair 2016-09-19 14:40:25 -07:00
parent a14b6c7a6a
commit aecc17d08b
No known key found for this signature in database
GPG Key ID: 434D16BCEF479EAB
3 changed files with 22 additions and 6 deletions

View File

@ -31,11 +31,14 @@ vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
build:
build: assets
@echo ">> building binaries"
@./build/assets.sh
@./build/build.sh
assets:
@echo ">> building assets"
@./build/assets.sh
release:
@echo ">> building release binaries"
@RELEASE=true ./build/build.sh

View File

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
GIT_ROOT=$(dirname "${BASH_SOURCE}")/..
ASSETS_INPUT_DIRS="$GIT_ROOT/pages/assets/js/... $GIT_ROOT/pages/assets/styles/..."
@ -24,6 +26,8 @@ TEMPLATES_INPUT_DIRS="$GIT_ROOT/pages/assets/html/..."
TEMPLATES_OUTPUT_PATH="$GIT_ROOT/pages/templates.go"
TEMPLATES_PACKAGE="pages"
FORCE="${FORCE:-}" # Force assets to be rebuilt if FORCE=true
go get -u github.com/jteeuwen/go-bindata/...
build_asset () {
@ -42,17 +46,17 @@ build_asset () {
}
for f in $GIT_ROOT/pages/assets/js/* $GIT_ROOT/pages/assets/styles/*; do
if [ "$f" -nt $ASSETS_OUTPUT_PATH -o ! -e $ASSETS_OUTPUT_PATH ]; then
build_asset "$ASSETS_PACKAGE" "$ASSETS_OUTPUT_PATH" "$ASSETS_INPUT_DIRS"
if [ "$FORCE" == "true" ] || [ "$f" -nt $ASSETS_OUTPUT_PATH -o ! -e $ASSETS_OUTPUT_PATH ]; then
build_asset "$ASSETS_PACKAGE" "$ASSETS_OUTPUT_PATH" "$ASSETS_INPUT_DIRS"
break;
fi
done
for f in $GIT_ROOT/pages/assets/html/*; do
if [ "$f" -nt $TEMPLATES_OUTPUT_PATH -o ! -e $TEMPLATES_OUTPUT_PATH ]; then
if [ "$FORCE" == "true" ] || [ "$f" -nt $TEMPLATES_OUTPUT_PATH -o ! -e $TEMPLATES_OUTPUT_PATH ]; then
build_asset "$TEMPLATES_PACKAGE" "$TEMPLATES_OUTPUT_PATH" "$TEMPLATES_INPUT_DIRS"
break;
fi
done
exit 0
exit 0

View File

@ -22,6 +22,15 @@ BUILDER=${BUILDER:-false} # Whether this is running a PR builder job.
export GO_FLAGS="-race"
export GORACE="halt_on_error=1"
# Check whether assets need to be rebuilt.
FORCE=true build/assets.sh
if [[ ! -z "$(git diff --name-only pages)" ]]; then
echo "Found changes to UI assets:"
git diff --name-only pages
echo "Run: `make assets FORCE=true`"
exit 1
fi
make
go build -tags test github.com/google/cadvisor/integration/runner