|
| 1 | +name: Smoke Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - reopened |
| 11 | + - synchronize |
| 12 | + |
| 13 | +jobs: |
| 14 | + smoke: |
| 15 | + name: Run Smoke Tests |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 30 |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Go |
| 24 | + uses: actions/setup-go@v5 |
| 25 | + with: |
| 26 | + go-version-file: go.mod |
| 27 | + |
| 28 | + - name: Download dependencies |
| 29 | + run: go mod download |
| 30 | + |
| 31 | + - name: Create kind cluster |
| 32 | + uses: helm/kind-action@v1 |
| 33 | + with: |
| 34 | + cluster_name: stackrox-mcp-smoke |
| 35 | + |
| 36 | + - name: Checkout StackRox repository |
| 37 | + uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + repository: stackrox/stackrox |
| 40 | + path: stackrox-repo |
| 41 | + |
| 42 | + - name: Deploy StackRox Central |
| 43 | + env: |
| 44 | + MAIN_IMAGE_TAG: latest |
| 45 | + SENSOR_HELM_DEPLOY: "true" |
| 46 | + ROX_SCANNER_V4: "false" |
| 47 | + ADMISSION_CONTROLLER: "false" |
| 48 | + SCANNER_REPLICAS: "0" |
| 49 | + COLLECTION_METHOD: "no_collection" |
| 50 | + run: | |
| 51 | + cd stackrox-repo |
| 52 | + ./deploy/k8s/deploy-local.sh |
| 53 | +
|
| 54 | + - name: Wait for Central pods ready |
| 55 | + run: kubectl wait --for=condition=ready --timeout=180s pod -l app=central -n stackrox |
| 56 | + |
| 57 | + - name: Remove resource constraints from Sensor |
| 58 | + run: | |
| 59 | + # Use kubectl set resources to remove all resource constraints |
| 60 | + kubectl set resources deployment/sensor -n stackrox \ |
| 61 | + --requests=cpu=0,memory=0 \ |
| 62 | + --limits=cpu=0,memory=0 |
| 63 | +
|
| 64 | + # Delete sensor pods to force recreation with new (empty) resources |
| 65 | + kubectl delete pods -n stackrox -l app=sensor |
| 66 | +
|
| 67 | + # Wait a bit for pods to be deleted and recreated |
| 68 | + sleep 10 |
| 69 | +
|
| 70 | + # Wait for new pods to be ready |
| 71 | + kubectl wait --for=condition=ready --timeout=300s pod -l app=sensor -n stackrox |
| 72 | +
|
| 73 | + - name: Extract Central password |
| 74 | + id: extract-password |
| 75 | + run: | |
| 76 | + PASSWORD="$(cat stackrox-repo/deploy/k8s/central-deploy/password)" |
| 77 | + echo "::add-mask::${PASSWORD}" |
| 78 | + echo "password=${PASSWORD}" >> "$GITHUB_OUTPUT" |
| 79 | +
|
| 80 | + - name: Setup port-forward to Central |
| 81 | + run: stackrox-repo/scale/dev/port-forward.sh 8000 |
| 82 | + |
| 83 | + - name: Install go-junit-report |
| 84 | + run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 |
| 85 | + |
| 86 | + - name: Run smoke tests with JUnit output |
| 87 | + env: |
| 88 | + ROX_ENDPOINT: localhost:8000 |
| 89 | + ROX_PASSWORD: ${{ steps.extract-password.outputs.password }} |
| 90 | + run: | |
| 91 | + go test -v -tags=smoke -cover -race -coverprofile=coverage-smoke.out -timeout=20m ./smoke 2>&1 | \ |
| 92 | + tee /dev/stderr | \ |
| 93 | + go-junit-report -set-exit-code -out junit-smoke.xml |
| 94 | +
|
| 95 | + - name: Upload JUnit test results |
| 96 | + if: always() |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + with: |
| 99 | + name: junit-smoke-results |
| 100 | + path: junit-smoke.xml |
| 101 | + if-no-files-found: error |
| 102 | + |
| 103 | + - name: Upload test results to Codecov |
| 104 | + if: always() |
| 105 | + uses: codecov/test-results-action@v1 |
| 106 | + with: |
| 107 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 108 | + files: junit-smoke.xml |
| 109 | + |
| 110 | + - name: Upload coverage to Codecov |
| 111 | + if: always() |
| 112 | + uses: codecov/codecov-action@v5 |
| 113 | + with: |
| 114 | + files: ./coverage-smoke.out |
| 115 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 116 | + fail_ci_if_error: false |
| 117 | + flags: smoke |
| 118 | + name: smoke-tests |
| 119 | + |
| 120 | + - name: Collect logs |
| 121 | + if: always() |
| 122 | + run: | |
| 123 | + mkdir -p logs |
| 124 | + kubectl get pods -A > logs/pods.txt || true |
| 125 | + kubectl get events -A --sort-by='.lastTimestamp' > logs/events.txt || true |
| 126 | + kubectl logs -n stackrox deployment/central > logs/central.log || true |
| 127 | +
|
| 128 | + - name: Upload logs |
| 129 | + if: always() |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + with: |
| 132 | + name: smoke-test-logs |
| 133 | + path: logs/ |
| 134 | + if-no-files-found: ignore |
0 commit comments