Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retire des restes de Travis #6179

Merged
merged 6 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 1 addition & 120 deletions scripts/define_function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,125 +10,6 @@ function _in {
}


## travis code
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_fold.bash
zds_travis_fold() {
local action="${1}"
local name="${2}"
echo -en "travis_fold:${action}:${name}\\r${ANSI_CLEAR}"
}


# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_nanoseconds.bash
zds_travis_nanoseconds() {
local cmd='date'
local format='+%s%N'

if hash gdate >/dev/null 2>&1; then
cmd='gdate'
elif [[ "${TRAVIS_OS_NAME}" == osx ]]; then
format='+%s000000000'
fi

"${cmd}" -u "${format}"
}


# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_time_start.bash
# change : prefixed global variable with ZDS_
zds_travis_time_start() {
ZDS_TRAVIS_TIMER_ID="ZDS_$(printf %08x $((RANDOM * RANDOM)))"
ZDS_TRAVIS_TIMER_START_TIME="$(zds_travis_nanoseconds)"
export ZDS_TRAVIS_TIMER_ID ZDS_TRAVIS_TIMER_START_TIME
echo -en "travis_time:start:${ZDS_TRAVIS_TIMER_ID}\\r${ANSI_CLEAR}"
}


# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_time_finish.bash
# change : prefixed global variable with ZDS_
zds_travis_time_finish() {
local result="${?}"
local travis_timer_end_time
travis_timer_end_time="$(zds_travis_nanoseconds)"
local duration
duration="$((travis_timer_end_time - ZDS_TRAVIS_TIMER_START_TIME))"
echo -en "travis_time:end:${ZDS_TRAVIS_TIMER_ID}:start=${ZDS_TRAVIS_TIMER_START_TIME},finish=${travis_timer_end_time},duration=${duration}\\r${ANSI_CLEAR}"
return "${result}"
}
##


## start fold for travis
ZDS_SHOW_TRAVIS_FOLD=0
if $(_in "--travis-output" $@); then
ZDS_SHOW_TRAVIS_FOLD=1
fi


zds_fold_current_cat="default"
function zds_fold_category {
zds_fold_current_cat="$1"
}


zds_fold_current=""
function zds_fold_start {
if [[ $ZDS_SHOW_TRAVIS_FOLD == 1 ]]; then
if [[ $zds_fold_current == $1 ]]; then # for virtualenv fold
return
fi

zds_fold_current="$1"
zds_travis_fold "start" "${zds_fold_current_cat}_${zds_fold_current}"

zds_travis_time_start
fi

print_info "$2" --bold
}


function zds_fold_end {
if [[ $ZDS_SHOW_TRAVIS_FOLD == 1 ]] && [[ $zds_fold_current =~ "" ]]; then
zds_travis_time_finish

zds_travis_fold "end" "${zds_fold_current_cat}_${zds_fold_current}"
zds_fold_current=""
fi
}
## end


## start zmd start & stop function
function zds_start_zmd {
npm run server --prefix zmd/node_modules/zmarkdown -- --silent; exVal=$?

if [[ $exVal != 0 ]]; then
zds_fold_end
gateway "!! Cannot start zmd" $exVal
exit 1
fi
}


function zds_stop_zmd {
node ./zmd/node_modules/pm2/bin/pm2 kill; exVal=$?

if [[ $exVal != 0 ]]; then
print_error "Warning: Cannot stop zmd"
fi
}
## end


function gateway {
if [[ $2 != 0 ]]; then
print_error "$1"
exit $2
fi
}


## start print function
function print_info {
if [[ "$2" == "--bold" ]]; then
Expand All @@ -146,4 +27,4 @@ function print_error {
echo "$1"
echo -en "\033[00m"
}
## end
## end
84 changes: 15 additions & 69 deletions scripts/install_zds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,6 @@ function load_nvm {
}


## start quiet mode
function progressfilt {
local flag=false c count cr=$'\r' nl=$'\n'
while IFS='' read -d '' -rn 1 c
do
if $flag; then
printf '%s' "$c"
else
if [[ $c != $cr && $c != $nl ]]; then
count=0
else
((count++))
if ((count > 1)); then
flag=true
fi
fi
fi
done
}


# Hack for "-q --show-progress" (at least v1.16) and travis uses (travis uses wget 1.15)
function wget_nv {
wget "$@" --progress=bar:force 2>&1 | progressfilt
}
## end


# zds-site root folder
ZDSSITE_DIR=$(pwd)

Expand All @@ -47,12 +19,10 @@ LOCAL_DIR="$(cd "$(dirname "$0")" && pwd)"
source $LOCAL_DIR/define_variable.sh
source $LOCAL_DIR/define_function.sh

zds_fold_category "install"


# Install packages
if ! $(_in "-packages" $@) && ( $(_in "+packages" $@) || $(_in "+base" $@) || $(_in "+full" $@) ); then
zds_fold_start "packages" "* [+packages] installing packages (this subcommand will be run as super-user)"
print_info "* [+packages] installing packages (this subcommand will be run as super-user)" --bold

if $(_in "--detect-os-version" $@); then
version=$(cat /proc/version)
Expand Down Expand Up @@ -147,15 +117,13 @@ if ! $(_in "-packages" $@) && ( $(_in "+packages" $@) || $(_in "+base" $@) || $
fi
echo ""
done

zds_fold_end
fi


# virtualenv

if ! $(_in "-virtualenv" $@) && ( $(_in "+virtualenv" $@) || $(_in "+base" $@) || $(_in "+full" $@) ); then
zds_fold_start "virtualenv" "* Create virtualenv"
print_info "* Create virtualenv" --bold

if [ ! -f $ZDS_VENV/bin/activate ]; then
if [ -d $ZDS_VENV ]; then
Expand Down Expand Up @@ -202,7 +170,7 @@ fi

# nvm node & yarn
if ! $(_in "-node" $@) && ( $(_in "+node" $@) || $(_in "+base" $@) || $(_in "+full" $@) ); then
zds_fold_start "node" "* [+node] installing nvm (v$ZDS_NVM_VERSION) & node (v$ZDS_NODE_VERSION) & yarn"
print_info "* [+node] installing nvm (v$ZDS_NVM_VERSION) & node (v$ZDS_NODE_VERSION) & yarn" --bold

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v${ZDS_NVM_VERSION}/install.sh | bash
if [[ $? == 0 ]]; then
Expand All @@ -225,13 +193,11 @@ if ! $(_in "-node" $@) && ( $(_in "+node" $@) || $(_in "+base" $@) || $(_in "+f
print_error "!! Cannot obtain nvm v${ZDS_NVM_VERSION}"
exit 1
fi

zds_fold_end
fi

# virtualenv activation
if ! $(_in "--force-skip-activating" $@) && [[ ( $VIRTUAL_ENV == "" || $(realpath $VIRTUAL_ENV) != $(realpath $ZDS_VENV) ) ]]; then
zds_fold_start "virtualenv" "* Load virtualenv"
print_info "* Load virtualenv" --bold

print_info "* activating venv \`$ZDS_VENV\`"

Expand All @@ -256,24 +222,20 @@ if ! $(_in "--force-skip-activating" $@) && [[ ( $VIRTUAL_ENV == "" || $(realpat
echo " - If you don't have other choice, use \`--force-skip-activating\`."
exit 1
fi

zds_fold_end
else
print_info "!! Add \`$(realpath $ZDS_VENV)\` in your PATH."

if [ ! -d $ZDS_VENV ]; then
mkdir $ZDS_VENV
fi

zds_fold_end
fi

export ZDS_ENV=$(realpath $ZDS_VENV)


# local jdk
if ! $(_in "-jdk-local" $@) && ( $(_in "+jdk-local" $@) || $(_in "+full" $@) ); then
zds_fold_start "jdk" "* [+jdk-local] installing a local version of JDK (v$ZDS_JDK_VERSION)"
print_info "* [+jdk-local] installing a local version of JDK (v$ZDS_JDK_VERSION)" --bold

mkdir -p $ZDS_VENV/lib/
cd $ZDS_VENV/lib/
Expand All @@ -289,7 +251,7 @@ if ! $(_in "-jdk-local" $@) && ( $(_in "+jdk-local" $@) || $(_in "+full" $@) );
folderPATH="${foldername}/OpenJDK11U-jdk_x64_linux_hotspot_${ZDS_JDK_VERSION}_${ZDS_JDK_REV}.tar.gz"

echo "GET ${baseURL}${folderPATH}"
wget_nv -O ${foldername}.tar.gz ${baseURL}${folderPATH}
wget -O ${foldername}.tar.gz ${baseURL}${folderPATH} -q --show-progress
tar xf ${foldername}.tar.gz

if [[ $? == 0 ]]; then
Expand All @@ -314,14 +276,12 @@ if ! $(_in "-jdk-local" $@) && ( $(_in "+jdk-local" $@) || $(_in "+full" $@) );
exit 1
fi
cd $ZDSSITE_DIR

zds_fold_end
fi


# local elasticsearch
if ! $(_in "-elastic-local" $@) && ( $(_in "+elastic-local" $@) || $(_in "+full" $@) ); then
zds_fold_start "elasticsearch" "* [+elastic-local] installing a local version of elasticsearch (v$ZDS_ELASTIC_VERSION)"
print_info "* [+elastic-local] installing a local version of elasticsearch (v$ZDS_ELASTIC_VERSION)" --bold

mkdir -p .local
cd .local
Expand All @@ -332,7 +292,7 @@ if ! $(_in "-elastic-local" $@) && ( $(_in "+elastic-local" $@) || $(_in "+full
rm -r "$es_path"
fi

wget_nv https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ZDS_ELASTIC_VERSION}.zip
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ZDS_ELASTIC_VERSION}.zip -q --show-progress
if [[ $? == 0 ]]; then
unzip -q elasticsearch-${ZDS_ELASTIC_VERSION}.zip
rm elasticsearch-${ZDS_ELASTIC_VERSION}.zip
Expand All @@ -350,14 +310,12 @@ if ! $(_in "-elastic-local" $@) && ( $(_in "+elastic-local" $@) || $(_in "+full
exit 1
fi
cd $ZDSSITE_DIR

zds_fold_end
fi


# local texlive
if ! $(_in "-tex-local" $@) && ( $(_in "+tex-local" $@) || $(_in "+full" $@) ); then
zds_fold_start "texlive" "* [+tex-local] install texlive"
print_info "* [+tex-local] install texlive" --bold

mkdir -p .local
cd .local
Expand Down Expand Up @@ -387,7 +345,7 @@ if ! $(_in "-tex-local" $@) && ( $(_in "+tex-local" $@) || $(_in "+full" $@) );
sed -i 's@.texlive@texlive@' texlive.profile # change directory
sed -i "s@\$HOME@$LOCAL@" texlive.profile # change destination

wget_nv -O install-tl.tar.gz http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
wget -O install-tl.tar.gz http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz -q --show-progress
if [[ $? == 0 ]]; then
if [[ ! -f ./bin/x86_64-linux/tlmgr ]]; then # install texlive
tar xzf install-tl.tar.gz
Expand Down Expand Up @@ -417,14 +375,12 @@ if ! $(_in "-tex-local" $@) && ( $(_in "+tex-local" $@) || $(_in "+full" $@) );
fi

cd $ZDSSITE_DIR

zds_fold_end
fi


# latex-template in TEXMFHOME.
if ! $(_in "-latex-template" $@) && ( $(_in "+latex-template" $@) || $(_in "+full" $@) ); then
zds_fold_start "latex-template" "* [+latex-template] install latex-template (from $ZDS_LATEX_REPO)"
print_info "* [+latex-template] install latex-template (from $ZDS_LATEX_REPO)" --bold

if [[ $(which kpsewhich) == "" ]]; then # no texlive ?
print_error "!! Cannot find kpsewhich, do you have texlive?"
Expand All @@ -449,14 +405,12 @@ if ! $(_in "-latex-template" $@) && ( $(_in "+latex-template" $@) || $(_in "+fu
fi

cd $ZDSSITE_DIR

zds_fold_end
fi


# install back
if ! $(_in "-back" $@) && ( $(_in "+back" $@) || $(_in "+base" $@) || $(_in "+full" $@) ); then
zds_fold_start "back" "* [+back] install back dependencies & migration"
print_info "* [+back] install back dependencies & migration" --bold

if $(_in "+prod" $@); then
make install-back-with-prod; exVal=$?
Expand All @@ -477,14 +431,12 @@ if ! $(_in "-back" $@) && ( $(_in "+back" $@) || $(_in "+base" $@) || $(_in "+f
exit 1
fi
fi

zds_fold_end
fi


# install front
if ! $(_in "-front" $@) && ( $(_in "+front" $@) || $(_in "+base" $@) || $(_in "+full" $@) ); then
zds_fold_start "front" "* [+front] install front dependencies & build front"
print_info "* [+front] install front dependencies & build front" --bold

if [ -d node_modules ]; then # delete previous modules
rm -r node_modules
Expand All @@ -503,29 +455,25 @@ if ! $(_in "-front" $@) && ( $(_in "+front" $@) || $(_in "+base" $@) || $(_in "
print_error "!! Cannot build-front (use \`-front\` to skip)"
exit 1
fi

zds_fold_end
fi


# zmd
if ! $(_in "-zmd" $@) && ( $(_in "+zmd" $@) || $(_in "+base" $@) || $(_in "+full" $@) ); then
zds_fold_start "zmd" "* [+zmd] install zmarkdown dependencies"
print_info "* [+zmd] install zmarkdown dependencies" --bold

make zmd-install; exVal=$?

if [[ $exVal != 0 ]]; then
print_error "!! Cannot install zmd (use \`-zmd\` to skip)"
exit 1
fi

zds_fold_end
fi


# fixtures
if ! $(_in "-data" $@) && ( $(_in "+data" $@) || $(_in "+base" $@) || $(_in "+full" $@) ); then
zds_fold_start "fixtures" "* [+data] fixtures"
print_info "* [+data] fixtures" --bold

npm run server --prefix zmd/node_modules/zmarkdown -- --silent; exVal=$?

Expand Down Expand Up @@ -570,8 +518,6 @@ if ! $(_in "-data" $@) && ( $(_in "+data" $@) || $(_in "+base" $@) || $(_in "+f
if $futureExit; then
exit 1
fi

zds_fold_end
fi

if ! $(_in "--force-skip-activating" $@); then
Expand Down
Loading