mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-12-05 02:41:32 +00:00
Merge branch 'baseimage-only-hack'
This commit is contained in:
commit
321699c644
31
README.md
31
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
|
||||
@ -80,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.
|
||||
|
@ -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:"
|
||||
@ -26,24 +29,33 @@ run()
|
||||
: > $LOGFILE
|
||||
|
||||
check_dependencies
|
||||
clone_repos_ask_ssh_or_https
|
||||
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
|
||||
clone_required_repos_ask_ssh_or_https
|
||||
TAG="${BASEIMAGE_ONLY:-$(fetch_latest_tag)}"
|
||||
TAG=$TAG build_baseimage
|
||||
|
||||
if [ -z "${BASEIMAGE_ONLY:-}" ]; then
|
||||
TAG=$TAG pin_baseimage
|
||||
install_frontend_deps
|
||||
if [ "$TFWDEV" == "0" ]; then
|
||||
cleanup_repos
|
||||
merge_repos
|
||||
fi
|
||||
else
|
||||
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 "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()
|
||||
{
|
||||
if [[ $? -ne 0 ]]; then
|
||||
err_cleanup
|
||||
delete_repos
|
||||
showlog
|
||||
fi
|
||||
cleanlog
|
||||
@ -51,7 +63,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()
|
||||
{
|
||||
@ -76,29 +88,31 @@ 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/"
|
||||
|
||||
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!"
|
||||
}
|
||||
|
||||
@ -120,21 +134,21 @@ fetch_latest_tag()
|
||||
tail -n 1)"
|
||||
}
|
||||
|
||||
pin_latest_baseimage()
|
||||
pin_baseimage()
|
||||
{
|
||||
echo -n "Pinning latest TFW baseimage version... "
|
||||
echo -n "which is ${LATESTTAG}... "
|
||||
sed -i "1 s/.*/&:${LATESTTAG}/" "${TEST}/solvable/Dockerfile"
|
||||
echo -n "Pinning TFW baseimage version... "
|
||||
echo -n "which is ${TAG}... "
|
||||
sed -i "1 s/.*/&:${TAG}/" "${TEST}/solvable/Dockerfile"
|
||||
echo "Done!"
|
||||
}
|
||||
|
||||
build_latest_baseimage()
|
||||
build_baseimage()
|
||||
{
|
||||
echo -n "Building baseimage at ${LATESTTAG}... "
|
||||
echo -n "Building baseimage at ${TAG}... "
|
||||
pushd "$BASEIMAGE"
|
||||
spinned logged git checkout "$LATESTTAG"
|
||||
logged git checkout "$TAG"
|
||||
spinned logged docker build -t "${BASEIMAGE_NAME}:${TAG}" .
|
||||
popd
|
||||
TFWTAG=$LATESTTAG spinned logged ${TEST}/hack/tfw.sh buildtfw
|
||||
echo "Done!"
|
||||
}
|
||||
|
||||
|
@ -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=d81057610588e16666251a4167f05841fc8b66ccd6988490c1a2d2deb6de8ffa bash -c 'cmd="$(curl -fsSL $URL)" && [ $(echo "$cmd" | sha256sum | cut -d " " -f1) == $SHA ] && echo "$cmd" | bash || echo Checksum mismatch!'
|
||||
|
27
hack/tfw.sh
27
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
|
||||
|
Loading…
Reference in New Issue
Block a user