Merge pull request 'lib: start & stop GitLab' (#207) from twenty-panda/end-to-end:wip-gitlab into main

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/207
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
This commit is contained in:
earl-warren 2024-06-23 08:26:40 +00:00
commit e4fa6d814f
3 changed files with 70 additions and 3 deletions

View file

@ -82,7 +82,18 @@ jobs:
steps: steps:
- uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/checkout@v4
- uses: ./.forgejo/prepare-end-to-end - uses: ./.forgejo/prepare-end-to-end
- run: su forgejo -c "./end-to-end.sh test_federation" - name: install zstd
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get -q install -y -qq zstd
- name: cache GitLab OCI image
uses: https://code.forgejo.org/actions/cache@v4
with:
path: |
/srv/forgejo-binaries/gitlab
key: gitlab
- run: |
su forgejo -c "./end-to-end.sh test_federation"
- name: full logs - name: full logs
if: always() if: always()
run: su forgejo -c "./end-to-end.sh show_logs" run: su forgejo -c "./end-to-end.sh show_logs"

View file

@ -66,6 +66,7 @@ function federation_teardown() {
} }
function test_federation() { function test_federation() {
# start_gitlab octobus/heptapod:1.5.3
federation_setup_variables federation_setup_variables
local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" local versions="${1:-$RELEASE_NUMBERS_AND_DEV}"

View file

@ -49,9 +49,9 @@ function dependencies() {
$SUDO chmod +x /usr/local/bin/forgejo-curl.sh $SUDO chmod +x /usr/local/bin/forgejo-curl.sh
fi fi
if ! which make curl daemon git-lfs jq sqlite3 > /dev/null ; then if ! which make curl daemon git-lfs jq sqlite3 skopeo > /dev/null ; then
$SUDO apt-get update -qq $SUDO apt-get update -qq
$SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 skopeo
fi fi
if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then
@ -178,6 +178,57 @@ function clobber() {
rm -fr /tmp/forgejo-end-to-end rm -fr /tmp/forgejo-end-to-end
} }
function start_gitlab_cache_load() {
local image=$1
local d=$DIR_BINARIES/gitlab
if test -d $d ; then
log_info "loading $image from $d"
skopeo copy dir:$d docker-daemon:$image
fi
}
function start_gitlab_cache_save() {
local image=$1
local d=$DIR_BINARIES/gitlab
if ! test -d $d ; then
log_info "saving $image to $d"
skopeo copy docker-daemon:$image dir:$d
fi
}
function start_gitlab() {
local image=$1
local config=$2
start_gitlab_cache_load $image
local GITLAB_OMNIBUS_CONFIG="nginx['listen_https'] = false ; nginx['listen_port'] = 8181 ; external_url 'http://0.0.0.0:8181'; gitlab_rails['gitlab_shell_ssh_port'] = 2221;"
docker run --name="test-gitlab" --shm-size=128M -d \
-e GITLAB_OMNIBUS_CONFIG="$GITLAB_OMNIBUS_CONFIG" \
-p 2221:22 -p 8181:8181 \
$image >& /dev/null < /dev/null
start_gitlab_cache_save $image
for i in $(seq 10) ; do
if test $(curl --silent http://0.0.0.0:8181 -o /dev/null -w "%{http_code}") = 302 ; then
docker exec test-gitlab gitlab-rails runner "user = User.find_by_username 'root'; user.password = 'Wrobyak4'; user.password_confirmation = 'Wrobyak4'; user.password_automatically_set = false ; user.save!"
docker exec test-gitlab$serial gitlab-rails runner "Gitlab::CurrentSettings.current_application_settings.update(default_vcs_type: 'git')"
log_info "GitLab is ready"
return
fi
log_info "waiting for GitLab to come up $i"
sleep 30
done
log_info "GitLab did not come up"
docker logs test-gitlab
false
}
function stop_gitlab() {
docker rm -f test-gitlab
}
function stop_forgejo() { function stop_forgejo() {
local config=$1 local config=$1
@ -386,6 +437,10 @@ function stop() {
} }
function show_logs() { function show_logs() {
if ! test -d $DIR ; then
log_info "$DIR does not exist, no logs to display"
return
fi
( (
cd $DIR cd $DIR
set +e set +e