From 9f2f5f8bfb9d1240af5f368283f62a26d5121f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 30 May 2018 17:21:21 +0200 Subject: [PATCH 1/7] Build TFW for framework developers and reorder building process --- hack/bootstrap_tfw_dev.sh | 16 ++++++++-------- hack/oneline_install.sh | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hack/bootstrap_tfw_dev.sh b/hack/bootstrap_tfw_dev.sh index e362feb..e1bd99a 100755 --- a/hack/bootstrap_tfw_dev.sh +++ b/hack/bootstrap_tfw_dev.sh @@ -27,11 +27,11 @@ run() check_dependencies clone_repos_ask_ssh_or_https + TAG="$(fetch_latest_tag)" + TAG=$TAG pin_latest_baseimage + TAG=$TAG build_latest_baseimage install_frontend_deps if [ "$TFWDEV" == "0" ]; then - LATESTTAG="$(fetch_latest_tag)" - LATESTTAG=$LATESTTAG pin_latest_baseimage - LATESTTAG=$LATESTTAG build_latest_baseimage cleanup_repos merge_repos fi @@ -123,18 +123,18 @@ fetch_latest_tag() pin_latest_baseimage() { echo -n "Pinning latest TFW baseimage version... " - echo -n "which is ${LATESTTAG}... " - sed -i "1 s/.*/&:${LATESTTAG}/" "${TEST}/solvable/Dockerfile" + echo -n "which is ${TAG}... " + sed -i "1 s/.*/&:${TAG}/" "${TEST}/solvable/Dockerfile" echo "Done!" } build_latest_baseimage() { - echo -n "Building baseimage at ${LATESTTAG}... " + echo -n "Building baseimage at ${TAG}... " pushd "$BASEIMAGE" - spinned logged git checkout "$LATESTTAG" + spinned logged git checkout "$TAG" popd - TFWTAG=$LATESTTAG spinned logged ${TEST}/hack/tfw.sh buildtfw + TFWTAG=$TAG spinned logged ${TEST}/hack/tfw.sh buildtfw echo "Done!" } diff --git a/hack/oneline_install.sh b/hack/oneline_install.sh index 3ae957a..a8963e9 100644 --- a/hack/oneline_install.sh +++ b/hack/oneline_install.sh @@ -1 +1 @@ -URL=https://git.io/vxBfj SHA=e16ddb440c0097521739067dd21312eadcb3a008e6982aaa1a052fe5ed35b1bc bash -c 'cmd="$(curl -fsSL $URL)" && [ $(echo "$cmd" | sha256sum | cut -d " " -f1) == $SHA ] && echo "$cmd" | bash || echo Checksum mismatch!' +URL=https://git.io/vxBfj SHA=237d0cce945574208784a21fa6c6fbb4f479e5ce60b1518b1fcc921d675d2861 bash -c 'cmd="$(curl -fsSL $URL)" && [ $(echo "$cmd" | sha256sum | cut -d " " -f1) == $SHA ] && echo "$cmd" | bash || echo Checksum mismatch!' From 5ea5f5263019a217ebbd4535d0013bc11033224e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 30 May 2018 17:54:39 +0200 Subject: [PATCH 2/7] Implement optional BASEIMAGE_ONLY builds --- hack/bootstrap_tfw_dev.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hack/bootstrap_tfw_dev.sh b/hack/bootstrap_tfw_dev.sh index e1bd99a..a3ed56a 100755 --- a/hack/bootstrap_tfw_dev.sh +++ b/hack/bootstrap_tfw_dev.sh @@ -27,13 +27,18 @@ run() check_dependencies clone_repos_ask_ssh_or_https - TAG="$(fetch_latest_tag)" + TAG="${BASEIMAGE_ONLY:-$(fetch_latest_tag)}" TAG=$TAG pin_latest_baseimage TAG=$TAG build_latest_baseimage - install_frontend_deps - if [ "$TFWDEV" == "0" ]; then - cleanup_repos - merge_repos + + if [ -z "${BASEIMAGE_ONLY:-}" ]; then + install_frontend_deps + if [ "$TFWDEV" == "0" ]; then + cleanup_repos + merge_repos + fi + else + delete_repos fi echo @@ -43,7 +48,7 @@ run() handle_exit() { if [[ $? -ne 0 ]]; then - err_cleanup + delete_repos showlog fi cleanlog @@ -51,7 +56,7 @@ handle_exit() showlog() { echo && echo "Error! Showing logs:" && cat $LOGFILE; } cleanlog() { rm $LOGFILE; } -err_cleanup() { cd "$BASEDIR" && rm -rf "$BASEIMAGE" "$FRONTEND" "$TEST"; } +delete_repos() { pushd "$BASEDIR" && rm -rf "$BASEIMAGE" "$FRONTEND" "$TEST" && popd; } check_dependencies() { @@ -122,7 +127,7 @@ fetch_latest_tag() pin_latest_baseimage() { - echo -n "Pinning latest TFW baseimage version... " + echo -n "Pinning TFW baseimage version... " echo -n "which is ${TAG}... " sed -i "1 s/.*/&:${TAG}/" "${TEST}/solvable/Dockerfile" echo "Done!" From 81a930470a1368be646b554cb1734e2661540ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 8 Jun 2018 11:40:22 +0200 Subject: [PATCH 3/7] Improve BASEIMAGE_ONLY flow --- hack/bootstrap_tfw_dev.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/hack/bootstrap_tfw_dev.sh b/hack/bootstrap_tfw_dev.sh index a3ed56a..952fd59 100755 --- a/hack/bootstrap_tfw_dev.sh +++ b/hack/bootstrap_tfw_dev.sh @@ -10,11 +10,14 @@ popd() { command popd "$@" > /dev/null; } TFWDEV="${TFWDEV:-0}" HTTPS_REMOTES="${HTTPS_REMOTES:-}" + TFW_POSTFIX=tutorial-framework BASEDIR="$(pwd)" BASEIMAGE=baseimage-${TFW_POSTFIX} TEST=test-${TFW_POSTFIX} FRONTEND=frontend-${TFW_POSTFIX} +BASEIMAGE_NAME="${BASEIMAGE_NAME:-eu.gcr.io/avatao-challengestore/tutorial-framework}" + LOGFILE=/tmp/bootstrap_tfw.log remotebase="git@github.com:" @@ -28,10 +31,10 @@ run() check_dependencies clone_repos_ask_ssh_or_https TAG="${BASEIMAGE_ONLY:-$(fetch_latest_tag)}" - TAG=$TAG pin_latest_baseimage TAG=$TAG build_latest_baseimage if [ -z "${BASEIMAGE_ONLY:-}" ]; then + TAG=$TAG pin_latest_baseimage install_frontend_deps if [ "$TFWDEV" == "0" ]; then cleanup_repos @@ -41,8 +44,12 @@ run() delete_repos fi - echo - echo "You can build & start TFW by executing the command: ${TEST}/hack/tfw.sh start" + if [ -z "${BASEIMAGE_ONLY:-}" ]; then + echo + echo "You can build & start TFW by executing the command: ${TEST}/hack/tfw.sh start" + else + echo "Baseimage version ${BASEIMAGE_ONLY} built successfully!" + fi } handle_exit() @@ -102,8 +109,10 @@ clone_repos() echo -n "Cloning TFW repositories... " echo -n "baseimage... " && logged git clone ${remotebase}avatao-content/${BASEIMAGE}.git - echo -n "frontend... " && logged git clone ${remotebase}avatao-content/${FRONTEND}.git - echo -n "test... " && logged git clone ${remotebase}avatao-content/${TEST}.git + if [ -z "${BASEIMAGE_ONLY:-}" ]; then + echo -n "frontend... " && logged git clone ${remotebase}avatao-content/${FRONTEND}.git + echo -n "test... " && logged git clone ${remotebase}avatao-content/${TEST}.git + fi echo "Done!" } @@ -137,9 +146,9 @@ build_latest_baseimage() { echo -n "Building baseimage at ${TAG}... " pushd "$BASEIMAGE" - spinned logged git checkout "$TAG" + logged git checkout "$TAG" + spinned logged docker build -t "${BASEIMAGE_NAME}:${TAG}" . popd - TFWTAG=$TAG spinned logged ${TEST}/hack/tfw.sh buildtfw echo "Done!" } From a6e8f4b8986fe74f47ea723b1b63941e0dd6af88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 8 Jun 2018 11:46:36 +0200 Subject: [PATCH 4/7] Rename functions not telling the truth in bootstrap script --- hack/bootstrap_tfw_dev.sh | 22 +++++++++++----------- hack/oneline_install.sh | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hack/bootstrap_tfw_dev.sh b/hack/bootstrap_tfw_dev.sh index 952fd59..826820c 100755 --- a/hack/bootstrap_tfw_dev.sh +++ b/hack/bootstrap_tfw_dev.sh @@ -29,12 +29,12 @@ run() : > $LOGFILE check_dependencies - clone_repos_ask_ssh_or_https + clone_required_repos_ask_ssh_or_https TAG="${BASEIMAGE_ONLY:-$(fetch_latest_tag)}" - TAG=$TAG build_latest_baseimage + TAG=$TAG build_baseimage if [ -z "${BASEIMAGE_ONLY:-}" ]; then - TAG=$TAG pin_latest_baseimage + TAG=$TAG pin_baseimage install_frontend_deps if [ "$TFWDEV" == "0" ]; then cleanup_repos @@ -44,8 +44,8 @@ run() delete_repos fi + echo if [ -z "${BASEIMAGE_ONLY:-}" ]; then - echo echo "You can build & start TFW by executing the command: ${TEST}/hack/tfw.sh start" else echo "Baseimage version ${BASEIMAGE_ONLY} built successfully!" @@ -88,22 +88,22 @@ check_dependencies() fi } -clone_repos_ask_ssh_or_https() +clone_required_repos_ask_ssh_or_https() { if [[ -z "$HTTPS_REMOTES" ]]; then read -p "Repos are pulled over SSH by default. Should I use HTTPS instead? [y/N]" -r -t 5 || : echo if [[ $REPLY =~ ^(y|Y|yes|Yes|YES)$ ]]; then - HTTPS_REMOTES=1 clone_repos + HTTPS_REMOTES=1 clone_required_repos else - HTTPS_REMOTES=0 clone_repos + HTTPS_REMOTES=0 clone_required_repos fi else - clone_repos + clone_required_repos fi } -clone_repos() +clone_required_repos() { [[ "$HTTPS_REMOTES" == "1" ]] && remotebase="https://github.com/" @@ -134,7 +134,7 @@ fetch_latest_tag() tail -n 1)" } -pin_latest_baseimage() +pin_baseimage() { echo -n "Pinning TFW baseimage version... " echo -n "which is ${TAG}... " @@ -142,7 +142,7 @@ pin_latest_baseimage() echo "Done!" } -build_latest_baseimage() +build_baseimage() { echo -n "Building baseimage at ${TAG}... " pushd "$BASEIMAGE" diff --git a/hack/oneline_install.sh b/hack/oneline_install.sh index a8963e9..dc1b5e3 100644 --- a/hack/oneline_install.sh +++ b/hack/oneline_install.sh @@ -1 +1 @@ -URL=https://git.io/vxBfj SHA=237d0cce945574208784a21fa6c6fbb4f479e5ce60b1518b1fcc921d675d2861 bash -c 'cmd="$(curl -fsSL $URL)" && [ $(echo "$cmd" | sha256sum | cut -d " " -f1) == $SHA ] && echo "$cmd" | bash || echo Checksum mismatch!' +URL=https://git.io/vxBfj SHA=d81057610588e16666251a4167f05841fc8b66ccd6988490c1a2d2deb6de8ffa bash -c 'cmd="$(curl -fsSL $URL)" && [ $(echo "$cmd" | sha256sum | cut -d " " -f1) == $SHA ] && echo "$cmd" | bash || echo Checksum mismatch!' From 164c04459530adabb3132fbdd18513c4a9698c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 8 Jun 2018 12:00:30 +0200 Subject: [PATCH 5/7] Reorder and augment stuff in readme --- README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1f2ba5d..52c2570 100644 --- a/README.md +++ b/README.md @@ -20,18 +20,6 @@ Getting started with creating challenges using the framework – *setting up a d ## Setting up a development environment -Just copy and paste the following command in a terminal: - -`bash -c "$(curl -fsSL https://git.io/vxBfj)"` - -Note that your SSH public key must be added to your GitHub user for this to work, or you mush select HTTPS remotes when prompted. - -By default your IDE will fail to autocomplete code and will complain about missing dependencies. -To fix this you should install the `tfw` pip package in your dev virtualenv: - -- `pip install git+ssh://git@github.com/avatao-content/baseimage-tutorial-framework.git` (SSH) -- `pip install git+https://github.com/avatao-content/baseimage-tutorial-framework.git` (HTTPS) - Dependencies: - bash - git @@ -40,13 +28,24 @@ Dependencies: - Angular CLI - GNU coreutils -> You have trust issues regarding the public key infrastructure? You can request a checksum authenticated version of the installer command from our team! +Just copy and paste the following command in a terminal: + +`bash -c "$(curl -fsSL https://git.io/vxBfj)"` + +Please do not hesitate to contact us with error logs included should this command fail to complete. +Note that your SSH public key must be added to your GitHub user for this to work, or you mush select HTTPS remotes when prompted. This will set up a dev environment based on [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) just for you: - it builds the latest release of the framework Docker baseimage locally - it pins `solvable/Dockerfile` to use the this image - it includes the latest frontend in `solvable/frontend` with dependencies installed +By default your IDE will fail to autocomplete code and will complain about missing dependencies. +To fix this you should install the `tfw` pip package in your dev virtualenv: + +- `pip install git+ssh://git@github.com/avatao-content/baseimage-tutorial-framework.git` (SSH) +- `pip install git+https://github.com/avatao-content/baseimage-tutorial-framework.git` (HTTPS) + ## Building & running ### Automated From 154c4fa2cef2a12f1d8ef5e7158d8c661f96228c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 8 Jun 2018 12:09:47 +0200 Subject: [PATCH 6/7] Add instructions on building a specific baseimage version --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 52c2570..ad8acad 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,12 @@ This will serve the frontend locally on `http://localhost:4200` and take care of If you've created a production build (without `--build-arg NOFRONTEND=1`) you don't have to run the frontend locally and you can access the challenge on `http://localhost:8888`. +### Building the TFW baseimage without test-tutorial-framework + +You might need to build our baseimage separately in case you've cloned an existing challenge depending on a specific version. + +To do this simply issue `BASEIMAGE_ONLY=version bash -c "$(curl -fsSL https://git.io/vxBfj)"`, where `version` is a tag or commit of the [baseimage-tutorial-framework](https://github.com/avatao-content/baseimage-tutorial-framework) repository. + ## Getting our hands dirty The repository of a tutorial-framework based challenge is quite similar to a regular challenge. From d21417ba0cd7904c5054825bf1bd1fcf194aa79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 8 Jun 2018 14:11:03 +0200 Subject: [PATCH 7/7] Implement in-container building of TFW sphinx documentation --- hack/tfw.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hack/tfw.sh b/hack/tfw.sh index f683a5f..dad09a4 100755 --- a/hack/tfw.sh +++ b/hack/tfw.sh @@ -5,6 +5,7 @@ set -o errtrace shopt -s expand_aliases [ "$(uname)" == "Darwin" ] && alias readlink="greadlink" || : +here="$(pwd)" SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" TAO_PATH="${TAO_PATH:-$SCRIPT_DIR/../..}" BASEIMAGE_REPO="${BASEIMAGE_REPO:-baseimage-tutorial-framework}" @@ -150,6 +151,28 @@ start_test() wait } +build_docs() +{ + mount_point="/mnt/docs" + + docker run --rm \ + -ti \ + -v "$BASEIMAGE_PATH"/docs:"$mount_point" \ + "$BASEIMAGE_NAME" \ + /bin/bash -c \ + "cd $mount_point + pip3 install sphinx + make html + exit" \ + &> /dev/null + + if [ "$?" == "0" ]; then + echo "Built baseimage docs at ${BASEIMAGE_PATH}/docs/build/html!" + else + echo "Building baseimage docs failed!" + fi +} + case ${1:-} in start) RUN_FRONTEND=1 start_test ${@:2} @@ -175,6 +198,9 @@ case ${1:-} in releasetfw) release_baseimage ;; + builddocs) + build_docs + ;; *) echo "Usage: tfw.sh [start|buildtfw|build|buildwithfrontend|releasetfw]" echo " |--- start: build & run TFW test and Angular frontend" @@ -185,5 +211,6 @@ case ${1:-} in echo " |--- build: build TFW baseimage and test" echo " |--- buildwithfrontend: build TFW baseimage and test, include frontend in image" echo " |--- releasetfw: tag TFW baseimage and push to upstream" + echo " |--- builddocs: build baseimage documentation (in docs/build/html)" ;; esac