diff --git a/.github/workflows/check_make_sizegen.yml b/.github/workflows/check_make_sizegen.yml new file mode 100644 index 00000000000..b8eef13acf4 --- /dev/null +++ b/.github/workflows/check_make_sizegen.yml @@ -0,0 +1,35 @@ +name: check_make_sizegen +on: [push, pull_request] +jobs: + + build: + name: Check Make Sizegen + runs-on: ubuntu-latest + steps: + + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.15 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + sudo apt-get update + sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget + sudo service mysql stop + sudo service etcd stop + sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + go mod download + + - name: Run make minimaltools + run: | + make minimaltools + + - name: check_make_sizegen + run: | + tools/check_make_sizegen.sh + diff --git a/go/vt/sqlparser/cached_size.go b/go/vt/sqlparser/cached_size.go index ad4cbe32662..30b1b680026 100644 --- a/go/vt/sqlparser/cached_size.go +++ b/go/vt/sqlparser/cached_size.go @@ -553,7 +553,7 @@ func (cached *CreateTable) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(57) + size += int64(65) } // field Table vitess.io/vitess/go/vt/sqlparser.TableName size += cached.Table.CachedSize(false) @@ -666,7 +666,7 @@ func (cached *DropTable) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(25) + size += int64(33) } // field FromTables vitess.io/vitess/go/vt/sqlparser.TableNames { diff --git a/go/vt/vtgate/engine/cached_size.go b/go/vt/vtgate/engine/cached_size.go index 136ce2b84f1..2278127a81c 100644 --- a/go/vt/vtgate/engine/cached_size.go +++ b/go/vt/vtgate/engine/cached_size.go @@ -78,7 +78,7 @@ func (cached *DDL) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(56) + size += int64(57) } // field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace size += cached.Keyspace.CachedSize(true) diff --git a/tools/check_make_sizegen.sh b/tools/check_make_sizegen.sh new file mode 100755 index 00000000000..edcff23a5e3 --- /dev/null +++ b/tools/check_make_sizegen.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Validate that the current version of the generated cache_size files match the output +# generated by sizegen. +# +# This is used in Travis to verify that the currently committed version was +# generated with the proper cache_size files. + +source build.env + +TMP="/tmp/cached_size.$$.go" +ALL_FILES=$(find . -name "cached_size.go") + +set +e + +for SRC in $ALL_FILES +do + TMP="/tmp/"$(echo "$SRC" | sed 's/\//_/g' | sed "s/cached_size.go/cached_size_$$.go/g") + mv "$SRC" "$TMP" +done + +make sizegen + +STATUS=0 + +for SRC in $ALL_FILES +do + TMP="/tmp/"$(echo "$SRC" | sed 's/\//_/g' | sed "s/cached_size.go/cached_size_$$.go/g") + + if [ ! -f "$SRC" ]; then + mv "$TMP" "$SRC" + continue + fi + + if ! diff -q "$SRC" "$TMP" > /dev/null ; then + echo "ERROR: Regenerated file for $SRC does not match the current version:" + diff -u "$SRC" "$TMP" + + echo + echo "Please re-run 'make sizegen' to generate." + STATUS=1 + fi + mv "$TMP" "$SRC" +done + +exit $STATUS +