Skip to content

Commit b40a120

Browse files
committed
Add setup action for installing spiceio in other workflows
Composite action that downloads a released spiceio binary, adds it to PATH, and starts the S3-to-SMB proxy in the background. Usage from another repo: - uses: spiceai/spiceio/.github/actions/setup@trunk with: smb-server: 192.168.3.148 smb-user: runner smb-pass: ${{ secrets.UNAS_SMB_PASS }} smb-share: ai_platform_dev Outputs the endpoint URL and PID for use in subsequent steps.
1 parent 406cbaf commit b40a120

1 file changed

Lines changed: 131 additions & 0 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Setup spiceio
2+
description: Install a released version of spiceio and start the S3-to-SMB proxy
3+
4+
inputs:
5+
version:
6+
description: Release tag to install (e.g. "v0.1.0"). Defaults to latest.
7+
required: false
8+
default: latest
9+
smb-server:
10+
description: SMB server hostname or IP
11+
required: true
12+
smb-user:
13+
description: SMB username
14+
required: true
15+
smb-pass:
16+
description: SMB password
17+
required: true
18+
smb-share:
19+
description: SMB share name
20+
required: true
21+
smb-port:
22+
description: SMB port
23+
required: false
24+
default: "445"
25+
smb-domain:
26+
description: SMB domain
27+
required: false
28+
default: ""
29+
bucket:
30+
description: Virtual S3 bucket name
31+
required: false
32+
default: spiceio
33+
region:
34+
description: AWS region to advertise
35+
required: false
36+
default: us-east-1
37+
bind:
38+
description: Listen address for the S3 endpoint
39+
required: false
40+
default: "127.0.0.1:8333"
41+
token:
42+
description: GitHub token for downloading release assets
43+
required: false
44+
default: ${{ github.token }}
45+
46+
outputs:
47+
endpoint:
48+
description: The S3-compatible endpoint URL
49+
value: ${{ steps.start.outputs.endpoint }}
50+
pid:
51+
description: PID of the spiceio background process
52+
value: ${{ steps.start.outputs.pid }}
53+
54+
runs:
55+
using: composite
56+
steps:
57+
- name: Download spiceio binary
58+
id: download
59+
shell: bash
60+
env:
61+
GH_TOKEN: ${{ inputs.token }}
62+
VERSION: ${{ inputs.version }}
63+
run: |
64+
set -euo pipefail
65+
66+
REPO="spiceai/spiceio"
67+
INSTALL_DIR="${RUNNER_TEMP:-/tmp}/spiceio-bin"
68+
mkdir -p "$INSTALL_DIR"
69+
70+
if [[ "$VERSION" == "latest" ]]; then
71+
TAG=$(gh release view --repo "$REPO" --json tagName -q .tagName)
72+
else
73+
TAG="$VERSION"
74+
fi
75+
76+
OS=$(uname -s)
77+
ARCH=$(uname -m)
78+
# Map to GitHub runner naming
79+
case "$ARCH" in
80+
arm64|aarch64) ARCH="ARM64" ;;
81+
x86_64) ARCH="X64" ;;
82+
esac
83+
84+
ASSET="spiceio-${OS}-${ARCH}.tar.gz"
85+
echo "Downloading $ASSET from $REPO@$TAG"
86+
87+
gh release download "$TAG" --repo "$REPO" --pattern "$ASSET" --dir "$INSTALL_DIR"
88+
tar xzf "$INSTALL_DIR/$ASSET" -C "$INSTALL_DIR"
89+
chmod +x "$INSTALL_DIR/spiceio"
90+
91+
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
92+
echo "bin=$INSTALL_DIR/spiceio" >> "$GITHUB_OUTPUT"
93+
94+
- name: Start spiceio
95+
id: start
96+
shell: bash
97+
env:
98+
SPICEIO_SMB_SERVER: ${{ inputs.smb-server }}
99+
SPICEIO_SMB_PORT: ${{ inputs.smb-port }}
100+
SPICEIO_SMB_USER: ${{ inputs.smb-user }}
101+
SPICEIO_SMB_PASS: ${{ inputs.smb-pass }}
102+
SPICEIO_SMB_DOMAIN: ${{ inputs.smb-domain }}
103+
SPICEIO_SMB_SHARE: ${{ inputs.smb-share }}
104+
SPICEIO_BUCKET: ${{ inputs.bucket }}
105+
SPICEIO_REGION: ${{ inputs.region }}
106+
SPICEIO_BIND: ${{ inputs.bind }}
107+
run: |
108+
set -euo pipefail
109+
110+
ENDPOINT="http://${SPICEIO_BIND}"
111+
112+
spiceio &
113+
PID=$!
114+
echo "pid=$PID" >> "$GITHUB_OUTPUT"
115+
echo "endpoint=$ENDPOINT" >> "$GITHUB_OUTPUT"
116+
117+
# Wait for readiness
118+
echo "Waiting for spiceio on ${SPICEIO_BIND}..."
119+
for i in $(seq 1 30); do
120+
if curl -sf -o /dev/null "$ENDPOINT/" 2>/dev/null; then
121+
echo "spiceio ready at $ENDPOINT (PID $PID)"
122+
exit 0
123+
fi
124+
if ! kill -0 "$PID" 2>/dev/null; then
125+
echo "::error::spiceio exited unexpectedly"
126+
exit 1
127+
fi
128+
sleep 1
129+
done
130+
echo "::error::spiceio failed to start within 30s"
131+
exit 1

0 commit comments

Comments
 (0)