Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
89 changes: 89 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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'

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

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.22'
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y wget curl coreutils jq bash tar grep sed
- name: Build runpodctl for Testing
run: |
go build -o runpodctl main.go
chmod +x runpodctl
- name: Setup Non-Root User and Workspace
if: matrix.user_mode == 'non-root'
run: |
sudo adduser --disabled-password --gecos "" tester
sudo mkdir -p /tmp/runpodctl-test
sudo cp -r . /tmp/runpodctl-test/
sudo chown -R tester:tester /tmp/runpodctl-test
- name: Run Unified 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' }}
run: |
if [ "${{ matrix.user_mode }}" == "root" ]; then
go test -tags e2e -v ./e2e/cli_lifecycle_test.go
else
# Debug info
echo "Runner user: $(whoami)"
echo "Go path: $(which go)"
go version

# 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 ./e2e/cli_lifecycle_test.go"
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
fi
Loading