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:
commit
e4fa6d814f
3 changed files with 70 additions and 3 deletions
|
@ -82,7 +82,18 @@ jobs:
|
|||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- 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
|
||||
if: always()
|
||||
run: su forgejo -c "./end-to-end.sh show_logs"
|
||||
|
|
|
@ -66,6 +66,7 @@ function federation_teardown() {
|
|||
}
|
||||
|
||||
function test_federation() {
|
||||
# start_gitlab octobus/heptapod:1.5.3
|
||||
federation_setup_variables
|
||||
|
||||
local versions="${1:-$RELEASE_NUMBERS_AND_DEV}"
|
||||
|
|
59
lib/lib.sh
59
lib/lib.sh
|
@ -49,9 +49,9 @@ function dependencies() {
|
|||
$SUDO chmod +x /usr/local/bin/forgejo-curl.sh
|
||||
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 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
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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() {
|
||||
local config=$1
|
||||
|
||||
|
@ -386,6 +437,10 @@ function stop() {
|
|||
}
|
||||
|
||||
function show_logs() {
|
||||
if ! test -d $DIR ; then
|
||||
log_info "$DIR does not exist, no logs to display"
|
||||
return
|
||||
fi
|
||||
(
|
||||
cd $DIR
|
||||
set +e
|
||||
|
|
Loading…
Add table
Reference in a new issue