Skip to content
Snippets Groups Projects
Commit 54401492 authored by Florian Bruhin's avatar Florian Bruhin
Browse files

init.sh: Abort on errors and show more debug infos

When viewing the container start logs, we want to see which step failed exactly.
And if one fails, the script should not continue to run, as this leads to weird
follow-up failures. Motivation for that change:

- Cloning the repos failed due to a bad token
- The `cd submission_repo` failed (as it doesn't exist)
- The `cd ..` thus moved out of the project directory
- And thus, starting gunicorn failed with `ModuleNotFoundError: No module named
  'flask_app'` after a long traceback, easily hiding the actual error.

Setting `-e` required making the rest of the script run fine no matter what
state things are in (local student volume and branch on GitLab).

Hopefully, it will be enough to:

- Not clone the repo if it already exists
- Deal with the upstream branch not existing yet
parent 08eb8add
Branches
No related tags found
No related merge requests found
Pipeline #358526 passed
#!/bin/bash
#!/bin/bash -ex
if [[ -z $USERNAME ]]
then
......@@ -16,7 +16,7 @@ echo "Username $USERNAME"
# Test Data
if [[ -n $GIT_TEST_REPO ]]; then
git clone -q $GIT_TEST_REPO test_repo
[[ ! -d test_repo ]] && git clone -q $GIT_TEST_REPO test_repo
else
echo "VENV GIT_TEST_REPO is not set."
echo "You can use a volume to get your test git repo into $(pwd)/test_repo"
......@@ -25,11 +25,11 @@ export TEST_REPO="$(pwd)/test_repo/notebooks"
# Submissions Repo
if [[ -n $GIT_SUBMISSION_REPO ]]; then
git clone -q $GIT_SUBMISSION_REPO submission_repo
[[ ! -d submission_repo ]] && git clone -q $GIT_SUBMISSION_REPO submission_repo
cd submission_repo
git checkout -B $USERNAME
git branch --set-upstream-to=origin/$USERNAME $USERNAME
git pull
# setting upstream can fail if there is no such branch upstream yet
{ git branch --set-upstream-to=origin/$USERNAME $USERNAME && git pull ;} || true
cd ..
else
echo "VENV GIT_SUBMISSION_REPO is not set."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment