Last active
May 29, 2019 18:55
-
-
Save laser/6c42062e4313f2002326b6f731958e29 to your computer and use it in GitHub Desktop.
integrate rust-fil-proofs and go-filecoin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
expected_circle_config_sha256sum="2ea6a7c8f63088b107b6346685866629abdf165f0b457f8856880ea2dcfc63b1" | |
integration_branch=laser/test-integrations-$(date +%s) | |
go_filecoin_branch=master | |
go_filecoin_url=git@github.com:filecoin-project/go-filecoin.git | |
rust_fil_proofs_branch=master | |
rust_fil_proofs_url=git@github.com:filecoin-project/rust-fil-proofs.git | |
bls_signatures_branch=master | |
bls_signatures_url=git@github.com:filecoin-project/bls-signatures.git | |
working_dir=$(mktemp -d $(mktemp -d /tmp/XXXXXX)/XXXXXX) | |
cd $working_dir | |
echo "working directory set to $working_dir" | |
# select go-filecoin repo URL | |
# | |
read -p "Enter go-filecoin URL [${go_filecoin_url}]: " url_x | |
if [[ $url_x = git* ]] | |
then | |
go_filecoin_url=$url_x | |
elif [[ $url_x = http* ]] | |
then | |
go_filecoin_url=$url_x | |
fi | |
# select appropriate branch | |
# | |
read -p "Enter go-filecoin branch [${go_filecoin_branch}]: " branch_x | |
if [ ! -z "$branch_x" ] | |
then | |
go_filecoin_branch=$branch_x | |
fi | |
# select rust-fil-proofs repo URL | |
# | |
read -p "Enter rust-fil-proofs URL [${rust_fil_proofs_url}]: " url_x | |
if [[ $url_x = git* ]] | |
then | |
rust_fil_proofs_url=$url_x | |
elif [[ $url_x = http* ]] | |
then | |
rust_fil_proofs_url=$url_x | |
fi | |
# select appropriate rust-fil-proofs branch | |
# | |
read -p "Enter rust-fil-proofs branch [${rust_fil_proofs_branch}]: " branch_x | |
if [ ! -z "$branch_x" ] | |
then | |
rust_fil_proofs_branch=$branch_x | |
fi | |
# select bls-signatures repo URL | |
# | |
read -p "Enter bls-signatures URL [${bls_signatures_url}]: " url_x | |
if [[ $url_x = git* ]] | |
then | |
bls_signatures_url=$url_x | |
elif [[ $url_x = http* ]] | |
then | |
bls_signatures_url=$url_x | |
fi | |
# select appropriate bls-signatures branch | |
# | |
read -p "Enter bls-signatures branch [${bls_signatures_branch}]: " branch_x | |
if [ ! -z "$branch_x" ] | |
then | |
bls_signatures_branch=$branch_x | |
fi | |
# clone, create integration branch, and change working directory | |
# | |
git clone $go_filecoin_url repo | |
cd repo | |
git checkout $go_filecoin_branch | |
git checkout -b $integration_branch | |
# verify that the config file hasn't changed out from underneath us | |
# | |
actual_circle_config_sha256sum=$(sha256sum .circleci/config.yml | awk '{ print $1 }') | |
if [ "$actual_circle_config_sha256sum" != "$expected_circle_config_sha256sum" ] | |
then | |
echo "actual ($actual_circle_config_sha256sum) and expected ($expected_circle_config_sha256sum) sha256sum differ for .circleci/config.yml" | |
echo "checksum was originally computed over file on master branch @ ed31296509c772379b5871c8ed998b89dbd888d8" | |
exit 1 | |
fi | |
# set rust-fil-proofs submodlue URL and branch | |
# | |
git config --file=.gitmodules submodule.proofs/rust-fil-proofs.url $rust_fil_proofs_url | |
git config --file=.gitmodules submodule.proofs/rust-fil-proofs.branch $rust_fil_proofs_branch | |
git submodule sync | |
git submodule update --init --remote proofs/rust-fil-proofs/ | |
# same thing for bls-signatures | |
# | |
git config --file=.gitmodules submodule.bls-signatures/bls-signatures.url $bls_signatures_url | |
git config --file=.gitmodules submodule.bls-signatures/bls-signatures.branch $bls_signatures_branch | |
git submodule sync | |
git submodule update --init --remote bls-signatures/bls-signatures | |
# update to remote across CircleCI and | |
# | |
grep -l -r -e 'git submodule update \-\-init' --include \*.sh -o --include \*.yml . \ | |
| xargs perl -i -pe 's/git submodule update \-\-init/git submodule update \-\-init \-\-remote/g' | |
# ensure that we always build from source | |
# | |
grep -l -r -e '-z \"\$FILECOIN_USE_PRECOMPILED_RUST_PROOFS\"' --include \*.sh $working_dir \ | |
| xargs perl -i -pe 's/-z \"\$FILECOIN_USE_PRECOMPILED_RUST_PROOFS\"/-z \"\"/g' | |
# more building from source | |
# | |
grep -l -r -e '-z \"\$FILECOIN_USE_PRECOMPILED_BLS_SIGNATURES\"' --include \*.sh $working_dir \ | |
| xargs perl -i -pe 's/-z \"\$FILECOIN_USE_PRECOMPILED_BLS_SIGNATURES\"/-z \"\"/g' | |
# modify the functional test target to run all the tests (except the unit tests) | |
# | |
cat .circleci/config.yml \ | |
| tr '\n' 'é' \ | |
| perl -pe 's/(test_all)(.*)(functional_test_linux\:é)(.*)(functional_test_linuxé \<\<\: \*master_filter)/$1$2functional_test_linux\:é sector_builder_tests: trueé$4$5/g' \ | |
| tr 'é' '\n' \ | |
> .circleci/config.yml.new \ | |
&& mv .circleci/config.yml.new .circleci/config.yml | |
# commit changes | |
# | |
read -p "Enter integration message [none]: " integration_msg | |
sha_x=$(git rev-parse HEAD | cut -c1-8) | |
sha_y=$(git submodule | grep rust | awk '{ print $1 }' | cut -c1-8) | |
sha_z=$(git submodule | grep bls | awk '{ print $1 }' | cut -c1-8) | |
git commit -am "integrate: go-filecoin=${sha_x} rust-fil-proofs=${sha_y} bls-signatures=${sha_z} ($integration_msg)" | |
# prompt user to publish to integration branch | |
# | |
while true; do | |
read -p "Do you wish to push these changes to branch ${integration_branch} (y/n)? " yn | |
case $yn in | |
[Yy]* ) echo ""; git push origin ${integration_branch}; echo ""; break;; | |
[Nn]* ) exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
echo "Done." | |
echo "" | |
echo "To view your build, go here: https://circleci.com/gh/filecoin-project/go-filecoin/tree/$(echo "${integration_branch}" | sed -e 's/\//%2F/g')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment