summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Wittig <max.wittig95@gmail.com>2019-06-10 19:09:18 +0200
committerMax Wittig <max.wittig95@gmail.com>2019-06-10 20:09:41 +0200
commit7040b4c207975f9a4ad3ea7d14d4c8c57e901188 (patch)
treee07dec83fa696eab71fbe3941327e05feb2f960d
parente45a6e2618db30834f732c5a7bc9f1c038c45c31 (diff)
downloadgitlab-chore/fix-ci-travis.tar.gz
chore(ci): fix travis testschore/fix-ci-travis
-rw-r--r--.travis.yml9
-rwxr-xr-xtools/build_test_env.sh3
-rw-r--r--tools/docker-compose.test.yml16
-rwxr-xr-xtools/docker-entrypoint18
-rwxr-xr-xtools/init101
-rw-r--r--tools/test.rb11
6 files changed, 155 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml
index 1e9cc4d..08c679f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,5 +8,14 @@ env:
- TOX_ENV=cli_func_v4
install:
- pip install tox
+before_script:
+ ## Spin up container
+ - cd tools/
+ - docker-compose -f docker-compose.test.yml up -d
+ - sleep 260
+ - export PERSONAL_ACCESS_TOKEN=$(docker exec -it gitlab bash -lc 'printf "%q" "${PERSONAL_ACCESS_TOKEN}"')
+ - export GITLAB_URL=$(docker exec -it gitlab bash -lc 'printf "%q" "${GITLAB_URL}"')
+ - echo $GITLAB_URL
+ - echo $PERSONAL_ACCESS_TOKEN
script:
- tox -e $TOX_ENV
diff --git a/tools/build_test_env.sh b/tools/build_test_env.sh
index 3185f72..29c16be 100755
--- a/tools/build_test_env.sh
+++ b/tools/build_test_env.sh
@@ -76,9 +76,6 @@ cleanup() {
trap 'exit 1' HUP INT TERM
}
-try docker run --name gitlab-test --detach --publish 8080:80 \
- --publish 2222:22 pythongitlab/test-python-gitlab:latest >/dev/null
-
LOGIN='root'
PASSWORD='5iveL!fe'
GITLAB() { gitlab --config-file "$CONFIG" "$@"; }
diff --git a/tools/docker-compose.test.yml b/tools/docker-compose.test.yml
new file mode 100644
index 0000000..072ad73
--- /dev/null
+++ b/tools/docker-compose.test.yml
@@ -0,0 +1,16 @@
+version: '3'
+services:
+ gitlab:
+ image: gitlab/gitlab-ce
+ container_name: gitlab
+ entrypoint: init/docker-entrypoint
+ environment:
+ - EXTERNAL_PORT=8080
+ - PERSONAL_ACCESS_TOKEN
+ ports:
+ - 8080:80
+ - 8443:443
+ volumes:
+ - ./docker-entrypoint:/init/docker-entrypoint
+ - ./init:/init/init
+ - ./test.rb:/init/test.rb
diff --git a/tools/docker-entrypoint b/tools/docker-entrypoint
new file mode 100755
index 0000000..d291220
--- /dev/null
+++ b/tools/docker-entrypoint
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+## Running the init logic for gitlab. See PR# for splitting this wrapper file into two pieces
+/bin/bash init/init
+
+echo Sleep for 30 seconds to ensure all services are running
+sleep 30
+
+echo Initalize test token and user
+PERSONAL_ACCESS_TOKEN="$(gitlab-rails r /init/test.rb)"
+GITLAB_URL="http://localhost:$EXTERNAL_PORT"
+
+echo "export PERSONAL_ACCESS_TOKEN=$PERSONAL_ACCESS_TOKEN" >> ~/.profile
+echo "export GITLAB_URL=$GITLAB_URL" >> ~/.profile
+
+echo Tail and wait
+gitlab-ctl tail&
+wait
diff --git a/tools/init b/tools/init
new file mode 100755
index 0000000..a02d7b7
--- /dev/null
+++ b/tools/init
@@ -0,0 +1,101 @@
+#!/bin/bash
+set -e
+
+function sigterm_handler() {
+ echo "SIGTERM signal received, try to gracefully shutdown all services..."
+ gitlab-ctl stop
+}
+
+function failed_pg_upgrade() {
+ echo 'Upgrading the existing database to 9.6 failed and was reverted.'
+ echo 'Please check the output, and open an issue at:'
+ echo 'https://gitlab.com/gitlab-org/omnibus-gitlab/issues'
+ echo 'If you would like to restart the instance without attempting to'
+ echo 'upgrade, add the following to your docker command:'
+ echo '-e GITLAB_SKIP_PG_UPGRADE=true'
+ exit 1
+}
+
+trap "sigterm_handler; exit" TERM
+
+source /RELEASE
+echo "Thank you for using GitLab Docker Image!"
+echo "Current version: $RELEASE_PACKAGE=$RELEASE_VERSION"
+echo ""
+if [[ "$PACKAGECLOUD_REPO" == "unstable" ]]; then
+ echo "You are using UNSTABLE version of $RELEASE_PACKAGE!"
+ echo ""
+fi
+echo "Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file"
+echo "And restart this container to reload settings."
+echo "To do it use docker exec:"
+echo
+echo " docker exec -it gitlab vim /etc/gitlab/gitlab.rb"
+echo " docker restart gitlab"
+echo
+echo "For a comprehensive list of configuration options please see the Omnibus GitLab readme"
+echo "https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md"
+echo
+echo "If this container fails to start due to permission problems try to fix it by executing:"
+echo
+echo " docker exec -it gitlab update-permissions"
+echo " docker restart gitlab"
+echo
+sleep 3s
+
+# Copy gitlab.rb for the first time
+if [[ ! -e /etc/gitlab/gitlab.rb ]]; then
+ echo "Installing gitlab.rb config..."
+ cp /opt/gitlab/etc/gitlab.rb.template /etc/gitlab/gitlab.rb
+ chmod 0600 /etc/gitlab/gitlab.rb
+fi
+
+# Generate ssh host key for the first time
+if [[ ! -f /etc/gitlab/ssh_host_rsa_key ]]; then
+ echo "Generating ssh_host_rsa_key..."
+ ssh-keygen -f /etc/gitlab/ssh_host_rsa_key -N '' -t rsa
+ chmod 0600 /etc/gitlab/ssh_host_rsa_key
+fi
+if [[ ! -f /etc/gitlab/ssh_host_ecdsa_key ]]; then
+ echo "Generating ssh_host_ecdsa_key..."
+ ssh-keygen -f /etc/gitlab/ssh_host_ecdsa_key -N '' -t ecdsa
+ chmod 0600 /etc/gitlab/ssh_host_ecdsa_key
+fi
+if [[ ! -f /etc/gitlab/ssh_host_ed25519_key ]]; then
+ echo "Generating ssh_host_ed25519_key..."
+ ssh-keygen -f /etc/gitlab/ssh_host_ed25519_key -N '' -t ed25519
+ chmod 0600 /etc/gitlab/ssh_host_ed25519_key
+fi
+
+# Remove all services, the reconfigure will create them
+echo "Preparing services..."
+rm -f /opt/gitlab/service/*
+ln -s /opt/gitlab/sv/sshd /opt/gitlab/service
+ln -sf /opt/gitlab/embedded/bin/sv /opt/gitlab/init/sshd
+mkdir -p /var/log/gitlab/sshd
+
+# Start service manager
+echo "Starting services..."
+GITLAB_OMNIBUS_CONFIG= /opt/gitlab/embedded/bin/runsvdir-start &
+
+# Configure gitlab package
+# WARNING:
+# the preinst script has the database backup
+# It will not be executed, because all services are not yet started
+# They will be started when `reconfigure` is executed
+echo "Configuring GitLab package..."
+/var/lib/dpkg/info/${RELEASE_PACKAGE}.preinst upgrade
+
+echo "Configuring GitLab..."
+gitlab-ctl reconfigure
+
+# Make sure PostgreSQL is at the latest version.
+# If it fails, print a message with a workaround and exit
+if [ "${GITLAB_SKIP_PG_UPGRADE}" != true ]; then
+ gitlab-ctl pg-upgrade -w || failed_pg_upgrade
+fi
+
+if [ -n "${GITLAB_POST_RECONFIGURE_SCRIPT+x}" ]; then
+ echo "Runnning Post Reconfigure Script..."
+ eval "${GITLAB_POST_RECONFIGURE_SCRIPT}"
+fi
diff --git a/tools/test.rb b/tools/test.rb
new file mode 100644
index 0000000..80dc331
--- /dev/null
+++ b/tools/test.rb
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+u = User.first
+u.password_automatically_set = false
+u.password = 'password'
+u.password_confirmation = 'password'
+u.save!
+
+t = PersonalAccessToken.new({ user: u, name: 'node-gitlab', scopes: ['api']})
+t.save!
+
+puts t.token