2023-09-18 20:44:19 +05:30
|
|
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2023-09-17 01:59:08 +05:30
|
|
|
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"
|
2023-09-18 17:14:19 +05:30
|
|
|
readonly FORGEJO_USER1_ACCESS_TOKEN_NAME="coreaccesstoken"
|
2023-09-18 22:30:02 +05:30
|
|
|
readonly FORGEJO_USER1_ACCESS_TOKEN_FILE_PATH=$(realpath tmp/user1-accesstoken.json)
|
2023-09-18 17:55:18 +05:30
|
|
|
rm $FORGEJO_USER1_ACCESS_TOKEN_FILE_PATH || true
|
2023-09-17 01:59:08 +05:30
|
|
|
|
|
|
|
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
|
2023-09-19 00:01:23 +05:30
|
|
|
sleep 10
|
|
|
|
curl $FORGEJO_URL
|
2023-09-17 01:59:08 +05:30
|
|
|
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 \
|
2023-09-17 23:06:21 +05:30
|
|
|
$FORGEJO_USER1_SUPPORT_REPO \
|
|
|
|
"normal issue title" "normal issue body"
|
|
|
|
|
|
|
|
python -m integration \
|
|
|
|
forgejo create_comment \
|
|
|
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
|
|
|
$FORGEJO_USER1_EMAIL \
|
|
|
|
$FORGEJO_URL \
|
|
|
|
$FORGEJO_USER1_USERNAME \
|
|
|
|
$FORGEJO_USER1_SUPPORT_REPO \
|
|
|
|
1 "normal body"
|
|
|
|
|
|
|
|
python -m integration \
|
|
|
|
forgejo create_comment \
|
|
|
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
|
|
|
$FORGEJO_USER1_EMAIL \
|
|
|
|
$FORGEJO_URL \
|
|
|
|
$FORGEJO_USER1_USERNAME \
|
|
|
|
$FORGEJO_USER1_SUPPORT_REPO \
|
|
|
|
1 "mention body @$FORGEJO_USER1_USERNAME"
|
|
|
|
|
|
|
|
python -m integration \
|
|
|
|
forgejo create_issue \
|
|
|
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
|
|
|
$FORGEJO_USER1_EMAIL \
|
|
|
|
$FORGEJO_URL \
|
|
|
|
$FORGEJO_USER1_USERNAME \
|
|
|
|
$FORGEJO_USER1_SUPPORT_REPO \
|
|
|
|
"normal issue title" "mention issue @$FORGEJO_USER1_USERNAME"
|
|
|
|
|
|
|
|
python -m integration \
|
|
|
|
forgejo create_issue \
|
|
|
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
|
|
|
$FORGEJO_USER1_EMAIL \
|
|
|
|
$FORGEJO_URL \
|
|
|
|
$FORGEJO_USER1_USERNAME \
|
|
|
|
$FORGEJO_USER1_SUPPORT_REPO \
|
|
|
|
"mention issue @$FORGEJO_USER1_USERNAME" "normal issue body"
|
|
|
|
|
|
|
|
|
|
|
|
python -m integration \
|
|
|
|
forgejo create_issue \
|
|
|
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
|
|
|
$FORGEJO_USER1_EMAIL \
|
|
|
|
$FORGEJO_URL \
|
|
|
|
$FORGEJO_USER1_USERNAME \
|
|
|
|
$FORGEJO_USER1_SUPPORT_REPO \
|
|
|
|
"mention issue @$FORGEJO_USER1_USERNAME" "mention issue @$FORGEJO_USER1_USERNAME"
|
2023-09-18 17:14:19 +05:30
|
|
|
|
2023-09-18 20:27:36 +05:30
|
|
|
python -m integration \
|
|
|
|
forgejo create_issue \
|
|
|
|
$FORGEJO_TESTUSER_USERNAME $FORGEJO_TESTUSER_PASSWORD \
|
|
|
|
$FORGEJO_USER1_EMAIL \
|
|
|
|
$FORGEJO_URL \
|
|
|
|
$FORGEJO_USER1_USERNAME \
|
|
|
|
$FORGEJO_USER1_SUPPORT_REPO \
|
|
|
|
"normal issue title and normal body" "normal body"
|
2023-09-18 17:14:19 +05:30
|
|
|
|
|
|
|
python -m integration \
|
|
|
|
forgejo create_access_token \
|
2023-09-18 19:04:40 +05:30
|
|
|
$FORGEJO_USER1_USERNAME $FORGEJO_USER1_PASSWORD \
|
2023-09-18 17:14:19 +05:30
|
|
|
$FORGEJO_USER1_EMAIL \
|
|
|
|
$FORGEJO_URL \
|
|
|
|
$FORGEJO_USER1_ACCESS_TOKEN_NAME \
|
2023-09-18 20:27:36 +05:30
|
|
|
$FORGEJO_USER1_ACCESS_TOKEN_FILE_PATH \
|
|
|
|
$FORGEJO_USER1_SUPPORT_REPO
|
2023-09-17 01:59:08 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|