Skip to content

Commit

Permalink
Force DISABLE_AUTOMATIC_DEREGISTRATION to be true on reusable runners…
Browse files Browse the repository at this point in the history
…, add tests
  • Loading branch information
myoung34 committed Feb 24, 2025
1 parent b9c038d commit 9ed37bc
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ jobs:
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
debian_base_tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -133,6 +136,9 @@ jobs:
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
ubuntu_base_latest_deploy:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,31 @@ jobs:
echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
# test the edge case from deregistration on reusable runners
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
-e DEBUG_ONLY=true \
-e ACCESS_TOKEN=notreal \
-e LABELS=linux,x64 \
-e REPO_URL=https://github.com/octokode/test1 \
-e RUNNER_NAME=sustainjane-runner-1 \
-e RUNNER_SCOPE=repo \
-e RUNNER_WORKDIR=/tmp/runner/work \
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the base
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the final image but with all defaults
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the final image but with non-default values
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
-e DEBUG_ONLY=true \
Expand All @@ -102,6 +123,9 @@ jobs:
-e EPHEMERAL=true \
-e DISABLE_AUTO_UPDATE=true \
${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
debian_tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -163,6 +187,21 @@ jobs:
echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
# test the edge case from deregistration on reusable runners
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
-e DEBUG_ONLY=true \
-e ACCESS_TOKEN=notreal \
-e LABELS=linux,x64 \
-e REPO_URL=https://github.com/octokode/test1 \
-e RUNNER_NAME=sustainjane-runner-1 \
-e RUNNER_SCOPE=repo \
-e RUNNER_WORKDIR=/tmp/runner/work \
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the base
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
# test the final image but with all defaults
Expand Down
40 changes: 39 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,31 @@ jobs:
echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
# test the edge case from deregistration on reusable runners
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
-e DEBUG_ONLY=true \
-e ACCESS_TOKEN=notreal \
-e LABELS=linux,x64 \
-e REPO_URL=https://github.com/octokode/test1 \
-e RUNNER_NAME=sustainjane-runner-1 \
-e RUNNER_SCOPE=repo \
-e RUNNER_WORKDIR=/tmp/runner/work \
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the base
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the final image but with all defaults
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the final image but with non-default values
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
-e DEBUG_ONLY=true \
Expand All @@ -104,7 +125,9 @@ jobs:
-e EPHEMERAL=true \
-e DISABLE_AUTO_UPDATE=true \
${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
debian_tests:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -168,6 +191,21 @@ jobs:
echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
# test the edge case from deregistration on reusable runners
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
-e DEBUG_ONLY=true \
-e ACCESS_TOKEN=notreal \
-e LABELS=linux,x64 \
-e REPO_URL=https://github.com/octokode/test1 \
-e RUNNER_NAME=sustainjane-runner-1 \
-e RUNNER_SCOPE=repo \
-e RUNNER_WORKDIR=/tmp/runner/work \
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
${GH_RUNNER_IMAGE} 10
if [ $? -ne 0 ]; then
exit 1
fi
# test the base
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
# test the final image but with all defaults
Expand Down
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ fi

if [[ -n "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
echo "Reusage is enabled. Storing data to ${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
echo "DISABLE_AUTOMATIC_DEREGISTRATION should be set to true to avoid issues with re-using a deregistered runner."
exit 1
fi
# Quoting (even with double-quotes) the regexp brokes the copying
cp -p -r "/actions-runner/_diag" "/actions-runner/svc.sh" /actions-runner/.[^.]* "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
fi
Expand Down
9 changes: 9 additions & 0 deletions goss_reusage_fail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
command:
/entrypoint.sh something:
exit-status: 1
stdout:
- "Runner reusage is enabled"
- "Reusage is enabled. Storing data to /runner/data"
- "DISABLE_AUTOMATIC_DEREGISTRATION should be set to true to avoid issues with re-using a deregistered runner."
stderr: ""
timeout: 2000
2 changes: 1 addition & 1 deletion install_actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ curl -L "https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSIO
tar -zxf actions.tar.gz
rm -f actions.tar.gz
./bin/installdependencies.sh
mkdir /_work
mkdir -p /_work

0 comments on commit 9ed37bc

Please sign in to comment.