|
| 1 | +name: Setup CF Environment |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + environment: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + capi-version: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + outputs: |
| 13 | + environment-name: |
| 14 | + description: "Name of claimed environment" |
| 15 | + value: ${{ jobs.cf-env-setup.outputs.environment-name }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + cf-env-setup: |
| 19 | + name: Setting Up CF env |
| 20 | + runs-on: ubuntu-latest |
| 21 | + environment: ${{ inputs.environment }} |
| 22 | + outputs: |
| 23 | + environment-name: ${{ steps.claim-toolsmiths-env.outputs.environment-name }} |
| 24 | + steps: |
| 25 | + - id: claim-toolsmiths-env |
| 26 | + name: Claim Toolsmiths Environment |
| 27 | + env: |
| 28 | + api_token: ${{ secrets.TOOLSMITHS_API_TOKEN }} |
| 29 | + hostname: ${{ secrets.TOOLSMITHS_HOSTNAME }} |
| 30 | + notes: CF CLI Github Actions Integration Tests |
| 31 | + pool_name: cf-deployment |
| 32 | + run: | |
| 33 | + while true; do |
| 34 | + curl -s --show-error -D >(tee headers.txt >&2) -H 'Accept: application/json' \ |
| 35 | + -X POST "https://${hostname}/pooled_gcp_engineering_environments/claim" \ |
| 36 | + --data-urlencode "api_token=${api_token}" \ |
| 37 | + --data-urlencode "pool_name=${pool_name}" \ |
| 38 | + --data-urlencode "notes=${notes}" > metadata.json \ |
| 39 | + || echo "Unable to reach server, trying again in 30 seconds..." |
| 40 | +
|
| 41 | + ERR_500="Sorry, the Toolsmiths Environments app is currently encountering issues. Trying again in 30 seconds..." |
| 42 | + ERR_429="Sorry, Toolsmiths are out of environments in your requested pool. New environments are on their way but you can stop by the Toolsmiths slack channel for more help." |
| 43 | + ERR_409="Sorry, was not able to claim an environment. Trying again in 30 seconds..." |
| 44 | +
|
| 45 | + grep -q -E "HTTP/[[:digit:]\.]{1,3} 401" headers.txt && exit 1 |
| 46 | + grep -q -E "HTTP/[[:digit:]\.]{1,3} 404" headers.txt && exit 2 |
| 47 | + grep -q -E "HTTP/[[:digit:]\.]{1,3} 500" headers.txt && echo "$ERR_500" |
| 48 | + grep -q -E "HTTP/[[:digit:]\.]{1,3} 200" headers.txt && break |
| 49 | + grep -q -E "HTTP/[[:digit:]\.]{1,3} 429" && echo "$ERR_429" |
| 50 | + grep -q -E "HTTP/[[:digit:]\.]{1,3} 409" && echo "$ERR_409" |
| 51 | +
|
| 52 | + sleep 30 |
| 53 | + done |
| 54 | +
|
| 55 | + ENV=$(cat metadata.json | jq -r '.name') |
| 56 | + echo "environment-name=${ENV}" >> $GITHUB_OUTPUT |
| 57 | +
|
| 58 | + - name: 'Upload Metadata' |
| 59 | + uses: actions/upload-artifact@v3 |
| 60 | + with: |
| 61 | + name: ${{ steps.claim-toolsmiths-env.outputs.environment-name }} |
| 62 | + path: metadata.json |
| 63 | + |
| 64 | + - name: Checkout cli-ci |
| 65 | + uses: actions/checkout@v3 |
| 66 | + with: |
| 67 | + repository: cloudfoundry/cli-ci |
| 68 | + path: cli-ci |
| 69 | + |
| 70 | + - name: Checkout cf-deployment Min CAPI |
| 71 | + if: ${{ inputs.capi-version != 'edge' }} |
| 72 | + uses: actions/checkout@v3 |
| 73 | + with: |
| 74 | + repository: cloudfoundry/cf-deployment |
| 75 | + path: cf-deployment |
| 76 | + ref: ${{ inputs.capi-version }} |
| 77 | + |
| 78 | + - name: Checkout cf-deployment |
| 79 | + uses: actions/checkout@v3 |
| 80 | + if: ${{ inputs.capi-version == 'edge' }} |
| 81 | + with: |
| 82 | + repository: cloudfoundry/cf-deployment |
| 83 | + path: cf-deployment |
| 84 | + |
| 85 | + - name: Checkout CF deployment tasks |
| 86 | + uses: actions/checkout@v3 |
| 87 | + with: |
| 88 | + repository: cloudfoundry/cf-deployment-concourse-tasks |
| 89 | + path: cf-deployment-concourse-tasks |
| 90 | + |
| 91 | + - name: Checkout cli |
| 92 | + uses: actions/checkout@v3 |
| 93 | + with: |
| 94 | + repository: cloudfoundry/cli |
| 95 | + path: cli |
| 96 | + ref: linux-min-capi-int-test |
| 97 | + |
| 98 | + - name: Install Tools |
| 99 | + run: | |
| 100 | + wget https://github.com/cloudfoundry/bosh-bootloader/releases/download/v8.4.110/bbl-v8.4.110_linux_x86-64 -P /tmp |
| 101 | + mv /tmp/bbl-* /usr/local/bin/bbl |
| 102 | + chmod +x /usr/local/bin/bbl |
| 103 | + bbl --version |
| 104 | +
|
| 105 | + wget https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-7.0.1-linux-amd64 --output-document="/usr/local/bin/bosh" |
| 106 | + chmod +x /usr/local/bin/bosh |
| 107 | + bosh --version |
| 108 | +
|
| 109 | + - name: Deploy edge CAPI with Isolation Segment and OIDC Provider |
| 110 | + if: ${{ inputs.capi-version == 'edge' }} |
| 111 | + env: |
| 112 | + CF_INT_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} |
| 113 | + run: | |
| 114 | + # find latest capi |
| 115 | + FILENAME="$(aws s3 ls capi-releases --no-sign-request --recursive --region us-east-1 | sort | tail -n 1 | awk '{print $4}')" |
| 116 | + aws s3 cp s3://capi-releases/$FILENAME $FILENAME --no-sign-request --region us-east-1 |
| 117 | + eval "$(bbl print-env --metadata-file metadata.json)" |
| 118 | + bosh upload-release --sha2 "$FILENAME" |
| 119 | + rm $FILENAME |
| 120 | +
|
| 121 | + # deploy |
| 122 | + bosh -d cf manifest > /tmp/manifest.yml |
| 123 | + bosh interpolate /tmp/manifest.yml \ |
| 124 | + -o cf-deployment/operations/test/add-persistent-isolation-segment-diego-cell.yml \ |
| 125 | + -o cli-ci/ci/infrastructure/operations/add-oidc-provider.yml \ |
| 126 | + -o cli-ci/ci/infrastructure/operations/add-uaa-client-credentials.yml \ |
| 127 | + -o cli-ci/ci/infrastructure/operations/use-latest-capi.yml \ |
| 128 | + -v client-secret="${CF_INT_CLIENT_SECRET}" \ |
| 129 | + > ./director.yml |
| 130 | +
|
| 131 | + bosh -d cf deploy director.yml -n |
| 132 | + echo "Deployed CAPI version:" |
| 133 | + bosh -d cf releases | grep capi |
| 134 | +
|
| 135 | + - name: Deploy MIN CAPI with Isolation Segment and OIDC Provider |
| 136 | + if: ${{ inputs.capi-version != 'edge' }} |
| 137 | + run: | |
| 138 | + # Creates vars files |
| 139 | + mkdir vars-files |
| 140 | + echo "cs = ${{ secrets.CLIENT_SECRET }}" |
| 141 | + cat << EOF > vars-files/vars.yml |
| 142 | + client-secret: ${{ secrets.CLIENT_SECRET }} |
| 143 | + EOF |
| 144 | +
|
| 145 | + # Copy Ops files |
| 146 | + mkdir ops-files |
| 147 | + cp cf-deployment/operations/scale-to-one-az.yml ops-files/ |
| 148 | + cp cf-deployment/operations/test/add-persistent-isolation-segment-diego-cell.yml ops-files/ |
| 149 | + cp cf-deployment/operations/use-compiled-releases.yml ops-files/ |
| 150 | + cp cf-deployment/operations/use-internal-lookup-for-route-services.yml ops-files/ |
| 151 | + cp cli-ci/ci/infrastructure/operations/add-dummy-windows-stack.yml ops-files/ |
| 152 | + cp cli-ci/ci/infrastructure/operations/add-oidc-provider.yml ops-files/ |
| 153 | + cp cli-ci/ci/infrastructure/operations/add-uaa-client-credentials.yml ops-files/ |
| 154 | + cp cli-ci/ci/infrastructure/operations/add-uaa-client-cf-custom.yml ops-files/ |
| 155 | + cp cli-ci/ci/infrastructure/operations/adjust-user-retry-attempts.yml ops-files/ |
| 156 | + cp cli-ci/ci/infrastructure/operations/cli-isolation-cell-overrides.yml ops-files/ |
| 157 | + cp cli-ci/ci/infrastructure/operations/default-app-memory.yml ops-files/ |
| 158 | + cp cli-ci/ci/infrastructure/operations/diego-cell-instances.yml ops-files/ |
| 159 | + cp cli-ci/ci/infrastructure/operations/doppler-instances.yml ops-files/ |
| 160 | + cp cli-ci/ci/infrastructure/operations/enable-v3-deployments-endpoint.yml ops-files/ |
| 161 | + cp cli-ci/ci/infrastructure/operations/give-cf-admin-clients-read-scope.yml ops-files/ |
| 162 | + cp cli-ci/ci/infrastructure/operations/reduce-async-service-polling.yml ops-files/ |
| 163 | + cp cli-ci/ci/infrastructure/operations/skip-ssl-override.yml ops-files/ |
| 164 | + cp cli-ci/ci/infrastructure/operations/uaa-vm_type-override.yml ops-files/ |
| 165 | + # Deletes CF-D |
| 166 | + eval "$(bbl print-env --metadata-file metadata.json)" |
| 167 | + bosh -d cf delete-deployment -n |
| 168 | +
|
| 169 | + # Deploy CF-D |
| 170 | + mkdir toolsmiths-env |
| 171 | + cp metadata.json toolsmiths-env/metadata |
| 172 | + cat metadata.json | jq -r .name > toolsmiths-env/name |
| 173 | + export VARS_FILES="vars.yml" |
| 174 | + export MANIFEST_FILE="cf-deployment.yml" |
| 175 | + export SYSTEM_DOMAIN="" |
| 176 | + export REGENERATE_CREDENTIALS=false |
| 177 | + export DEPLOY_WITH_UPTIME_MEASUREMENTS=false |
| 178 | + export MEASURE_SYSLOG_AVAILABILITY=false |
| 179 | + export TCP_DOMAIN="" |
| 180 | + export AVAILABLE_PORT="" |
| 181 | + export FAIL_ON_DOWNTIME=false |
| 182 | + export APP_PUSHABILITY_THRESHOLD=0 |
| 183 | + export HTTP_AVAILABILITY_THRESHOLD=0 |
| 184 | + export RECENT_LOGS_THRESHOLD=0 |
| 185 | + export STREAMING_LOGS_THRESHOLD=0 |
| 186 | + export APP_SYSLOG_AVAILABILITY_THRESHOLD=0 |
| 187 | + export USE_SINGLE_APP_INSTANCE=false |
| 188 | + export BOSH_DEPLOY_ARGS="" |
| 189 | + export BOSH_LITE=false |
| 190 | + export BBL_JSON_CONFIG="" |
| 191 | + export OPS_FILES="add-persistent-isolation-segment-diego-cell.yml \ |
| 192 | + use-compiled-releases.yml \ |
| 193 | + cli-isolation-cell-overrides.yml \ |
| 194 | + default-app-memory.yml \ |
| 195 | + skip-ssl-override.yml \ |
| 196 | + scale-to-one-az.yml \ |
| 197 | + diego-cell-instances.yml \ |
| 198 | + doppler-instances.yml \ |
| 199 | + uaa-vm_type-override.yml \ |
| 200 | + add-uaa-client-credentials.yml \ |
| 201 | + add-dummy-windows-stack.yml \ |
| 202 | + reduce-async-service-polling.yml \ |
| 203 | + add-oidc-provider.yml \ |
| 204 | + adjust-user-retry-attempts.yml \ |
| 205 | + enable-v3-deployments-endpoint.yml \ |
| 206 | + give-cf-admin-clients-read-scope.yml \ |
| 207 | + add-uaa-client-cf-custom.yml \ |
| 208 | + use-internal-lookup-for-route-services.yml" |
| 209 | + ./cf-deployment-concourse-tasks/bosh-deploy/task |
0 commit comments