Skip to content

Commit

Permalink
Install node and yarn in common_startup.sh using nodeenv and the venv's
Browse files Browse the repository at this point in the history
npm.
  • Loading branch information
natefoo authored and nsoranzo committed Feb 8, 2018
1 parent b463be7 commit 977bbf1
Showing 1 changed file with 68 additions and 24 deletions.
92 changes: 68 additions & 24 deletions scripts/common_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ RMFILES="
lib/pkg_resources.pyc
"

# return true if $1 is in $VIRTUAL_ENV else false
in_venv() {
case $1 in
$VIRTUAL_ENV*)
return 0
;;
''|*)
return 1
;;
esac
}

if [ $COPY_SAMPLE_FILES -eq 1 ]; then
# Create any missing config/location files
for sample in $SAMPLES; do
Expand All @@ -65,30 +77,23 @@ for rmfile in $RMFILES; do
[ -f "$rmfile" ] && rm -f "$rmfile"
done

# Check client build state.
if [ $SKIP_CLIENT_BUILD -eq 0 ]; then
gitbranch=$(git rev-parse --abbrev-ref HEAD)
if [ "$gitbranch" = "dev" ]; then
# We're on dev. This branch (only, currently) doesn't have build
# artifacts. We should probabably swap to a list of releases?
# Compare hash.
if [ -f static/client_build_hash.txt ]; then
githash=$(git rev-parse HEAD)
statichash=$(cat static/client_build_hash.txt)
if [ "$githash" = "$statichash" ]; then
SKIP_CLIENT_BUILD=1
fi
fi
else
# Not on dev. We're not going to bug people about building.
SKIP_CLIENT_BUILD=1
fi
if [ $SKIP_CLIENT_BUILD -eq 0 ]; then
echo "The Galaxy client build is out of date. Please run 'make client' or your choice of client build target (client-*)."
echo "If you're sure you'd like to skip this check, you can run galaxy with the --skip-client-build flag, though this is not recommended as the client and server code will potentially be out of sync."
echo "See ./client/README.md in the Galaxy repository for more information, including how to get help if you're having trouble."
exit 1
fi
# Determine branch (if using git)
if command -v git >/dev/null; then
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
case $GIT_BRANCH in
release_*|master)
# All non-release branches should build the client as necessary
SKIP_CLIENT_BUILD=1
;;
*)
# Ensure nodeenv is installed
DEV_WHEELS=1
# SKIP_CLIENT_BUILD will default to false, but can be overridden by the command line argument
;;
esac
else
GIT_BRANCH=0
SKIP_CLIENT_BUILD=1
fi

: ${GALAXY_CONFIG_FILE:=config/galaxy.yml}
Expand Down Expand Up @@ -183,3 +188,42 @@ if [ $FETCH_WHEELS -eq 1 ]; then
GALAXY_CONDITIONAL_DEPENDENCIES=$(PYTHONPATH=lib python -c "import galaxy.dependencies; print('\n'.join(galaxy.dependencies.optional('$GALAXY_CONFIG_FILE')))")
[ -z "$GALAXY_CONDITIONAL_DEPENDENCIES" ] || echo "$GALAXY_CONDITIONAL_DEPENDENCIES" | pip install -r /dev/stdin --index-url "${GALAXY_WHEELS_INDEX_URL}" --extra-index-url "${PYPI_INDEX_URL}"
fi

# Check client build state.
if [ $SKIP_CLIENT_BUILD -eq 0 ]; then
if [ -f static/client_build_hash.txt ]; then
# Compare hash.
githash=$(git rev-parse HEAD)
statichash=$(cat static/client_build_hash.txt)
if [ "$githash" = "$statichash" ]; then
SKIP_CLIENT_BUILD=1
else
echo "The Galaxy client is out of date and will be built now."
fi
else
echo "The Galaxy client has not yet been built and will be built now."
fi
fi

# Build client if necessary.
if [ $SKIP_CLIENT_BUILD -eq 0 ]; then
# Ensure dependencies are installed
if [ -n "$VIRTUAL_ENV" ]; then
if ! in_venv `command -v node`; then
echo "Installing node into $VIRTUAL_ENV with nodeenv."
nodeenv -p
fi
if ! in_venv `command -v yarn`; then
echo "Installing yarn into $VIRTUAL_ENV with npm."
npm install --global yarn
fi
else
echo "WARNING: Galaxy client build needed but there is no virtualenv enabled. Build may fail."
fi

# Build client
if ! make client; then
echo "ERROR: Galaxy client build failed. See ./client/README.md for more information, including how to get help."
exit 1
fi
fi

0 comments on commit 977bbf1

Please sign in to comment.