Update repo with latest weaver changes (#100) #274
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2023 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. | |
name: Integration Test | |
env: | |
APP_CONFIG_FILE: app.toml | |
KUBE_CONFIG_FILE: deploy.yaml | |
REPO_URL: 192.168.50.2:5000 | |
WAIT_TIMEOUT: "5m" | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Re-configure docker" | |
# NOTE: This step allows the weaver-kube tool to push the container images | |
# to the minikube cluster repository. | |
run: | | |
echo '{"insecure-registries" : ["192.168.50.2:5000"]}' | sudo tee /etc/docker/daemon.json | |
sudo systemctl daemon-reload | |
sudo systemctl restart docker | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 'stable' | |
cache: true | |
- name: Setup kubectl. | |
uses: azure/setup-kubectl@v3 | |
- name: Setup minikube | |
uses: medyagh/setup-minikube@master | |
with: | |
start-args: '--subnet 192.168.50.0/24' | |
addons: registry | |
insecure-registry: '192.168.50.0/24' | |
- name: Install weaver-kube | |
run: cd cmd/weaver-kube; go build . | |
- name: Build echo example. | |
run: cd examples/echo; go build . | |
- name: Generate app config file | |
run: | | |
CONFIG=$(cat << EOF | |
[serviceweaver] | |
binary = "./examples/echo/echo" | |
EOF | |
) | |
echo "$CONFIG" > ${{ env.APP_CONFIG_FILE }} | |
- name: Generate kubernetes config file | |
run: | | |
CONFIG=$(cat << EOF | |
appConfig: "${{ env.APP_CONFIG_FILE }}" | |
repo: "${{ env.REPO_URL }}" | |
listeners: | |
- name: echo | |
public: true | |
EOF | |
) | |
echo "$CONFIG" > ${{ env.KUBE_CONFIG_FILE }} | |
- name: Build the docker image and push | |
run: | | |
WEAVER_YAML=$(./cmd/weaver-kube/weaver-kube deploy ${{ env.KUBE_CONFIG_FILE }}) | |
echo "Generated YAML file:" $WEAVER_YAML | |
echo "WEAVER_YAML=$WEAVER_YAML" >> $GITHUB_ENV | |
- name: Deploy the application | |
run: kubectl apply -f ${{env.WEAVER_YAML}} | |
- name: Get the name of the echo listener service | |
run: | | |
NAME=$(timeout ${{ env.WAIT_TIMEOUT }} /bin/sh -c 'while true; do NAME=$(kubectl get service -l serviceweaver/listener=echo -o jsonpath={.items[].metadata.name}) && echo $NAME && break; sleep 2; done') | |
echo "SERVICE_NAME=$NAME" >> $GITHUB_ENV | |
- name: Call the echo endpoint until it succeeds | |
run: | | |
timeout ${{ env.WAIT_TIMEOUT }} /bin/sh -c 'while true; do kubectl run -i --rm --restart=Never --image=busybox:latest test-api --command wget -- -q -O - http://${{ env.SERVICE_NAME }}?s=testme && break; sleep 2; done' | |
- name: Display deployment logs | |
if: failure() | |
run: | | |
kubectl get all | |
kubectl describe pod | |
kubectl logs -l serviceweaver/app=echo | |