Skip to content
Open
Show file tree
Hide file tree
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
118 changes: 118 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Integration Test Matrix

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
pod_image:
description: 'Image to test for Pod lifecycle'
required: false
default: 'docker.io/library/alpine'
serverless_image:
description: 'Image to test for Serverless lifecycle'
required: false
default: 'fngarvin/ci-minimal-serverless@sha256:6a33a9bac95b8bc871725db9092af2922a7f1e3b63175248b2191b38be4e93a0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concern (supply chain): fngarvin/ci-minimal-serverless is hosted on a personal docker hub account. for CI pipelines that run on every PR to main, this creates a third-party dependency. if this image is compromised or removed, CI breaks or worse.

ideally this should be hosted under the runpod docker hub org (or ghcr.io/runpod). the pinned sha256 digest is a good practice though.


concurrency:
group: integration-tests-${{ github.ref_name }}
cancel-in-progress: true

jobs:
test-matrix:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
user_mode: [root, non-root]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.25.7'
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y wget curl coreutils jq bash tar grep sed
- name: Setup User for Mode
run: |
if [ "${{ matrix.user_mode }}" == "non-root" ]; then
# useradd is faster than the adduser Perl wrapper
sudo useradd -m -s /bin/bash tester
# Pre-create bin dir for the installer
sudo -u tester mkdir -p /home/tester/.local/bin

# Optimization: git checkout-index is instant compared to cp -r .
# it exports tracked files without the bulky .git folder (fixes 50s bottleneck)
mkdir -p /tmp/runpodctl-test
git checkout-index -a -f --prefix=/tmp/runpodctl-test/
sudo chown -R tester:tester /tmp/runpodctl-test
fi
- name: Build and Install runpodctl
run: |
# 1. Build the local PR version (the "new" code)
go build -o runpodctl main.go
chmod +x runpodctl

# 2. Run installer as the correct user to validate PORTABILITY logic
if [ "${{ matrix.user_mode }}" == "root" ]; then
sudo bash install.sh
else
# Ensure the installer sees the tester's local bin
sudo -u tester env "PATH=$PATH:/home/tester/.local/bin" bash install.sh
fi

# 3. Overwrite with PR code so the tests below are testing the REAL changes
if [ "${{ matrix.user_mode }}" == "root" ]; then
sudo cp -f runpodctl /usr/local/bin/runpodctl
sudo chmod +x /usr/local/bin/runpodctl
mkdir -p ~/go/bin && cp runpodctl ~/go/bin/runpodctl
else
# Update the tester's binaries and satisfy upstream hardcoded paths
sudo cp -f runpodctl /home/tester/.local/bin/runpodctl
sudo -u tester mkdir -p /home/tester/go/bin
sudo cp runpodctl /home/tester/go/bin/runpodctl
sudo chown tester:tester /home/tester/.local/bin/runpodctl /home/tester/go/bin/runpodctl
sudo chmod +x /home/tester/.local/bin/runpodctl /home/tester/go/bin/runpodctl
fi
- name: Run Go E2E Tests
env:
RUNPOD_API_KEY: ${{ secrets.RUNPOD_API_KEY }}
RUNPOD_TEST_POD_IMAGE: ${{ github.event.inputs.pod_image || 'docker.io/library/alpine' }}
RUNPOD_TEST_SERVERLESS_IMAGE: ${{ github.event.inputs.serverless_image || 'fngarvin/ci-minimal-serverless@sha256:6a33a9bac95b8bc871725db9092af2922a7f1e3b63175248b2191b38be4e93a0' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug (unused): RUNPOD_TEST_SERVERLESS_IMAGE is set here and wired through to the test, but the test never uses it — the serverless create uses --template-id instead. either remove this or update the test to actually use the image.

run: |
# Use -run to ONLY execute our safe tests, but ./e2e/... to ensure package compilation
TEST_PATTERN="^TestE2E_CLILifecycle"

if [ "${{ matrix.user_mode }}" == "root" ]; then
go test -tags e2e -v -run "$TEST_PATTERN" ./e2e/...
else
# Execute the tests as the tester user, preserving path and env
sudo -u tester env "PATH=$PATH" "RUNPOD_API_KEY=${{ secrets.RUNPOD_API_KEY }}" \
"RUNPOD_TEST_POD_IMAGE=${{ github.event.inputs.pod_image || 'docker.io/library/alpine' }}" \
"RUNPOD_TEST_SERVERLESS_IMAGE=${{ github.event.inputs.serverless_image || 'fngarvin/ci-minimal-serverless@sha256:6a33a9bac95b8bc871725db9092af2922a7f1e3b63175248b2191b38be4e93a0' }}" \
bash -c "cd /tmp/runpodctl-test && go test -tags e2e -v -run \"$TEST_PATTERN\" ./e2e/..."
fi
- name: Post-Run Cleanup (Emergency)
if: always()
env:
RUNPOD_API_KEY: ${{ secrets.RUNPOD_API_KEY }}
run: |
RP="./runpodctl"
if [ "${{ matrix.user_mode }}" == "non-root" ]; then
RP="/tmp/runpodctl-test/runpodctl"
fi

if [ -n "$RUNPOD_API_KEY" ]; then
echo "Ensuring safe sweeping of CI resources explicitly prefixed with 'ci-test-'..."
# Only delete pods named exactly starting with "ci-test-"
$RP pod list --output json 2>/dev/null | jq -r '.[] | select(.name | startswith("ci-test-")) | .id' | xargs -r -I {} $RP pod delete {} || true
$RP serverless list --output json 2>/dev/null | jq -r '.[] | select(.name | startswith("ci-test-")) | .id' | xargs -r -I {} $RP serverless delete {} || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should fix: the serverless test now creates templates with ci-test-tpl- prefix, but the emergency cleanup only sweeps pods and serverless endpoints. if the test fails between template creation and endpoint creation (or if t.Cleanup doesn't run), orphaned templates will be left behind.

add a line to clean up templates too:

$RP template list --output json 2>/dev/null | jq -r '.[] | select(.name | startswith("ci-test-")) | .id' | xargs -r -I {} $RP template delete {} || true

$RP template list --output json 2>/dev/null | jq -r '.[] | select(.name | startswith("ci-test-")) | .id' | xargs -r -I {} $RP template delete {} || true
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ vendor/

## auto generated file during make and release
version

# User built binaries
runpodctl
Loading