Skip to content

Commit

Permalink
chore: move shell scripts to single file
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm committed Jul 8, 2023
1 parent 54a1ed8 commit 2e3764e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 36 deletions.
41 changes: 5 additions & 36 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
go-version: '1.20'
cache: true
- uses: azure/setup-kubectl@v3
- uses: medyagh/setup-minikube@master
- uses: docker/login-action@v2
with:
registry: ghcr.io
Expand All @@ -74,44 +75,12 @@ jobs:
id: repository
with:
string: ${{ github.repository }}
- name: Generate weaver.toml
uses: DamianReeves/write-file-action@master
with:
path: ./examples/collatz/weaver.toml
write-mode: overwrite
contents: |
[serviceweaver]
binary = "./collatz"
[kube]
image = "ghcr.io/${{ steps.repository.outputs.lowercase }}/example-collatz"
listeners.collatz = {public = true}
- name: Build and generate kube manifests
working-directory: ./examples/collatz
run: |
# Ensure the binary is executable
chmod +x ./collatz
# Build the docker image and push
weaver-kube deploy weaver.toml
- uses: medyagh/setup-minikube@master
id: minikube
- name: Deploy the application
working-directory: ./examples/collatz
run: |
kubectl apply -f ./kube_*.yaml
- name: Wait for deployment to be ready
working-directory: ./examples/collatz
run: |
kubectl wait --for=condition=Available=True --timeout=90s Deployment -l serviceweaver/app_name=collatz
- name: Call the collatz API
run: |
# Get the load balancer name
LOAD_BALANCER_NAME=$(kubectl get service \
-l serviceweaver/app_name=collatz \
-o=go-template \
--template='{{- range .items -}}{{- if eq .spec.type "LoadBalancer" -}}{{ .metadata.name }}{{- end -}}{{- end -}}')
# Call the API and check the response
kubectl run -i --rm --restart=Never --image=busybox:latest test-api \
--command wget -- -q -O - http://$LOAD_BALANCER_NAME/\?x\=10
run: ./dev/integration.sh
shell: bash
env:
IMAGE_NAME: ghcr.io/${{ steps.repository.outputs.lowercase }}/example-collatz
- name: Display deployment logs
if: failure()
working-directory: ./examples/collatz
Expand Down
46 changes: 46 additions & 0 deletions dev/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Generate weaver.toml
cat <<EOT >> ./weaver.toml
[serviceweaver]
binary = "./collatz"
[kube]
image = "$IMAGE_NAME"
listeners.collatz = {public = true}
EOT

# Ensure the binary is executable
chmod +x ./collatz

# Build the docker image and push
weaver-kube deploy weaver.toml

# Deploy the application
kubectl apply -f ./kube_*.yaml

# Wait for deployment to be ready
kubectl wait --for=condition=Available=True --timeout=90s Deployment \
-l serviceweaver/app_name=collatz

# Get the load balancer name
LOAD_BALANCER_NAME=$(kubectl get service \
-l serviceweaver/app_name=collatz \
-o=go-template \
--template='{{- range .items -}}{{- if eq .spec.type "LoadBalancer" -}}{{ .metadata.name }}{{- end -}}{{- end -}}')

# Call the API and check the response
kubectl run -i --rm --restart=Never --image=busybox:latest test-api \
--command wget -- -q -O - http://$LOAD_BALANCER_NAME/\?x\=10

0 comments on commit 2e3764e

Please sign in to comment.