|
| 1 | +# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Integration Tests - GCP |
| 16 | + |
| 17 | +on: |
| 18 | + workflow_dispatch: {} # allow manual runs for testing |
| 19 | + schedule: |
| 20 | + - cron: '30 14 * * *' # daily at 14:30 UTC, runs on default branch only |
| 21 | + push: |
| 22 | + branches: |
| 23 | + - main |
| 24 | + - feature/oidc-gcp |
| 25 | + |
| 26 | +permissions: |
| 27 | + contents: read |
| 28 | + actions: read |
| 29 | + id-token: write |
| 30 | + |
| 31 | +jobs: |
| 32 | + integration-test-gcp: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + timeout-minutes: 60 |
| 35 | + env: |
| 36 | + CSP: "gcp" |
| 37 | + PREFIX: "nvs" |
| 38 | + PROJECT_ID: "nv-dgxck8s-20250306" |
| 39 | + IDENTITY_PROVIDER: "projects/1015254933832/locations/global/workloadIdentityPools/github-pool/providers/github-provider" |
| 40 | + SERVICE_ACCOUNT: "github-actions-user" |
| 41 | + # Terraform Vars |
| 42 | + TF_VAR_deployment_id: "d${{ github.run_id }}" |
| 43 | + TF_VAR_project_id: "nv-dgxck8s-20250306" |
| 44 | + TF_VAR_region: "europe-west4" |
| 45 | + TF_VAR_zone: "europe-west4-b" |
| 46 | + TF_VAR_system_node_type: "e2-standard-4" |
| 47 | + TF_VAR_system_node_count: "3" |
| 48 | + TF_VAR_gpu_node_pool_name: "gpu-pool" |
| 49 | + TF_VAR_gpu_machine_type: "a3-megagpu-8g" |
| 50 | + TF_VAR_gpu_node_count: "1" |
| 51 | + TF_VAR_gpu_reservation_project: "nv-dgxcloudprodgsc-20240206" |
| 52 | + TF_VAR_gpu_reservation_name: "gsc-a3-megagpu-8g-shared-res-2" |
| 53 | + TF_VAR_gpu_driver_version: "INSTALLATION_DISABLED" |
| 54 | + TF_VAR_resource_labels: '{"environment":"test","team":"nvsentinel","managed_by":"terraform"}' |
| 55 | + # Debug |
| 56 | + SKIP_DELETE: "false" # skip cluster deletion |
| 57 | + TEST_TAG: "main-33c1d03" |
| 58 | + |
| 59 | + steps: |
| 60 | + # Checkout |
| 61 | + - name: Checkout |
| 62 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 63 | + |
| 64 | + # Terraform |
| 65 | + - name: Terraform |
| 66 | + uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 |
| 67 | + with: |
| 68 | + terraform_version: "1.13.5" |
| 69 | + |
| 70 | + # Auth |
| 71 | + - name: Get AuthN Token |
| 72 | + id: auth |
| 73 | + uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3 |
| 74 | + with: |
| 75 | + token_format: access_token |
| 76 | + workload_identity_provider: ${{ env.IDENTITY_PROVIDER }} |
| 77 | + service_account: "${{ env.SERVICE_ACCOUNT }}@${{ env.PROJECT_ID }}.iam.gserviceaccount.com" |
| 78 | + |
| 79 | + # Gcloud |
| 80 | + - name: Setup gcloud CLI |
| 81 | + uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1 |
| 82 | + |
| 83 | + # Cluster |
| 84 | + - name: Create Cluster |
| 85 | + id: cluster |
| 86 | + shell: bash |
| 87 | + continue-on-error: true |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + cd tests/uat/gcp/cluster |
| 91 | + terraform init |
| 92 | + terraform apply -auto-approve |
| 93 | +
|
| 94 | + # Connect |
| 95 | + - name: Connect to Cluster |
| 96 | + id: client |
| 97 | + if: steps.cluster.outcome == 'success' |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + set -euo pipefail |
| 101 | + echo "Installing GKE auth plugin..." |
| 102 | + gcloud components install gke-gcloud-auth-plugin --quiet --project ${{ env.TF_VAR_project_id }} |
| 103 | + echo "Getting cluster credentials..." |
| 104 | + gcloud container clusters get-credentials "${{ env.PREFIX }}-${{ env.TF_VAR_deployment_id }}" \ |
| 105 | + --zone ${{ env.TF_VAR_zone }} --project ${{ env.TF_VAR_project_id }} |
| 106 | +
|
| 107 | + # Image Tag |
| 108 | + - name: Compute ref name with short SHA |
| 109 | + id: ref-name |
| 110 | + run: | |
| 111 | + if [[ "${{ github.ref_type }}" == "tag" ]]; then |
| 112 | + SAFE_REF="${{ github.ref_name }}" |
| 113 | + elif [[ "${{ github.ref_name }}" == "main" ]]; then |
| 114 | + SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) |
| 115 | + SAFE_REF="${{ github.ref_name }}-${SHORT_SHA}" |
| 116 | + else |
| 117 | + SAFE_REF="${{ env.TEST_TAG }}" |
| 118 | + fi |
| 119 | + # Sanitize ref name: replace slashes with hyphens for Docker tag compatibility |
| 120 | + SAFE_REF=$(echo "$SAFE_REF" | sed 's/\//-/g') |
| 121 | + echo "value=$SAFE_REF" >> $GITHUB_OUTPUT |
| 122 | +
|
| 123 | + # Apps |
| 124 | + - name: Install NVS |
| 125 | + id: apps |
| 126 | + if: steps.client.outcome == 'success' |
| 127 | + shell: bash |
| 128 | + env: |
| 129 | + GCP_PROJECT_ID: "${{ env.PROJECT_ID }}" |
| 130 | + GCP_ZONE: "${{ env.TF_VAR_zone }}" |
| 131 | + GCP_SERVICE_ACCOUNT: "${{ env.SERVICE_ACCOUNT }}" |
| 132 | + NVSENTINEL_VERSION: "${{ steps.ref-name.outputs.value }}" |
| 133 | + run: | |
| 134 | + set -euxo pipefail |
| 135 | + tests/uat/install-apps.sh |
| 136 | +
|
| 137 | + # Test |
| 138 | + - name: Run UAT Tests |
| 139 | + id: tests |
| 140 | + if: steps.apps.outcome == 'success' |
| 141 | + shell: bash |
| 142 | + run: | |
| 143 | + set -euxo pipefail |
| 144 | + tests/uat/tests.sh |
| 145 | +
|
| 146 | + # Teardown |
| 147 | + - name: Destroy Cluster |
| 148 | + if: always() && steps.cluster.outcome != 'skipped' && env.SKIP_DELETE != 'true' |
| 149 | + shell: bash |
| 150 | + run: | |
| 151 | + set -euxo pipefail |
| 152 | + cd tests/uat/gcp/cluster |
| 153 | + terraform destroy -auto-approve |
| 154 | +
|
| 155 | + # Summary |
| 156 | + - name: Test Summary |
| 157 | + if: always() |
| 158 | + run: | |
| 159 | + echo "## Test Results" >> $GITHUB_STEP_SUMMARY |
| 160 | + echo "- Cluster: ${{ steps.cluster.outcome }}" >> $GITHUB_STEP_SUMMARY |
| 161 | + echo "- Connection: ${{ steps.client.outcome }}" >> $GITHUB_STEP_SUMMARY |
| 162 | + echo "- Apps: ${{ steps.apps.outcome }}" >> $GITHUB_STEP_SUMMARY |
| 163 | + echo "- Tests: ${{ steps.tests.outcome }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments