Skip to content

Commit

Permalink
Add configurable timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonsturgeon committed Jan 15, 2024
1 parent 3d05034 commit efe0633
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ on:
required: false
description: "A GitHub Personal Access Token"

timeout:
type: string
required: false
description: "How many minutes to let the job run before killing the server (small projects shouldn't need more than 2 minutes)"
default: "2"

jobs:
test:
name: "Run tests"
Expand Down Expand Up @@ -125,6 +131,7 @@ jobs:
COLLECTION_ID: "${{ inputs.collection }}"
SSH_PRIVATE_KEY: "${{ inputs.ssh-private-key }}"
GITHUB_TOKEN: "${{ inputs.github-token }}"
TIMEOUT: "${{ inputs.timeout }}"

run: |
docker compose up --no-log-prefix --exit-code-from runner
Expand Down
3 changes: 2 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
runner:
image: ghcr.io/cfc-servers/gluatest:0.27-pre10
image: ghcr.io/cfc-servers/gluatest:0.27-pre11
build: .
container_name: gluatest_runner
stop_grace_period: 2s
Expand All @@ -27,3 +27,4 @@ services:
- COLLECTION_ID=$COLLECTION_ID
- SSH_PRIVATE_KEY=$SSH_PRIVATE_KEY
- GITHUB_TOKEN=$GITHUB_TOKEN
- TIMEOUT=${TIMEOUT-5}
5 changes: 3 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ home=/home/steam
gmodroot=$home/gmodserver
server=$home/gmodserver/garrysmod
pat=$GITHUB_TOKEN@
timeout=$TIMEOUT

# Make sure docker-slim doesn't remove bins we'll eventually need
echo $(date)
Expand Down Expand Up @@ -117,10 +118,10 @@ srcds_args=(
)
if [ "$GMOD_BRANCH" = "x86-64" ]; then
echo "Starting 64-bit server"
unbuffer timeout 5m "$gmodroot"/srcds_run_x64 "${srcds_args[@]}"
unbuffer timeout "$TIMEOUT"m "$gmodroot"/srcds_run_x64 "${srcds_args[@]}"
else
echo "Starting 32-bit server"
unbuffer timeout 5m "$gmodroot"/srcds_run "${srcds_args[@]}"
unbuffer timeout "$TIMEOUT"m "$gmodroot"/srcds_run "${srcds_args[@]}"
fi

status=$?
Expand Down

0 comments on commit efe0633

Please # to comment.