-
Notifications
You must be signed in to change notification settings - Fork 56
Fng infra install fix v2 #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
293362f
94c89dd
5a7823b
3d64721
66b4194
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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' | ||
|
|
||
| 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' }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bug (unused): |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should fix: the serverless test now creates templates with 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,6 @@ vendor/ | |
|
|
||
| ## auto generated file during make and release | ||
| version | ||
|
|
||
| # User built binaries | ||
| runpodctl | ||
There was a problem hiding this comment.
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-serverlessis 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
runpoddocker hub org (or ghcr.io/runpod). the pinned sha256 digest is a good practice though.