This commit is contained in:
Yusuke Kuoka 2025-10-21 00:49:26 -07:00 committed by GitHub
commit 67aafe3d31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 160 additions and 211 deletions

View File

@ -77,7 +77,9 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \
&& chmod +x /usr/bin/dumb-init
ENV RUNNER_ASSETS_DIR=/runnertmp
# Set this to /home/runner for compatibility with v1 runners
ARG RUNNER_ASSETS_DIR=/runnertmp
ENV RUNNER_ASSETS_DIR=$RUNNER_ASSETS_DIR
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \

View File

@ -55,7 +55,9 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \
&& chmod +x /usr/bin/dumb-init
ENV RUNNER_ASSETS_DIR=/runnertmp
# Set this to /home/runner for compatibility with v1 runners
ARG RUNNER_ASSETS_DIR=/runnertmp
ENV RUNNER_ASSETS_DIR=$RUNNER_ASSETS_DIR
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \

View File

@ -72,7 +72,9 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \
&& chmod +x /usr/bin/dumb-init
ENV RUNNER_ASSETS_DIR=/runnertmp
# Set this to /home/runner for compatibility with v1 runners
ARG RUNNER_ASSETS_DIR=/runnertmp
ENV RUNNER_ASSETS_DIR=$RUNNER_ASSETS_DIR
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \

View File

@ -48,7 +48,9 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \
&& chmod +x /usr/bin/dumb-init
ENV RUNNER_ASSETS_DIR=/runnertmp
# Set this to /home/runner for compatibility with v1 runners
ARG RUNNER_ASSETS_DIR=/runnertmp
ENV RUNNER_ASSETS_DIR=$RUNNER_ASSETS_DIR
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \

View File

@ -68,7 +68,10 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \
&& chmod +x /usr/bin/dumb-init
ENV RUNNER_ASSETS_DIR=/runnertmp
# Set this to /home/runner for compatibility with v1 runners
ARG RUNNER_ASSETS_DIR=/runnertmp
ENV RUNNER_ASSETS_DIR=$RUNNER_ASSETS_DIR
ARG EXTERNALS_DIR_NAME=externalstmp
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \
@ -77,7 +80,7 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& tar xzf ./runner.tar.gz \
&& rm runner.tar.gz \
&& ./bin/installdependencies.sh \
&& mv ./externals ./externalstmp \
&& if [ "${EXTERNALS_DIR_NAME}" != externals ]; then mv ./externals ./${EXTERNALS_DIR_NAME}; fi \
# libyaml-dev is required for ruby/setup-ruby action.
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own.

View File

@ -45,7 +45,11 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& curl -fLo /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${ARCH} \
&& chmod +x /usr/bin/dumb-init
ENV RUNNER_ASSETS_DIR=/runnertmp
# Set this to /home/runner for compatibility with v1 runners
ARG RUNNER_ASSETS_DIR=/runnertmp
ENV RUNNER_ASSETS_DIR=$RUNNER_ASSETS_DIR
# Set this to "externals" for compatibility with v1 runners
ARG EXTERNALS_DIR_NAME=externalstmp
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x64 ; fi \
&& mkdir -p "$RUNNER_ASSETS_DIR" \
@ -54,7 +58,7 @@ RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
&& tar xzf ./runner.tar.gz \
&& rm runner.tar.gz \
&& ./bin/installdependencies.sh \
&& mv ./externals ./externalstmp \
&& if [ "${EXTERNALS_DIR_NAME}" != externals ]; then mv ./externals ./${EXTERNALS_DIR_NAME}; fi \
# libyaml-dev is required for ruby/setup-ruby action.
# It is installed after installdependencies.sh and before removing /var/lib/apt/lists
# to avoid rerunning apt-update on its own.

View File

@ -16,6 +16,18 @@ if [ -n "${STARTUP_DELAY_IN_SECONDS}" ]; then
sleep "${STARTUP_DELAY_IN_SECONDS}"
fi
if ! cd "${RUNNER_HOME}"; then
log.error "Failed to cd into ${RUNNER_HOME}"
exit 1
fi
# past that point, it's all relative pathes from /runner
# This is for registering ARC v0 runners.
# ARC v1 runners do not need config.sh for registering themselves.
# ARC v1 runners are supposed to given the ACTIONS_RUNNER_INPUT_JITCONFIG envvars
# so we use it as the trigger to skip config.sh.
if [ -z "${ACTIONS_RUNNER_INPUT_JITCONFIG:-}" ]; then
if [ -z "${GITHUB_URL}" ]; then
log.debug 'Working with public GitHub'
GITHUB_URL="https://github.com/"
@ -71,13 +83,6 @@ if [[ "${UNITTEST:-}" == '' ]]; then
shopt -u dotglob
fi
if ! cd "${RUNNER_HOME}"; then
log.error "Failed to cd into ${RUNNER_HOME}"
exit 1
fi
# past that point, it's all relative pathes from /runner
config_args=()
if [ "${RUNNER_FEATURE_FLAG_ONCE:-}" != "true" ] && [ "${RUNNER_EPHEMERAL}" == "true" ]; then
config_args+=(--ephemeral)
@ -111,6 +116,12 @@ while [[ ${retries_left} -gt 0 ]]; do
sleep 1
done
# Note that ARC v1 runners do create this file, but only after the runner
# agent is up and running.
# On the other hand, this logic assumes the file to be created BEFORE
# the runner is up, by running `config.sh`, which is not present in a v1 runner deployment.
# That's why we need to skip this check for v1 runners.
# Otherwise v1 runner will never start up due to this check.
if [ ! -f .runner ]; then
# we couldn't configure and register the runner; no point continuing
log.error 'Configuration failed!'
@ -138,8 +149,12 @@ cat .runner
# -H "Accept: application/vnd.github.v3+json" \
# -H "Authorization: bearer ${GITHUB_TOKEN}"
# https://api.github.com/repos/USER/REPO/actions/runners/171
fi
# Hack due to the DinD volumes
# This is necessary only for legacy ARC v0.x.
# ARC v1.x uses the "externals" as the copy source and "tmpDir" as the copy destionation.
# See https://github.com/actions/actions-runner-controller/blob/91c8991835016f8c6568f101d4a28185baec3dcc/charts/gha-runner-scale-set/templates/_helpers.tpl#L76-L87
if [ -z "${UNITTEST:-}" ] && [ -e ./externalstmp ]; then
mkdir -p ./externals
mv ./externalstmp/* ./externals/

View File

@ -15,7 +15,7 @@ startup_log() {
}
log "Setting up test area"
export RUNNER_HOME=testarea
export RUNNER_HOME=$(pwd)/testarea
mkdir -p ${RUNNER_HOME}
log "Setting up the test config"
@ -49,7 +49,9 @@ log ""
# Run the runner startup script which as a final step runs this
# unit tests run.sh as it was symlinked
../../../runner/startup.sh 2> >(startup_log)
cd ../../../runner
export PATH=${PATH}:$(pwd)
./startup.sh 2> >(startup_log)
if [ "$?" != "2" ]; then
error "========================================="

View File

@ -15,7 +15,7 @@ startup_log() {
}
log "Setting up test area"
export RUNNER_HOME=testarea
export RUNNER_HOME=$(pwd)/testarea
mkdir -p ${RUNNER_HOME}
log "Setting up the test"
@ -49,7 +49,9 @@ log ""
# Run the runner entrypstartupoint script which as a final step runs this
# unit tests run.sh as it was symlinked
../../../runner/startup.sh 2> >(startup_log)
cd ../../../runner
export PATH=${PATH}:$(pwd)
./startup.sh 2> >(startup_log)
if [ "$?" != "0" ]; then
error "==========================================="

View File

@ -15,7 +15,7 @@ startup_log() {
}
log "Setting up test area"
export RUNNER_HOME=testarea
export RUNNER_HOME=$(pwd)/testarea
mkdir -p ${RUNNER_HOME}
log "Setting up the test"
@ -47,7 +47,9 @@ log ""
# Run the runner startup script which as a final step runs this
# unit tests run.sh as it was symlinked
../../../runner/startup.sh 2> >(startup_log)
cd ../../../runner
export PATH=${PATH}:$(pwd)
./startup.sh 2> >(startup_log)
if [ "$?" != "0" ]; then
error "=========================="

View File

@ -1,87 +0,0 @@
#!/usr/bin/env bash
# UNITTEST: should work disable update
# Will simulate a scneario where disableupdate=true. expects:
# - the configuration step to be run exactly once
# - the startup script to exit with no error
# - the config.sh script to run with the --disableupdate flag set to 'true'.
source ../assets/logging.sh
startup_log() {
while read I; do
printf "\tstartup.sh: $I\n"
done
}
log "Setting up test area"
export RUNNER_HOME=testarea
mkdir -p ${RUNNER_HOME}
log "Setting up the test"
export UNITTEST=true
export RUNNER_NAME="example_runner_name"
export RUNNER_REPO="myorg/myrepo"
export RUNNER_TOKEN="xxxxxxxxxxxxx"
export DISABLE_RUNNER_UPDATE="true"
# run.sh and config.sh get used by the runner's real entrypoint.sh and are part of actions/runner.
# We change symlink dummy versions so the entrypoint.sh can run allowing us to test the real entrypoint.sh
log "Symlink dummy config.sh and run.sh"
ln -s ../../assets/config.sh ${RUNNER_HOME}/config.sh
ln -s ../../assets/run.sh ${RUNNER_HOME}/run.sh
cleanup() {
rm -rf ${RUNNER_HOME}
unset UNITTEST
unset RUNNERHOME
unset RUNNER_NAME
unset RUNNER_REPO
unset RUNNER_TOKEN
}
# Always run cleanup when test ends regardless of how it ends
trap cleanup SIGINT SIGTERM SIGQUIT EXIT
log "Running the startup script"
log ""
# run.sh and config.sh get used by the runner's real startup.sh and are part of actions/runner.
# We change symlink dummy versions so the startup.sh can run allowing us to test the real entrypoint.sh
../../../runner/startup.sh 2> >(startup_log)
if [ "$?" != "0" ]; then
error "=========================="
error "FAIL | Test completed with errors"
exit 1
fi
log "Testing if the configuration step was run only once"
count=`cat ${RUNNER_HOME}/counter || echo "not_found"`
if [ ${count} != "1" ]; then
error "==============================================="
error "FAIL | The configuration step was not run exactly once"
exit 1
fi
success "PASS | The configuration ran ${count} time(s)"
log "Testing if the configuration included the --disableupdate flag"
if ! grep -q -- '--disableupdate' ${RUNNER_HOME}/runner_config; then
error "==============================================="
error "FAIL | The configuration should not include the --disableupdate flag"
exit 1
fi
success "PASS | The --disableupdate switch was included in the configuration"
log "Testing if run.sh ran"
if [ ! -f "${RUNNER_HOME}/run_sh_ran" ]; then
error "=============================="
error "FAIL | The runner service has not run"
exit 1
fi
success "PASS | run.sh ran"
success ""
success "==========================="
success "Test completed successfully"