Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow to check make sizegen #7535

Merged
merged 3 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/check_make_sizegen.yml
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions go/vt/sqlparser/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/vt/vtgate/engine/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions tools/check_make_sizegen.sh
Original file line number Diff line number Diff line change
@@ -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