diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..b2b26b3 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,107 @@ +# 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 Tests + +on: + push: + branches: + - 'main' + pull_request: + +jobs: + collatz: + name: Build collatz binary + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + name: Checkout collatz example + with: + repository: ServiceWeaver/weaver + ref: 'v0.15.0' + - uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: true + - name: Build collatz example + working-directory: ./examples/collatz + run: go build -o collatz + - uses: actions/upload-artifact@v3 + with: + name: collatz-binary + path: ./examples/collatz/collatz + deploy: + name: Deploy and run tests + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + needs: collatz + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: true + - uses: azure/setup-kubectl@v3 + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Install weaver-kube + run: | + go install ./cmd/weaver-kube + - uses: actions/download-artifact@v3 + with: + name: collatz-binary + path: ./examples/collatz + - 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/${{ github.repository }}/example-collatz" + listeners.collatz = {public = true} + - name: Build and generate kube manifests + working-directory: ./examples/collatz + run: | + chmod +x ./collatz && \ + 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=ready --timeout=300s Deployment -l serviceweaver/app_name=collatz + - name: Display deployment logs + if: failure() + working-directory: ./examples/collatz + run: | + kubectl get all && \ + kubectl describe pod -l app_name=collatz && \ + kubectl logs -l app_name=collatz + - uses: actions/upload-artifact@v3 + if: always() + with: + name: collatz-kube-manifests + path: ./examples/collatz/kube_*.yaml