Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

add presubmit_build.sh that passes a flag to swiftpm if it is a stock toolchain #723

Merged
merged 2 commits into from
Dec 18, 2020
Merged
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
43 changes: 43 additions & 0 deletions docker/presubmit_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -exuo pipefail

sudo apt-get install -y docker.io

# Sets 'swift_tf_url' to the public url corresponding to
# 'swift_tf_bigstore_gfile', if it exists.
if [[ ! -z ${swift_tf_bigstore_gfile+x} ]]; then
export swift_tf_url="${swift_tf_bigstore_gfile/\/bigstore/https://storage.googleapis.com}"
case "$swift_tf_url" in
*stock*) STOCK_TOOLCHAIN=YES ;;
*) ;;
esac
fi

# Help debug the job's disk space.
df -h

# Move docker images into /tmpfs, where there is more space.
sudo /etc/init.d/docker stop
sudo mv /var/lib/docker /tmpfs/
sudo ln -s /tmpfs/docker /var/lib/docker
sudo /etc/init.d/docker start

# Help debug the job's disk space.
df -h

cd github/swift-models
sudo -E docker build -t built-img -f docker/Dockerfile --build-arg swift_tf_url .

# SwiftPM-based build.
docker run built-img /bin/bash -c "
swift build ${STOCK_TOOLCHAIN:+"-Xswiftc -D -Xswiftc TENSORFLOW_USE_STANDARD_TOOLCHAIN"} ;
swift test ${STOCK_TOOLCHAIN:+"-Xswiftc -D -Xswiftc TENSORFLOW_USE_STANDARD_TOOLCHAIN"} ;
"

# CMake-based build.
sudo docker run built-img /bin/bash -c "
set -e;
cmake -B /BinaryCache/tensorflow-swift-models -D CMAKE_BUILD_TYPE=Release -D CMAKE_Swift_COMPILER=/swift-tensorflow-toolchain/usr/bin/swiftc -G Ninja -S /swift-models;
cmake --build /BinaryCache/tensorflow-swift-models --verbose;
"