debian-mirror-gitlab/qa/gdk/launch
2023-07-09 08:55:56 +05:30

39 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
COMMIT_REF=${1:-$CI_COMMIT_SHA}
RSPEC_ARGS=$2
if [ -z "${COMMIT_REF}" ]; then
echo "Please provide a commit ref with the code to be tested as the first argument"
exit 1
fi
# Set the GitLab license mode to "test" so that GitLab uses the appropriate encryption key
export GITLAB_LICENSE_MODE="test"
# Create the temporary directory that screenshots are saved to
sudo install -m 777 -d /home/gdk/gdk/gitlab/qa/tmp
# Update GDK
(cd .. ; gdk update ; cat gdk.yml)
# Reset, fetch, and checkout the GitLab repository with the code from the ref to be tested
git reset --hard
git fetch origin $COMMIT_REF
git checkout $COMMIT_REF
# Install the required gems
bundle install --jobs=$(nproc) --retry=3 --quiet
# Run the database migrations
bundle exec rake db:migrate
# Restart GDK to be sure any changes are accounted for in running services, start any stopped services, and wait until the GDK is reachable
(cd .. ; gdk restart ; ./support/test_url http://gdk.test:3000)
# Install the required gems in the QA directory
cd qa
bundle install --jobs=$(nproc) --retry=3 --quiet
# Run the tests
bundle exec bin/qa Test::Instance::All http://gdk.test:3000 -- $RSPEC_ARGS