fix: Regenerate flatbuffers in a Docker container by default
parent
2934370426
commit
9cc5b1950a
|
@ -168,7 +168,7 @@ jobs:
|
|||
- rust_components # Regenerating flatbuffers uses rustfmt
|
||||
- run:
|
||||
name: Check Flatbuffers
|
||||
command: ./generated_types/check-flatbuffers.sh
|
||||
command: LOCAL=1 ./generated_types/check-flatbuffers.sh
|
||||
|
||||
# Compile a cargo "release" profile binary for branches that end in `/perf`
|
||||
#
|
||||
|
|
|
@ -24,45 +24,78 @@ FB_COMMIT="86401e078d0746d2381735415f8c2dfe849f3f52"
|
|||
# - Check in the changes to the generated code along with your changes to the `Cargo.lock` file and
|
||||
# this script.
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
pushd $DIR
|
||||
# By default, this script will run a Docker container that uses the same image we use in CI that
|
||||
# will have all the necessary dependencies. If you don't want to run Docker, run this script with
|
||||
# LOCAL=1.
|
||||
if [ -z ${LOCAL} ]; then
|
||||
echo "Running in Docker..."
|
||||
|
||||
echo "Building flatc from source ..."
|
||||
CI_IMAGE=quay.io/influxdb/rust:ci
|
||||
|
||||
FB_URL="https://github.com/google/flatbuffers"
|
||||
FB_DIR=".flatbuffers"
|
||||
FLATC="$FB_DIR/bazel-bin/flatc"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
pushd $DIR
|
||||
|
||||
if [ -z $(which bazel) ]; then
|
||||
echo "bazel is required to build flatc"
|
||||
exit 1
|
||||
fi
|
||||
DOCKER_IOX_DIR=/home/rust/influxdb_iox
|
||||
|
||||
echo "Bazel version: $(bazel version | head -1 | awk -F':' '{print $2}')"
|
||||
docker kill flatc || true
|
||||
docker rm flatc || true
|
||||
|
||||
if [ ! -e $FB_DIR ]; then
|
||||
echo "git clone $FB_URL ..."
|
||||
git clone -b master --no-tag $FB_URL $FB_DIR
|
||||
docker pull ${CI_IMAGE} || true
|
||||
|
||||
docker run \
|
||||
-it \
|
||||
--detach \
|
||||
--name=flatc \
|
||||
--volume ${DIR}/..:${DOCKER_IOX_DIR} \
|
||||
${CI_IMAGE}
|
||||
|
||||
docker exec -e LOCAL=1 flatc .${DOCKER_IOX_DIR}/generated_types/regenerate-flatbuffers.sh
|
||||
|
||||
docker kill flatc || true
|
||||
docker rm flatc || true
|
||||
else
|
||||
echo "git pull $FB_URL ..."
|
||||
git -C $FB_DIR pull --ff-only
|
||||
echo "Running locally..."
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
pushd $DIR
|
||||
|
||||
echo "Building flatc from source ..."
|
||||
|
||||
FB_URL="https://github.com/google/flatbuffers"
|
||||
FB_DIR=".flatbuffers"
|
||||
FLATC="$FB_DIR/bazel-bin/flatc"
|
||||
|
||||
if [ -z $(which bazel) ]; then
|
||||
echo "bazel is required to build flatc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Bazel version: $(bazel version | head -1 | awk -F':' '{print $2}')"
|
||||
|
||||
if [ ! -e $FB_DIR ]; then
|
||||
echo "git clone $FB_URL ..."
|
||||
git clone -b master --no-tag $FB_URL $FB_DIR
|
||||
else
|
||||
echo "git pull $FB_URL ..."
|
||||
git -C $FB_DIR pull --ff-only
|
||||
fi
|
||||
|
||||
echo "hard reset to $FB_COMMIT"
|
||||
git -C $FB_DIR reset --hard $FB_COMMIT
|
||||
|
||||
pushd $FB_DIR
|
||||
echo "run: bazel build :flatc ..."
|
||||
bazel build :flatc
|
||||
popd
|
||||
|
||||
RUST_DIR="$DIR/src"
|
||||
while read -r FBS_FILE; do
|
||||
echo "Compiling ${FBS_FILE}"
|
||||
$FLATC --rust -o $RUST_DIR $FBS_FILE
|
||||
done < <(git ls-files $DIR/*.fbs)
|
||||
|
||||
cargo fmt
|
||||
popd
|
||||
|
||||
echo "DONE! Please run 'cargo test' and check in any changes."
|
||||
fi
|
||||
|
||||
echo "hard reset to $FB_COMMIT"
|
||||
git -C $FB_DIR reset --hard $FB_COMMIT
|
||||
|
||||
pushd $FB_DIR
|
||||
echo "run: bazel build :flatc ..."
|
||||
bazel build :flatc
|
||||
popd
|
||||
|
||||
RUST_DIR="$DIR/src"
|
||||
while read -r FBS_FILE; do
|
||||
echo "Compiling ${FBS_FILE}"
|
||||
$FLATC --rust -o $RUST_DIR $FBS_FILE
|
||||
done < <(git ls-files $DIR/*.fbs)
|
||||
|
||||
cargo fmt
|
||||
popd
|
||||
|
||||
echo "DONE! Please run 'cargo test' and check in any changes."
|
||||
|
|
Loading…
Reference in New Issue