Skip to content
Snippets Groups Projects

feat: test fast runner on MR

Merged Sébastien Heurtematte requested to merge feat/fastdraft into main
Files
8
#*******************************************************************************
# Copyright (c) 2022 Eclipse Foundation and others.
# This program and the accompanying materials are made available
# under the terms of the Eclipse Public License 2.0
# which is available at http://www.eclipse.org/legal/epl-v20.html,
# or the MIT License which is available at https://opensource.org/licenses/MIT.
# SPDX-License-Identifier: EPL-2.0 OR MIT
#*******************************************************************************
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
org.eclipse.cbi.ef-grac/project.fullname: 'eclipsefdn.it.releng.gitlab-runner-as-code'
org.eclipse.cbi.ef-grac/project.shortname: 'gitlab-runner-as-code'
org.eclipse.cbi.ef-grac/project.namespace: 'eclipsefdn.it.releng'
namespace: 'ef-grac-eclipsefdn-it-releng-gitlab-runner-as-code'
name: ef-grac-eclipsefdn-it-releng-gitlab-runner-as-code-fastdraft-cm
data:
entrypoint: |
#!/bin/bash
set -e
[[ "$REGISTER_DEBUG" == "true" ]] && set -x
mkdir -p /home/gitlab-runner/.gitlab-runner/
cp /configmaps/config.toml /home/gitlab-runner/.gitlab-runner/
# Set up environment variables for cache
if [[ -f /secrets/accesskey && -f /secrets/secretkey ]]; then
export CACHE_S3_ACCESS_KEY=$(cat /secrets/accesskey)
export CACHE_S3_SECRET_KEY=$(cat /secrets/secretkey)
fi
if [[ -z "${REGISTRATION_TOKEN}" ]] && [[ -f /secrets/runner-registration-token ]]; then
export REGISTRATION_TOKEN=$(cat /secrets/runner-registration-token)
fi
# should use api : https://docs.gitlab.com/ee/api/runners.html#register-a-new-runner
#if [[ -z "${CI_SERVER_TOKEN}" ]] && [[ -f /secrets/runner-token ]]; then
# export CI_SERVER_TOKEN=$(cat /secrets/runner-token)
#fi
# Validate this also at runtime in case the user has set a custom secret
#if [[ ! -z "$CI_SERVER_TOKEN" && "1" -ne "1" ]]; then
# echo "Using a runner token with more than 1 replica is not supported."
# exit 1
#fi
# Register the runner
if ! sh /configmaps/register-the-runner; then
exit 1
fi
# Run pre-entrypoint-script
if ! bash /configmaps/pre-entrypoint-script; then
exit 1
fi
# Start the runner
exec /entrypoint run --user=gitlab-runner \
--working-directory=/home/gitlab-runner
config.toml: |
concurrent = 4
check_interval = 10
sentry_dsn = ""
config.template.toml: |
[[runners]]
environment = [
"TMPDIR=$CI_PROJECT_DIR.tmp",
"HOME=$CI_BUILDS_DIR",
"CI_RUNNER_PERSISTENT_STORAGE=/var/shared",
]
[runners.kubernetes]
[runners.kubernetes.pod_labels]
"gitlab/project_name"="${CI_PROJECT_NAME}"
"gitlab/project_path"="${CI_PROJECT_PATH_SLUG}"
[runners.kubernetes.pod_annotations]
"gitlab/branch_name"="${CI_BRANCH_NAME}"
"gitlab/commit_author"="${CI_COMMIT_AUTHOR}"
"gitlab/environment_name"="${CI_ENVIRONMENT_NAME}"
"gitlab/environment_slug"="${CI_ENVIRONMENT_SLUG}"
"gitlab/environment_tier"="${CI_ENVIRONMENT_TIER}"
"gitlab/job_author"="${GITLAB_USER_NAME}"
"gitlab/job_id"="${CI_JOB_ID}"
"gitlab/job_image"="${CI_JOB_IMAGE}"
"gitlab/job_name"="${CI_JOB_NAME}"
"gitlab/job_url"="$CI_JOB_URL"
"gitlab/pipeline_id"="${CI_PIPELINE_ID}"
"gitlab/pipeline_iid"="${CI_PIPELINE_IID}"
"gitlab/project_name"="${CI_PROJECT_NAME}"
"gitlab/project_path"="${CI_PROJECT_PATH_SLUG}"
"gitlab/runner_version"="${CI_RUNNER_VERSION}"
"gitlab/stage_name"="${CI_JOB_STAGE}"
"pod-cleanup.gitlab.com/ttl"="6h"
[[runners.kubernetes.volumes.pvc]]
name = "ef-grac-eclipsefdn-it-releng-gitlab-runner-as-code-nfs-pvc"
mount_path = "/var/shared"
[[runners.kubernetes.volumes.empty_dir]]
name = "repo"
mount_path = "/builds"
medium = "Memory"
register-the-runner: |
#!/bin/bash
[[ "$REGISTER_DEBUG" == "true" ]] && set -x
MAX_REGISTER_ATTEMPTS=30
for i in $(seq 1 "${MAX_REGISTER_ATTEMPTS}"); do
echo "Registration attempt ${i} of ${MAX_REGISTER_ATTEMPTS}"
/entrypoint register
retval=$?
if [ ${retval} = 0 ]; then
break
elif [ ${i} = ${MAX_REGISTER_ATTEMPTS} ]; then
exit 1
fi
sleep 5
done
exit 0
check-live: |
#!/bin/bash
if /usr/bin/pgrep -f .*register-the-runner; then
exit 0
elif /usr/bin/pgrep gitlab.*runner; then
exit 0
else
exit 1
fi
pre-entrypoint-script: |
Loading