|
| 1 | +name: Test Galaxy Deployment on GCE |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + galaxy-chart-version: |
| 7 | + description: 'Galaxy Helm chart version' |
| 8 | + default: '6.6.0' |
| 9 | + required: true |
| 10 | + git-repo: |
| 11 | + description: 'Git repository URL for galaxy-k8s-boot' |
| 12 | + default: 'https://github.com/galaxyproject/galaxy-k8s-boot.git' |
| 13 | + required: true |
| 14 | + git-branch: |
| 15 | + description: 'Git branch to deploy' |
| 16 | + default: 'master' |
| 17 | + required: true |
| 18 | + instance-name: |
| 19 | + description: 'Name for the test VM instance' |
| 20 | + default: 'galaxy-test-ci' |
| 21 | + required: true |
| 22 | + gcp-project: |
| 23 | + description: 'GCP project ID' |
| 24 | + default: 'anvil-and-terra-development' |
| 25 | + required: true |
| 26 | + gcp-zone: |
| 27 | + description: 'GCP zone' |
| 28 | + default: 'us-east4-c' |
| 29 | + required: true |
| 30 | + |
| 31 | +env: |
| 32 | + INSTANCE_NAME: ${{ inputs.instance-name }} |
| 33 | + GCP_PROJECT: ${{ inputs.gcp-project }} |
| 34 | + GCP_ZONE: ${{ inputs.gcp-zone }} |
| 35 | + |
| 36 | +jobs: |
| 37 | + test-galaxy: |
| 38 | + name: Deploy and Test Galaxy |
| 39 | + runs-on: ubuntu-latest |
| 40 | + |
| 41 | + permissions: |
| 42 | + contents: read |
| 43 | + id-token: write # Required for Workload Identity |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout repository |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Authenticate to Google Cloud |
| 50 | + uses: google-github-actions/auth@v2 |
| 51 | + with: |
| 52 | + workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} |
| 53 | + service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} |
| 54 | + |
| 55 | + - name: Set up Cloud SDK |
| 56 | + uses: google-github-actions/setup-gcloud@v2 |
| 57 | + |
| 58 | + - name: Generate SSH key for VM |
| 59 | + id: ssh-key |
| 60 | + run: | |
| 61 | + ssh-keygen -t rsa -b 4096 -f ~/.ssh/galaxy-ci-key -N "" -C "github-actions" |
| 62 | + echo "public-key=$(cat ~/.ssh/galaxy-ci-key.pub)" >> $GITHUB_OUTPUT |
| 63 | + echo "private-key-path=$HOME/.ssh/galaxy-ci-key" >> $GITHUB_OUTPUT |
| 64 | +
|
| 65 | + - name: Launch Galaxy VM |
| 66 | + id: launch-vm |
| 67 | + run: | |
| 68 | + bin/launch_vm.sh \ |
| 69 | + --project "${{ env.GCP_PROJECT }}" \ |
| 70 | + --zone "${{ env.GCP_ZONE }}" \ |
| 71 | + --ephemeral-only \ |
| 72 | + --galaxy-chart-version "${{ inputs.galaxy-chart-version }}" \ |
| 73 | + --git-repo "${{ inputs.git-repo }}" \ |
| 74 | + --git-branch "${{ inputs.git-branch }}" \ |
| 75 | + -k "${{ steps.ssh-key.outputs.public-key }}" \ |
| 76 | + -f values/values.yml \ |
| 77 | + "${{ env.INSTANCE_NAME }}" |
| 78 | +
|
| 79 | + - name: Get VM IP address |
| 80 | + id: vm-ip |
| 81 | + run: | |
| 82 | + sleep 10 # Give VM time to fully initialize |
| 83 | + VM_IP=$(gcloud compute instances describe "${{ env.INSTANCE_NAME }}" \ |
| 84 | + --project="${{ env.GCP_PROJECT }}" \ |
| 85 | + --zone="${{ env.GCP_ZONE }}" \ |
| 86 | + --format='get(networkInterfaces[0].accessConfigs[0].natIP)') |
| 87 | + echo "ip=${VM_IP}" >> $GITHUB_OUTPUT |
| 88 | + echo "Galaxy VM IP: ${VM_IP}" |
| 89 | +
|
| 90 | + - name: Wait for cloud-init to complete |
| 91 | + run: | |
| 92 | + echo "Waiting for cloud-init to complete on ${{ steps.vm-ip.outputs.ip }}..." |
| 93 | + for i in {1..60}; do |
| 94 | + if gcloud compute ssh "${{ env.INSTANCE_NAME }}" \ |
| 95 | + --project="${{ env.GCP_PROJECT }}" \ |
| 96 | + --zone="${{ env.GCP_ZONE }}" \ |
| 97 | + --ssh-key-file="${{ steps.ssh-key.outputs.private-key-path }}" \ |
| 98 | + --command="cloud-init status --wait" 2>/dev/null; then |
| 99 | + echo "Cloud-init completed successfully" |
| 100 | + break |
| 101 | + fi |
| 102 | + echo "Attempt $i/60: Cloud-init still running or SSH not ready..." |
| 103 | + sleep 30 |
| 104 | + done |
| 105 | +
|
| 106 | + - name: Copy kubeconfig from VM |
| 107 | + run: | |
| 108 | + mkdir -p ~/.kube |
| 109 | + gcloud compute scp \ |
| 110 | + --project="${{ env.GCP_PROJECT }}" \ |
| 111 | + --zone="${{ env.GCP_ZONE }}" \ |
| 112 | + --ssh-key-file="${{ steps.ssh-key.outputs.private-key-path }}" \ |
| 113 | + "ubuntu@${{ env.INSTANCE_NAME }}:/home/ubuntu/.kube/config" \ |
| 114 | + ~/.kube/config |
| 115 | +
|
| 116 | + # Update kubeconfig to use external IP |
| 117 | + sed -i "s|https://0.0.0.0:6443|https://${{ steps.vm-ip.outputs.ip }}:6443|" ~/.kube/config |
| 118 | +
|
| 119 | + - name: Wait for Galaxy deployments to rollout |
| 120 | + run: | |
| 121 | + echo "Waiting for Galaxy deployments to complete (timeout: 15 minutes)..." |
| 122 | +
|
| 123 | + # Get all deployments in the galaxy namespace |
| 124 | + DEPLOYMENTS=$(kubectl get deployments -n galaxy -o jsonpath='{.items[*].metadata.name}') |
| 125 | +
|
| 126 | + if [ -z "$DEPLOYMENTS" ]; then |
| 127 | + echo "No deployments found in galaxy namespace" |
| 128 | + exit 1 |
| 129 | + fi |
| 130 | +
|
| 131 | + echo "Found deployments: $DEPLOYMENTS" |
| 132 | +
|
| 133 | + # Wait for each deployment to rollout |
| 134 | + for deployment in $DEPLOYMENTS; do |
| 135 | + echo "Waiting for deployment: $deployment" |
| 136 | + kubectl rollout status deployment/$deployment -n galaxy --timeout=15m |
| 137 | + done |
| 138 | +
|
| 139 | + echo "All deployments rolled out successfully" |
| 140 | +
|
| 141 | + - name: Test Galaxy API endpoint |
| 142 | + id: test-api |
| 143 | + run: | |
| 144 | + GALAXY_URL="http://${{ steps.vm-ip.outputs.ip }}/api/version" |
| 145 | + echo "Testing Galaxy API at: $GALAXY_URL" |
| 146 | +
|
| 147 | + # Wait for Galaxy to be responsive (max 5 minutes) |
| 148 | + for i in {1..30}; do |
| 149 | + if response=$(curl -s -f "$GALAXY_URL"); then |
| 150 | + echo "Galaxy API is responsive" |
| 151 | + echo "$response" | jq . |
| 152 | +
|
| 153 | + # Validate that response is valid JSON |
| 154 | + if echo "$response" | jq -e . >/dev/null 2>&1; then |
| 155 | + echo "Response is valid JSON ✓" |
| 156 | + echo "version-info=$response" >> $GITHUB_OUTPUT |
| 157 | + exit 0 |
| 158 | + else |
| 159 | + echo "Response is not valid JSON" |
| 160 | + exit 1 |
| 161 | + fi |
| 162 | + fi |
| 163 | + echo "Attempt $i/30: Galaxy not ready yet..." |
| 164 | + sleep 10 |
| 165 | + done |
| 166 | +
|
| 167 | + echo "Galaxy API did not become responsive in time" |
| 168 | + exit 1 |
| 169 | +
|
| 170 | + - name: Cleanup - Delete VM |
| 171 | + if: always() |
| 172 | + run: | |
| 173 | + echo "Cleaning up: Deleting VM ${{ env.INSTANCE_NAME }}" |
| 174 | + gcloud compute instances delete "${{ env.INSTANCE_NAME }}" \ |
| 175 | + --project="${{ env.GCP_PROJECT }}" \ |
| 176 | + --zone="${{ env.GCP_ZONE }}" \ |
| 177 | + --quiet || echo "Failed to delete VM (may not exist)" |
| 178 | +
|
| 179 | + - name: Display test results |
| 180 | + if: always() |
| 181 | + run: | |
| 182 | + echo "=== Test Results ===" |
| 183 | + echo "Instance: ${{ env.INSTANCE_NAME }}" |
| 184 | + echo "IP: ${{ steps.vm-ip.outputs.ip }}" |
| 185 | + echo "Galaxy Chart Version: ${{ inputs.galaxy-chart-version }}" |
| 186 | + echo "Git Repo: ${{ inputs.git-repo }}" |
| 187 | + echo "Git Branch: ${{ inputs.git-branch }}" |
| 188 | + if [ -n "${{ steps.test-api.outputs.version-info }}" ]; then |
| 189 | + echo "Galaxy Version Info:" |
| 190 | + echo "${{ steps.test-api.outputs.version-info }}" | jq . |
| 191 | + fi |
0 commit comments