Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: 'Begin Testbox'
description: 'Initialize a Blacksmith Testbox session. Phones home to receive config, installs SSH key and rsync.'

Check warning on line 2 in action.yml

View workflow job for this annotation

GitHub Actions / validate

2:81 [line-length] line too long (114 > 80 characters)

inputs:
testbox_id:
description: 'Testbox session ID (from workflow_dispatch input). Leave empty for validation mode.'

Check warning on line 6 in action.yml

View workflow job for this annotation

GitHub Actions / validate

6:81 [line-length] line too long (102 > 80 characters)
required: false
default: ''
api_url:
description: 'Override the backend API URL (default: discovered from VM metadata)'

Check warning on line 10 in action.yml

View workflow job for this annotation

GitHub Actions / validate

10:81 [line-length] line too long (86 > 80 characters)
required: false

runs:
Expand All @@ -17,7 +17,7 @@
shell: bash
run: |
if [ -z "${{ inputs.testbox_id }}" ]; then
echo "::notice::Running in validation mode — setup steps will be validated without starting a testbox session."

Check warning on line 20 in action.yml

View workflow job for this annotation

GitHub Actions / validate

20:81 [line-length] line too long (121 > 80 characters)
fi

- name: Discover metadata service
Expand All @@ -25,22 +25,22 @@
shell: bash
run: |
if [ -z "${BLACKSMITH_AGENT_ADDR:-}" ]; then
echo "::warning::BLACKSMITH_AGENT_ADDR is not set; testbox is only supported on Blacksmith runners. Skipping testbox setup."

Check warning on line 28 in action.yml

View workflow job for this annotation

GitHub Actions / validate

28:81 [line-length] line too long (134 > 80 characters)
echo "available=false" >> "$GITHUB_OUTPUT"
exit 0
fi
METADATA_PORT="${METADATA_PORT:-}"
if [ -z "$METADATA_PORT" ]; then
METADATA_PORT=$(tr ' ' '\n' < /proc/cmdline | grep '^metadata_port=' | cut -d'=' -f2 || true)

Check warning on line 34 in action.yml

View workflow job for this annotation

GitHub Actions / validate

34:81 [line-length] line too long (103 > 80 characters)
if [ -z "$METADATA_PORT" ]; then
echo "::warning::metadata_port not found in kernel cmdline; testbox is only supported on Blacksmith runners. Skipping testbox setup."

Check warning on line 36 in action.yml

View workflow job for this annotation

GitHub Actions / validate

36:81 [line-length] line too long (145 > 80 characters)
echo "available=false" >> "$GITHUB_OUTPUT"
exit 0
fi
export METADATA_PORT
fi
echo "available=true" >> "$GITHUB_OUTPUT"
echo "metadata_addr=${BLACKSMITH_AGENT_ADDR}:${METADATA_PORT}" >> "$GITHUB_OUTPUT"

Check warning on line 43 in action.yml

View workflow job for this annotation

GitHub Actions / validate

43:81 [line-length] line too long (90 > 80 characters)

- name: Phone home and configure testbox
if: steps.metadata.outputs.available == 'true' && inputs.testbox_id
Expand All @@ -54,11 +54,11 @@
mkdir -p "$STATE"
chmod 700 "$STATE"

INSTALLATION_MODEL_ID=$(curl -s --connect-timeout 2 --max-time 5 "http://${METADATA_ADDR}/installationModelID")

Check warning on line 57 in action.yml

View workflow job for this annotation

GitHub Actions / validate

57:81 [line-length] line too long (119 > 80 characters)
if [ -n "$API_URL_OVERRIDE" ]; then
API_URL="$API_URL_OVERRIDE"
else
API_URL=$(curl -s --connect-timeout 2 --max-time 5 "http://${METADATA_ADDR}/backendURL")

Check warning on line 61 in action.yml

View workflow job for this annotation

GitHub Actions / validate

61:81 [line-length] line too long (98 > 80 characters)
fi

# Piggyback on the VM's stickyDiskToken for phone-home authentication.
Expand All @@ -72,6 +72,13 @@
echo "::error::Could not read required metadata (backendURL, installationModelID, stickyDiskToken); the testbox cannot phone home."
exit 1
fi
# The agent publishes the literal "unset" when the backend did not mint a
# token for this VM. Fail here with a clear message instead of letting the
# backend reject it as an invalid token.
if [ "$AUTH_TOKEN" = "unset" ]; then
echo "::error::This VM was not issued an identity token (stickyDiskToken=unset), so the testbox cannot phone home. This runner image/region does not support Testbox yet; contact Blacksmith support."
exit 1
fi

if [ -n "$BLACKSMITH_HOSTNAME" ]; then
RUNNER_HOST="$BLACKSMITH_HOSTNAME"
Expand Down Expand Up @@ -202,4 +209,14 @@
if: steps.metadata.outputs.available == 'true' && inputs.testbox_id
shell: bash
run: |
which rsync || sudo apt-get install -y rsync
if command -v rsync >/dev/null 2>&1; then
exit 0
fi
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -y rsync
elif command -v brew >/dev/null 2>&1; then
brew install rsync
else
echo "::error::rsync is not installed and no supported package manager was found."
exit 1
fi
Loading