-
Notifications
You must be signed in to change notification settings - Fork 0
Add E2E test workflow. #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| name: E2E | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - 'dist/**' | ||
| schedule: | ||
| - cron: '0 5 * * 0' | ||
|
|
||
| jobs: | ||
| e2e: | ||
| if: github.event_name == 'push' && github_actor == 'roxbot' | ||
| name: E2E | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write # Required for the central-login action which we will test. | ||
| contents: read | ||
| env: | ||
| USE_GKE_GCLOUD_AUTH_PLUGIN: "True" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| repository: stackrox/stackrox | ||
| path: stackrox | ||
| fetch-depth: 0 # Required since we need to calculate the latest image tag with the existing tags. | ||
|
|
||
| - name: Setup kubectl | ||
| uses: azure/setup-kubectl@v3 | ||
|
|
||
| - name: Setup infractl | ||
| uses: stackrox/actions/infra/install-infractl@main | ||
|
|
||
| - name: Setup GCloud auth | ||
| uses: "google-github-actions/auth@v1" | ||
| with: | ||
| credentials_json: "${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}" | ||
|
|
||
| - name: Setup GCloud auth plugin | ||
| uses: "google-github-actions/setup-gcloud@v1" | ||
| with: | ||
| install_components: "gke-gcloud-auth-plugin" | ||
|
|
||
| - name: Create GKE infra cluster | ||
| uses: stackrox/actions/infra/create-cluster@v1.0.9 | ||
| with: | ||
| token: ${{ secrets.INFRA_TOKEN }} | ||
| flavor: gke-default | ||
| name: central-login-${{ github.run_id }} | ||
| lifespan: 20m | ||
| wait: "true" | ||
| no-slack: "true" | ||
|
|
||
| - name: Deploy Central to infra cluster | ||
| env: | ||
| CLUSTER_NAME: central-login-${{ github.run_id }} | ||
| INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }} | ||
| ARTIFACTS_DIR: ${{ runner.temp }}/gke-artifacts | ||
| run: | | ||
| # Fetch the artifacts for the GKE cluster. | ||
| infractl artifacts --download-dir=${ARTIFACTS_DIR} ${CLUSTER_NAME} | ||
|
|
||
| # Setup context for GKE cluster. | ||
| echo "KUBECONFIG=${ARTIFACTS_DIR}/kubeconfig" >> $GITHUB_ENV | ||
| export KUBECONFIG=${ARTIFACTS_DIR}/kubeconfig | ||
|
|
||
| # Kill port-forwards from earlier runs. | ||
| pkill -f kubectl'.*port-forward.*' || true | ||
| pkill -9 -f kubectl'.*port-forward.*' || true | ||
|
|
||
| # Deploy Central via deploy scripts. | ||
| cd stackrox | ||
| MONITORING_SUPPORT=false ./deploy/central.sh | ||
| kubectl set env -n stackrox deploy/central ROX_AUTH_MACHINE_TO_MACHINE=true | ||
|
|
||
| # Kill port-forwards from the initial deploy. | ||
| pkill -f kubectl'.*port-forward.*' || true | ||
| pkill -9 -f kubectl'.*port-forward.*' || true | ||
|
|
||
| ./deploy/k8s/central-deploy/central/scripts/port-forward.sh 8000 | ||
|
dhaus67 marked this conversation as resolved.
|
||
|
|
||
| echo "ROX_PASSWORD=$(cat deploy/k8s/central-deploy/password)" >> $GITHUB_ENV | ||
|
|
||
| - name: Wait for Central to be ready | ||
| run: | | ||
| cd stackrox | ||
| export USE_MIDSTREAM_IMAGES=false # Required for wait_for_api to be set. | ||
| source "tests/e2e/lib.sh" | ||
| wait_for_api | ||
|
|
||
| - name: Add machine to machine configuration in Central | ||
| run: | | ||
| curl -u admin:${ROX_PASSWORD} \ | ||
| https://localhost:8000/v1/auth/m2m \ | ||
|
janisz marked this conversation as resolved.
|
||
| -k -d '{"config": {"type": "GITHUB_ACTIONS", "tokenExpirationDuration": "5m", "mappings":[{"key":"sub","valueExpression":"repo:stackrox/central-login.*", "role":"Analyst"}]}}' | ||
|
|
||
| - name: Run central-login action | ||
| uses: ./ | ||
| with: | ||
| endpoint: https://localhost:8000 | ||
| skip-tls-verify: true | ||
|
|
||
| - name: Fetch roxctl and run roxctl central whoami | ||
| run: | | ||
| curl -k -u admin:${ROX_PASSWORD} https://localhost:8000/api/cli/download/roxctl-linux --output ./roxctl | ||
|
dhaus67 marked this conversation as resolved.
|
||
| chmod +x ./roxctl | ||
| echo $ROX_ENDPOINT | ||
| ./roxctl central whoami | ||
|
janisz marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.