114 lines
2.7 KiB
Bash
114 lines
2.7 KiB
Bash
|
is_ci(){
|
||
|
if [ -z ${CI+x} ];
|
||
|
then
|
||
|
return 1
|
||
|
else
|
||
|
return 0
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
if is_ci
|
||
|
then
|
||
|
FORGEJO_URL="http://forgejo:3000"
|
||
|
FORGEJO_SSH_URL="ssh://git@forgejo:22"
|
||
|
else
|
||
|
FORGEJO_URL="http://localhost:3000"
|
||
|
FORGEJO_SSH_URL="ssh://git@localhost:22"
|
||
|
fi
|
||
|
|
||
|
readonly FORGEJO_ROOT_USERNAME=root
|
||
|
readonly FORGEJO_ROOT_EMAIL="$FORGEJO_ROOT_USERNAME@example.org"
|
||
|
readonly FORGEJO_ROOT_PASSOWRD=supercomplicatedpassword
|
||
|
|
||
|
readonly FORGEJO_USER1_USERNAME=owner_user
|
||
|
readonly FORGEJO_USER1_PASSWORD=supercomplicatedpassword
|
||
|
readonly FORGEJO_USER1_EMAIL="$FORGEJO_USER1_USERNAME@example.org"
|
||
|
readonly FORGEJO_USER1_SUPPORT_REPO="support"
|
||
|
|
||
|
readonly FORGEJO_TESTUSER_USERNAME=test_user
|
||
|
readonly FORGEJO_TESTUSER_PASSWORD=supercomplicatedpassword
|
||
|
readonly FORGEJO_TESTUSER_EMAIL="$FORGEJO_TESTUSER_USERNAME@example.org"
|
||
|
|
||
|
|
||
|
wait_for_env() {
|
||
|
python -m integration \
|
||
|
check_env $FORGEJO_URL
|
||
|
}
|
||
|
|
||
|
# register root user on Forgejo to simulate Hoste admin and integrate SSO
|
||
|
forgejo_root(){
|
||
|
python -m integration \
|
||
|
forgejo install \
|
||
|
$FORGEJO_ROOT_USERNAME $FORGEJO_ROOT_PASSOWRD \
|
||
|
$FORGEJO_ROOT_EMAIL \
|
||
|
$FORGEJO_URL
|
||
|
python -m integration \
|
||
|
forgejo register \
|
||
|
$FORGEJO_ROOT_USERNAME $FORGEJO_ROOT_PASSOWRD \
|
||
|
$FORGEJO_ROOT_EMAIL \
|
||
|
$FORGEJO_URL
|
||
|
python -m integration \
|
||
|
forgejo login \
|
||
|
$FORGEJO_ROOT_USERNAME $FORGEJO_ROOT_PASSOWRD \
|
||
|
$FORGEJO_ROOT_EMAIL \
|
||
|
$FORGEJO_URL
|
||
|
}
|
||
|
|
||
|
|
||
|
# register user "Hostea" on Forgejo and create support repository
|
||
|
init_users_repo() {
|
||
|
python -m integration \
|
||
|
forgejo register \
|
||
|
$FORGEJO_USER1_USERNAME $FORGEJO_USER1_PASSWORD \
|
||
|
$FORGEJO_USER1_EMAIL \
|
||
|
$FORGEJO_URL
|
||
|
python -m integration \
|
||
|
forgejo login \
|
||
|
$FORGEJO_USER1_USERNAME $FORGEJO_USER1_PASSWORD \
|
||
|
$FORGEJO_USER1_EMAIL \
|
||
|
$FORGEJO_URL
|
||
|
python -m integration \
|
||
|
forgejo create_repo \
|
||
|
$FORGEJO_USER1_USERNAME $FORGEJO_USER1_PASSWORD \
|
||
|
$FORGEJO_USER1_EMAIL \
|
||
|
$FORGEJO_URL \
|
||
|
$FORGEJO_USER1_SUPPORT_REPO
|
||
|
|
||
|
python -m integration \
|
||
|
forgejo register \
|
||
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
||
|
$FORGEJO_TESTUSER_EMAIL \
|
||
|
$FORGEJO_URL
|
||
|
|
||
|
python -m integration \
|
||
|
forgejo create_issue \
|
||
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
||
|
$FORGEJO_USER1_EMAIL \
|
||
|
$FORGEJO_URL \
|
||
|
$FORGEJO_USER1_USERNAME \
|
||
|
$FORGEJO_USER1_SUPPORT_REPO
|
||
|
}
|
||
|
|
||
|
setup_env() {
|
||
|
# mkdir tmp/ || true
|
||
|
# nohup python manage.py runserver > /dev/null 2>&1 &
|
||
|
# SERVER_PID=$!
|
||
|
# echo $SERVER_PID > $SERVER_PID_FILE
|
||
|
echo "TODO"
|
||
|
}
|
||
|
|
||
|
teardown_env() {
|
||
|
echo "TODO"
|
||
|
#kill $(cat $SERVER_PID_FILE)
|
||
|
}
|
||
|
|
||
|
docker_compose_up() {
|
||
|
echo "[*] Starting Forgejo"
|
||
|
docker-compose -f docker-compose-dev-deps.yml up
|
||
|
}
|
||
|
|
||
|
docker_compose_down() {
|
||
|
docker-compose -f docker-compose-dev-deps.yml down
|
||
|
docker-compose -f docker-compose-dev-deps.yml down --remove-orphans
|
||
|
}
|