Skip to content

Commit ecaa0c9

Browse files
committed
Force DISABLE_AUTOMATIC_DEREGISTRATION to be true on reusable runners, add tests
1 parent b9c038d commit ecaa0c9

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ jobs:
7575
echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
7676
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
7777
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
78+
# test the edge case from deregistration on reusable runners
79+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
80+
-e DEBUG_ONLY=true \
81+
-e ACCESS_TOKEN=notreal \
82+
-e LABELS=linux,x64 \
83+
-e REPO_URL=https://github.com/octokode/test1 \
84+
-e RUNNER_NAME=sustainjane-runner-1 \
85+
-e RUNNER_SCOPE=repo \
86+
-e RUNNER_WORKDIR=/tmp/runner/work \
87+
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
88+
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
89+
${GH_RUNNER_IMAGE} 10
90+
if [ $? -ne 0 ]; then
91+
exit 1
92+
fi
7893
# test the base
7994
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
8095
# test the final image but with all defaults
@@ -163,6 +178,21 @@ jobs:
163178
echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
164179
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
165180
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
181+
# test the edge case from deregistration on reusable runners
182+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
183+
-e DEBUG_ONLY=true \
184+
-e ACCESS_TOKEN=notreal \
185+
-e LABELS=linux,x64 \
186+
-e REPO_URL=https://github.com/octokode/test1 \
187+
-e RUNNER_NAME=sustainjane-runner-1 \
188+
-e RUNNER_SCOPE=repo \
189+
-e RUNNER_WORKDIR=/tmp/runner/work \
190+
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
191+
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
192+
${GH_RUNNER_IMAGE} 10
193+
if [ $? -ne 0 ]; then
194+
exit 1
195+
fi
166196
# test the base
167197
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
168198
# test the final image but with all defaults

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ jobs:
7777
echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
7878
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
7979
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
80+
# test the edge case from deregistration on reusable runners
81+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
82+
-e DEBUG_ONLY=true \
83+
-e ACCESS_TOKEN=notreal \
84+
-e LABELS=linux,x64 \
85+
-e REPO_URL=https://github.com/octokode/test1 \
86+
-e RUNNER_NAME=sustainjane-runner-1 \
87+
-e RUNNER_SCOPE=repo \
88+
-e RUNNER_WORKDIR=/tmp/runner/work \
89+
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
90+
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
91+
${GH_RUNNER_IMAGE} 10
92+
if [ $? -ne 0 ]; then
93+
exit 1
94+
fi
8095
# test the base
8196
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
8297
# test the final image but with all defaults
@@ -168,6 +183,21 @@ jobs:
168183
echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
169184
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
170185
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
186+
# test the edge case from deregistration on reusable runners
187+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_reusage_fail.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
188+
-e DEBUG_ONLY=true \
189+
-e ACCESS_TOKEN=notreal \
190+
-e LABELS=linux,x64 \
191+
-e REPO_URL=https://github.com/octokode/test1 \
192+
-e RUNNER_NAME=sustainjane-runner-1 \
193+
-e RUNNER_SCOPE=repo \
194+
-e RUNNER_WORKDIR=/tmp/runner/work \
195+
-e DISABLE_AUTOMATIC_DEREGISTRATION=false \
196+
-e CONFIGURED_ACTIONS_RUNNER_FILES_DIR=/runner/data \
197+
${GH_RUNNER_IMAGE} 10
198+
if [ $? -ne 0 ]; then
199+
exit 1
200+
fi
171201
# test the base
172202
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
173203
# test the final image but with all defaults

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ fi
210210

211211
if [[ -n "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
212212
echo "Reusage is enabled. Storing data to ${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
213+
if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
214+
echo "DISABLE_AUTOMATIC_DEREGISTRATION should be set to true to avoid issues with re-using a deregistered runner."
215+
exit 1
216+
fi
213217
# Quoting (even with double-quotes) the regexp brokes the copying
214218
cp -p -r "/actions-runner/_diag" "/actions-runner/svc.sh" /actions-runner/.[^.]* "${_CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
215219
fi

goss_reusage_fail.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
command:
2+
/entrypoint.sh something:
3+
exit-status: 1
4+
stdout:
5+
- "Runner reusage is enabled"
6+
- "Copying previous data"
7+
- "The runner has already been configured"
8+
- "Reusage is enabled. Storing data to /runner/data"
9+
stderr: ""
10+
timeout: 2000

install_actions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ curl -L "https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSIO
1010
tar -zxf actions.tar.gz
1111
rm -f actions.tar.gz
1212
./bin/installdependencies.sh
13-
mkdir /_work
13+
mkdir -p /_work

0 commit comments

Comments
 (0)