Skip to content
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

Add parallel steps #41

Merged
merged 3 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cloudbuild.compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
# dir: 'web'
# args: ['test']

- id: 'build web container'
- id: 'build web'
name: 'gcr.io/cloud-builders/docker'
args: [
'build',
Expand All @@ -28,8 +28,9 @@ steps:
'--cache-from=gcr.io/$PROJECT_ID/web:latest',
'web/.',
]
waitFor: ['-'] # start immediately

- id: 'build database container'
- id: 'build db'
name: 'gcr.io/cloud-builders/docker'
args: [
'build',
Expand All @@ -38,8 +39,9 @@ steps:
'--cache-from', 'gcr.io/$PROJECT_ID/mysql:latest',
'mysql/.',
]
waitFor: ['-'] # start immediately

- id: 'Create Environment'
- id: 'compose up'
name: 'gcr.io/$PROJECT_ID/docker-compose:latest'
entrypoint: '/bin/bash'
args:
Expand All @@ -48,8 +50,9 @@ steps:
docker-compose up -d
env:
- 'PROJECT_ID=$PROJECT_ID'
waitFor: ['build web','build db']

- id: 'run E2E tests'
- id: 'integration tests'
name: 'gcr.io/$PROJECT_ID/docker-compose:latest'
entrypoint: '/bin/bash'
args:
Expand All @@ -58,6 +61,7 @@ steps:
### -r = retries; -i = interval; -k = keyword to search for ###
./test/test-connection.sh -r 20 -i 3 -u http://web:3000
./test/test-content.sh -r 20 -i 3 -u http://web:3000 -k 'Chocolate Chip'
waitFor: ['compose up']

images:
- gcr.io/$PROJECT_ID/web
Expand Down
37 changes: 23 additions & 14 deletions cloudbuild.gke.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
steps:
- id: 'build web container'
- id: 'build web'
name: 'gcr.io/cloud-builders/docker'
args: [
'build',
Expand All @@ -8,8 +8,9 @@ steps:
'--cache-from', 'gcr.io/$PROJECT_ID/web:latest',
'web/.',
]
waitFor: ['-'] # start immediately

- id: 'build database container'
- id: 'build db'
name: 'gcr.io/cloud-builders/docker'
args: [
'build',
Expand All @@ -20,24 +21,29 @@ steps:
]
env:
- "MYSQL_ROOT_PASSWORD=password"
waitFor: ['-'] # start immediately

- id: 'Push web image'
- id: 'make namespace'
name: 'gcr.io/cloud-builders/kubectl'
args: ['create','namespace','test-$BUILD_ID']
waitFor: ['-'] # start immediately

- id: 'push web'
name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/web']
waitFor: ['build web']

- id: 'Push database image'
- id: 'push db'
name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/mysql']

- id: 'Create namespace'
name: 'gcr.io/cloud-builders/kubectl'
args: ['create','namespace','test-$BUILD_ID']
waitFor: ['build db']

- id: 'Deploy application to cluster'
- id: 'deploy to staging'
name: 'gcr.io/cloud-builders/kubectl'
args: ['apply', '-f', 'k8s/', '--namespace=test-$BUILD_ID']
waitFor: ['push web','push db']

- id: 'Get endpoint of web service'
- id: 'get endpoint'
name: 'gcr.io/cloud-builders/kubectl'
entrypoint: 'bash'
args:
Expand All @@ -53,7 +59,7 @@ steps:
sleep 3
done

echo "$(get_nodeport)" > _nodeport
echo "$(get_nodeport)" > _nodeport # save port for use in next step

# grab the public IP of a random node
# (why do this instead of a load balancer? b/c it's faster to instantiate)
Expand All @@ -68,10 +74,11 @@ steps:
sleep 3
done

echo $(get_nodeip) > _nodeip # save ip for use in next step

echo $(get_nodeip) > _nodeip
waitFor: ['deploy to staging']

- id: 'run E2E tests'
- id: 'integration tests'
name: 'gcr.io/cloud-builders/curl'
entrypoint: '/bin/bash'
args:
Expand All @@ -80,10 +87,12 @@ steps:
### -r = retries; -i = interval; -k = keyword to search for ###
./test/test-connection.sh -r 20 -i 3 -u http://$(cat _nodeip):$(cat _nodeport)
./test/test-content.sh -r 20 -i 3 -u http://$(cat _nodeip):$(cat _nodeport) -k 'Chocolate Chip'
waitFor: ['get endpoint']

- id: 'Delete namespace'
- id: 'delete namespace'
name: 'gcr.io/cloud-builders/kubectl'
args: ['delete', 'namespaces', 'test-$BUILD_ID']
waitFor: ['integration tests']

options:
env:
Expand Down
20 changes: 2 additions & 18 deletions cloudbuild.vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,13 @@ steps:
args: ['push', 'gcr.io/$PROJECT_ID/mysql']
waitFor: ['build db']

# - id: 'Create namespace'
# name: 'gcr.io/cloud-builders/kubectl'
# args: ['create','namespace','$BUILD_ID']

- id: 'deploy app'
# use vanilla kubectl container b/c this isn't GKE
name: 'bitnami/kubectl'
args: [
'apply',
'-f',
'k8s/',
# '--namespace=$BUILD_ID',
'--kubeconfig=kubeconfig.microk8s'
]
waitFor: ['patch kubeconfig']
Expand All @@ -116,7 +111,6 @@ steps:
- |
# determine which node port the service was exposed on
get_nodeport() {
# kubectl get service cookieshop-web --namespace=test-$BUILD_ID -o=jsonpath='{.spec.ports[0].nodePort}'
kubectl get service cookieshop-web -o=jsonpath='{.spec.ports[0].nodePort}' --kubeconfig=kubeconfig.microk8s
}

Expand All @@ -128,7 +122,7 @@ steps:
echo "$(get_nodeport)" > _nodeport
waitFor: ['deploy app']

- id: 'test'
- id: 'integration test'
name: 'gcr.io/cloud-builders/curl'
entrypoint: '/bin/bash'
args:
Expand All @@ -148,17 +142,7 @@ steps:
'-var=instance-name=test-$BUILD_ID',
'-auto-approve'
]
waitFor: ['test']

# - id: 'Delete namespace'
# name: 'gcr.io/cloud-builders/kubectl'
# args: ['delete', 'namespaces', '$BUILD_ID']

# options:
# env:
# # location/name of GKE cluster (used by all kubectl commands)
# - CLOUDSDK_COMPUTE_ZONE=us-central1-a
# - CLOUDSDK_CONTAINER_CLUSTER=staging
waitFor: ['integration test']

timeout:
3600s