|
63 | 63 | key: downloaded-${{ runner.os }}-${{ hashFiles('klone.yaml') }}-test-unit |
64 | 64 |
|
65 | 65 | - run: make -j test-unit test-helm |
| 66 | + |
| 67 | + test-e2e: |
| 68 | + if: contains(github.event.pull_request.labels.*.name, 'test-e2e') |
| 69 | + runs-on: ubuntu-latest |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + with: |
| 73 | + fetch-depth: 0 |
| 74 | + |
| 75 | + - uses: ./.github/actions/repo_access |
| 76 | + with: |
| 77 | + DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }} |
| 78 | + |
| 79 | + - name: Authenticate to Google Cloud |
| 80 | + id: auth |
| 81 | + uses: google-github-actions/auth@v2 |
| 82 | + with: |
| 83 | + credentials_json: '${{ secrets.GCP_SA_KEY }}' |
| 84 | + |
| 85 | + - name: Set up gcloud |
| 86 | + id: setup-gcloud |
| 87 | + uses: google-github-actions/setup-gcloud@v2 |
| 88 | + with: |
| 89 | + install_components: "gke-gcloud-auth-plugin" |
| 90 | + project_id: machineidentitysecurity-jsci-e |
| 91 | + |
| 92 | + - name: Configure Docker for Google Artifact Registry |
| 93 | + run: gcloud auth configure-docker europe-west1-docker.pkg.dev |
| 94 | + |
| 95 | + - id: go-version |
| 96 | + run: | |
| 97 | + make print-go-version >> "$GITHUB_OUTPUT" |
| 98 | +
|
| 99 | + - uses: actions/setup-go@v5 |
| 100 | + with: |
| 101 | + go-version: ${{ steps.go-version.outputs.result }} |
| 102 | + |
| 103 | + - name: Generate timestamp for cluster name |
| 104 | + id: timestamp # Give the step an ID to reference its output |
| 105 | + run: | |
| 106 | + # Generate a timestamp in the format YYMMDD-HHMMSS. |
| 107 | + # Extracting from PR name would require sanitization due to GKE cluster naming constraints |
| 108 | + TIMESTAMP=$(date +'%y%m%d-%H%M%S') |
| 109 | + CLUSTER_NAME="test-secretless-${TIMESTAMP}" |
| 110 | + echo "Generated cluster name: ${CLUSTER_NAME}" |
| 111 | + echo "cluster_name=${CLUSTER_NAME}" >> $GITHUB_OUTPUT |
| 112 | +
|
| 113 | + - run: | |
| 114 | + make helm-plugins |
| 115 | + make -j test-e2e-gke |
| 116 | + # The VEN_API_KEY_PULL secret is set to my API key (Mladen) for glow.in.the.dark tenant. |
| 117 | + env: |
| 118 | + VEN_API_KEY: ${{ secrets.VEN_API_KEY_PULL }} |
| 119 | + VEN_API_KEY_PULL: ${{ secrets.VEN_API_KEY_PULL }} |
| 120 | + OCI_BASE: europe-west1-docker.pkg.dev/machineidentitysecurity-jsci-e/js-agent-ci-repo |
| 121 | + VEN_API_HOST: api.venafi.cloud |
| 122 | + VEN_ZONE: k8s-agent-CI\Default |
| 123 | + VEN_VCP_REGION: us |
| 124 | + CLOUDSDK_CORE_PROJECT: machineidentitysecurity-jsci-e |
| 125 | + CLOUDSDK_COMPUTE_ZONE: europe-west1-b |
| 126 | + CLUSTER_NAME: ${{ steps.timestamp.outputs.cluster_name }} |
| 127 | +
|
| 128 | + - name: Delete GKE Cluster |
| 129 | + # 'always()' - Run this step regardless of success or failure. |
| 130 | + # '!contains(...)' - AND only run if the list of PR labels DOES NOT contain 'keep-e2e-cluster'. |
| 131 | + # NOTE: You will have to delete the test cluster manually when finished with debugging or incur costs. |
| 132 | + if: always() && !contains(github.event.pull_request.labels.*.name, 'keep-e2e-cluster') |
| 133 | + run: | |
| 134 | + echo "Label 'keep-e2e-cluster' not found. Cleaning up GKE cluster ${{ steps.timestamp.outputs.cluster_name }}" |
| 135 | + gcloud container clusters delete ${{ steps.timestamp.outputs.cluster_name }} \ |
| 136 | + --project=machineidentitysecurity-jsci-e \ |
| 137 | + --zone=europe-west1-b \ |
| 138 | + --quiet |
0 commit comments