From 01093cd9486f0c19bbf304f8b4e7b50b07f25235 Mon Sep 17 00:00:00 2001 From: Mathieu Baudet Date: Tue, 16 Feb 2021 14:26:21 -0800 Subject: [PATCH] [ci] setup codegen requirements --- .github/actions/build-setup/action.yml | 3 +- docker/ci/github/Dockerfile | 11 +++-- scripts/dev_setup.sh | 67 ++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 7 deletions(-) diff --git a/.github/actions/build-setup/action.yml b/.github/actions/build-setup/action.yml index 7f249ff4e6..59f66d4dfd 100644 --- a/.github/actions/build-setup/action.yml +++ b/.github/actions/build-setup/action.yml @@ -48,9 +48,10 @@ runs: echo 'BOOGIE_EXE='${HOME}/.dotnet/tools/boogie | tee -a $GITHUB_ENV echo "$HOME/bin" | tee -a $GITHUB_PATH echo "/opt/cargo/bin" | tee -a $GITHUB_PATH + echo '/usr/lib/golang/bin' | tee -a $GITHUB_PATH - name: install common dependencies (should be ~ 10 seconds in a linux build, on mac it's a beast.) shell: bash - run: scripts/dev_setup.sh -t -o -b -p -y + run: scripts/dev_setup.sh -t -o -b -p -y -s - id: rust-environment shell: bash run: | diff --git a/docker/ci/github/Dockerfile b/docker/ci/github/Dockerfile index f4ff449ce9..3d1a7a0889 100644 --- a/docker/ci/github/Dockerfile +++ b/docker/ci/github/Dockerfile @@ -14,11 +14,11 @@ ENV CARGO_HOME "/opt/cargo/" RUN mkdir -p /github/home \ && mkdir -p /opt/cargo/ \ && mkdir -p /opt/git/ \ - && /diem/scripts/dev_setup.sh -t -o -b -p -y \ + && /diem/scripts/dev_setup.sh -t -o -b -p -y -s\ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -ENV PATH "/opt/cargo/bin:/github/home/bin/:$PATH" +ENV PATH "/opt/cargo/bin:/usr/lib/golang/bin:/github/home/bin:$PATH" ENV DOTNET_ROOT "/github/home/.dotnet" ENV Z3_EXE "/github/home/bin/z3" ENV BOOGIE_EXE "/github/home/.dotnet/tools/boogie" @@ -39,12 +39,17 @@ RUN [ -x "$(command -v shellcheck)" ] \ && [ -x "$(command -v helm)" ] \ && [ -x "$(command -v aws)" ] \ && [ -x "$(command -v z3)" ] \ + && [ -x "$(command -v javac)" ] \ + && [ -x "$(command -v clang)" ] \ + && [ -x "$(command -v python3)" ] \ + && [ -x "$(command -v go)" ] \ + && [ -x "$(command -v npm)" ] \ && [ -x "$(command -v "$HOME/.dotnet/tools/boogie")" ] \ && [ -x "$(xargs rustup which cargo --toolchain < /diem/rust-toolchain )" ] \ && [ -x "$(xargs rustup which cargo --toolchain < /diem/cargo-toolchain)" ] # should be a no-op # sccache builds fine, but is not executable ??? in alpine, ends up being recompiled. Wierd. -RUN /diem/scripts/dev_setup.sh -b -p +RUN /diem/scripts/dev_setup.sh -b -p -s FROM setup_ci as build_environment diff --git a/scripts/dev_setup.sh b/scripts/dev_setup.sh index dcb23c153b..e3a00ffe8b 100755 --- a/scripts/dev_setup.sh +++ b/scripts/dev_setup.sh @@ -36,6 +36,7 @@ function usage { echo "-t install build tools" echo "-o install operations tooling as well: helm, terraform, hadolint, yamllint, vault, docker, kubectl, python3" echo "-y installs or updates Move prover tools: z3, cvc4, dotnet, boogie" + echo "-s installs or updates requirements to test code-generation for Move SDKs" echo "-v verbose mode" echo "If no toolchain component is selected with -t, -o, -y, or -p, the behavior is as if -t had been provided." echo "This command must be called from the root folder of the Diem project." @@ -65,6 +66,9 @@ function update_path_and_profile { add_to_profile "export CVC4_EXE=$HOME/bin/cvc4" add_to_profile "export BOOGIE_EXE=$HOME/.dotnet/tools/boogie" fi + if [[ "$INSTALL_CODEGEN" == "true" ]] && [[ "$PACKAGE_MANAGER" == "apt-get" ]]; then + add_to_profile "export PATH=\$PATH:/usr/lib/golang/bin:\$GOBIN" + fi } function install_build_essentials { @@ -428,6 +432,30 @@ function install_cvc4 { rm -rf "$TMPFILE" } +function install_golang { + if [[ "$PACKAGE_MANAGER" == "apt-get" ]]; then + if ! grep -q 'buster-backports main' /etc/apt/sources.list; then + ( + echo "deb http://http.us.debian.org/debian/ buster-backports main" + echo "deb-src http://http.us.debian.org/debian/ buster-backports main" + ) | "${PRE_COMMAND[@]}" tee -a /etc/apt/sources.list + "${PRE_COMMAND[@]}" apt-get update + fi + "${PRE_COMMAND[@]}" apt-get install -y golang-1.14-go/buster-backports + "${PRE_COMMAND[@]}" ln -sf /usr/lib/go-1.14 /usr/lib/golang + else + install_pkg golang "$PACKAGE_MANAGER" + fi +} + +function install_java { + if [[ "$PACKAGE_MANAGER" == "apt-get" ]]; then + "${PRE_COMMAND[@]}" apt-get install -y default-jdk + else + install_pkg java "$PACKAGE_MANAGER" + fi +} + function welcome_message { cat <