Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 181
feat(ci): add UI E2E tests on GKE #21421
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: master
Are you sure you want to change the base?
Changes from all commits
d198431
c2f7bbd
726f686
566e4d4
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,140 @@ | ||
| name: Deploy StackRox | ||
| description: > | ||
| Deploys StackRox using roxie. Foreground (default): blocks until | ||
| ready, exports env vars. Background: returns immediately. Wait | ||
| with: wait $(cat /tmp/deploy-stackrox.pid) && source /tmp/roxie-env.sh | ||
| Log: /tmp/deploy-stackrox.log. | ||
|
|
||
| inputs: | ||
| tag: | ||
| description: Image tag to deploy | ||
| required: true | ||
| cluster-name: | ||
| description: Cluster name as seen by Sensor | ||
| default: remote | ||
| resources: | ||
| description: Resource sizing preset | ||
| default: small | ||
| roxie-version: | ||
| description: roxie release version | ||
| default: v0.4.0 | ||
| github-token: | ||
| description: GitHub token with access to stackrox/roxie | ||
| required: true | ||
| scanner: | ||
| description: "Scanner config: v4 (default), v2, or both" | ||
| default: v4 | ||
| registry-username: | ||
| description: "Registry username — sets REGISTRY_USERNAME for roxie" | ||
| default: "" | ||
| registry-password: | ||
| description: "Registry password — sets REGISTRY_PASSWORD for roxie" | ||
| default: "" | ||
| exposure: | ||
| description: "Service exposure: auto (default), none, loadbalancer, route" | ||
| default: "" | ||
| background: | ||
| description: Run deploy in background | ||
| default: "false" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install roxctl + roxie | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ inputs.github-token }} | ||
| run: | | ||
| set -x | ||
| if ! command -v roxctl >/dev/null 2>&1; then | ||
| docker pull -q --platform linux/amd64 "quay.io/stackrox-io/roxctl:${{ inputs.tag }}" | ||
| cid=$(docker create --platform linux/amd64 "quay.io/stackrox-io/roxctl:${{ inputs.tag }}" true) | ||
| docker cp "$cid:/usr/bin/roxctl" /usr/local/bin/roxctl | ||
| docker rm "$cid" >/dev/null | ||
| fi | ||
|
|
||
| arch=$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/') | ||
| os=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
| gh release download "${{ inputs.roxie-version }}" \ | ||
| --repo stackrox/roxie --pattern "roxie-${os}-${arch}" --dir /tmp --clobber | ||
| sudo install "/tmp/roxie-${os}-${arch}" /usr/local/bin/roxie | ||
| roxie version || echo "roxie install failed" | ||
|
|
||
| - name: Deploy StackRox | ||
| shell: bash | ||
| env: | ||
| INPUT_REGISTRY_USERNAME: ${{ inputs.registry-username }} | ||
| INPUT_REGISTRY_PASSWORD: ${{ inputs.registry-password }} | ||
| run: | | ||
| set +x | ||
| if [ -n "$INPUT_REGISTRY_USERNAME" ]; then | ||
| export REGISTRY_USERNAME="$INPUT_REGISTRY_USERNAME" | ||
| export REGISTRY_PASSWORD="$INPUT_REGISTRY_PASSWORD" | ||
| fi | ||
| export ROX_ADMIN_PASSWORD="$(openssl rand -base64 20)" | ||
| echo "::add-mask::${ROX_ADMIN_PASSWORD}" | ||
| echo "${ROX_ADMIN_PASSWORD}" > /tmp/rox-admin-password | ||
| export MAIN_IMAGE_TAG="${{ inputs.tag }}" | ||
|
|
||
| deploy() { | ||
| for _ in $(seq 1 120); do | ||
| kubectl cluster-info && break | ||
| sleep 2 | ||
| done | ||
|
|
||
| # Ensure kubeconfig is at the default path for tools that don't honor KUBECONFIG | ||
| echo "KUBECONFIG=${KUBECONFIG:-not set}" | ||
| if [ -n "${KUBECONFIG:-}" ] && [ ! -f "$HOME/.kube/config" ]; then | ||
| echo "Copying $KUBECONFIG to $HOME/.kube/config" | ||
| mkdir -p "$HOME/.kube" | ||
| cp "$KUBECONFIG" "$HOME/.kube/config" | ||
| elif [ -f "$HOME/.kube/config" ]; then | ||
| echo "Default kubeconfig already exists" | ||
| else | ||
| echo "WARNING: No KUBECONFIG set and no default kubeconfig" | ||
| fi | ||
|
|
||
| yq -n ".securedCluster.spec.clusterName = \"${{ inputs.cluster-name }}\"" > /tmp/roxie-override.yaml | ||
| case "${{ inputs.scanner }}" in | ||
| v2) yq -i '.central.spec.scanner.scannerComponent = "Enabled" | .central.spec.scannerV4.scannerComponent = "Disabled"' /tmp/roxie-override.yaml ;; | ||
| both) yq -i '.central.spec.scanner.scannerComponent = "Enabled"' /tmp/roxie-override.yaml ;; | ||
| esac | ||
|
|
||
| exposure_flag="" | ||
| if [ -n "${{ inputs.exposure }}" ]; then | ||
| exposure_flag="--exposure=${{ inputs.exposure }}" | ||
| fi | ||
|
|
||
| roxie deploy both \ | ||
| --resources=${{ inputs.resources }} \ | ||
| --single-namespace \ | ||
| --envrc /tmp/roxie-env.sh \ | ||
| --override /tmp/roxie-override.yaml \ | ||
| --tag ${{ inputs.tag }} \ | ||
| $exposure_flag | ||
|
|
||
| sed "s/^export //; s/['\"]//g" /tmp/roxie-env.sh >> "$GITHUB_ENV" | ||
| source /tmp/roxie-env.sh | ||
| echo "$API_ENDPOINT" > /tmp/rox-api-endpoint | ||
|
|
||
| echo "Generating API token (endpoint: ${API_ENDPOINT})..." | ||
| for attempt in $(seq 1 12); do | ||
| if curl -sk --connect-timeout 10 -u "admin:${ROX_ADMIN_PASSWORD}" \ | ||
| "https://${API_ENDPOINT}/v1/apitokens/generate" \ | ||
| -X POST -d '{"name":"ui_tests","role":"Admin"}' \ | ||
| | jq -r '.token' > /tmp/rox-auth-token && [ -s /tmp/rox-auth-token ]; then | ||
| echo "API token generated" | ||
| break | ||
| fi | ||
| echo "Attempt $attempt/12 failed, waiting 10s..." | ||
| sleep 10 | ||
| done | ||
|
|
||
| } | ||
|
|
||
| if [ "${{ inputs.background }}" = "true" ]; then | ||
| deploy > /tmp/deploy-stackrox.log 2>&1 & | ||
| echo $! > /tmp/deploy-stackrox.pid | ||
| else | ||
| deploy 2>&1 | tee /tmp/deploy-stackrox.log | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -910,6 +910,18 @@ jobs: | |
| message-id: build-images-ready | ||
| message-path: build-comment.md | ||
|
|
||
| ui-e2e: | ||
| needs: | ||
| - define-job-matrix | ||
| - push-main-manifests | ||
| if: >- | ||
| !cancelled() && needs.push-main-manifests.result == 'success' && | ||
| contains(github.event.pull_request.labels.*.name, 'e2e-ui-gke') | ||
| uses: ./.github/workflows/ui-e2e.yaml | ||
| with: | ||
| tag: ${{ needs.define-job-matrix.outputs.build-tag }} | ||
| secrets: inherit | ||
|
Comment on lines
+913
to
+923
Contributor
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. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win Add an explicit least-privilege This caller job runs with the default token permissions and forwards every secret via 🔒 Suggestion ui-e2e:
+ permissions:
+ contents: read
needs:
- define-job-matrix
- push-main-manifests🧰 Tools🪛 zizmor (1.26.1)[warning] 913-923: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) [warning] 920-920: secrets unconditionally inherited by called workflow (secrets-inherit): this reusable workflow (secrets-inherit) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| build-and-push-operator: | ||
| runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') || 'ubuntu-latest' }} | ||
| needs: | ||
|
|
||

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.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
sed-based env export is fragile.s/['\"]//gstrips every quote from values (not just wrapping quotes), and any multiline value would corrupt$GITHUB_ENV, which requires heredoc delimiters for multiline content. Ifroxie-env.shonly ever emits single-line, quote-free values this is safe; otherwise downstream steps will read truncated values.🤖 Prompt for AI Agents
Source: Linters/SAST tools