Skip to content

test

test #203

Workflow file for this run

name: test
on:
workflow_dispatch:
permissions: read-all
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
fail-fast: false
matrix:
options:
- fn-call
- non-fn-call
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.22"
check-latest: true
- name: setup test dependencies
shell: bash
run: |
make test-e2e-dependencies
- name: build binary
shell: bash
run: |
make bin
- name: create kind cluster
shell: bash
run: |
# used to retrieve the k8s api for fn-call and apply the manifest
kind create cluster
- name: run tests
shell: bash
run: |
if [[ ${{ matrix.options }} == 'fn-call' ]]; then
FN_CALL="--use-k8s-api"
fi
kubectl ai "create a deployment called 'nginx-deployment' with image as docker.io/library/nginx:latest and 'app: nginx' as selector with 2 replicas" --require-confirmation=false ${FN_CALL}
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_DEPLOYMENT_NAME: ${{ secrets.OPENAI_DEPLOYMENT_NAME }}
OPENAI_ENDPOINT: ${{ secrets.OPENAI_ENDPOINT }}
- name: validate deployment
shell: bash
run: |
set -x
kubectl rollout status deployment nginx-deployment
kubectl wait --for=condition=available --timeout=5m deployment/nginx-deployment
- name: test input and output
shell: bash
run: |
kubectl get deployments nginx-deployment -o yaml | kubectl ai "create a service called nginx-svc that point to this deployment and set replicas to 5" --raw | kubectl apply -f -
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_DEPLOYMENT_NAME: ${{ secrets.OPENAI_DEPLOYMENT_NAME }}
OPENAI_ENDPOINT: ${{ secrets.OPENAI_ENDPOINT }}
- name: validate replicas
shell: bash
run: |
set -x
REPLICA_COUNT=$(kubectl get deployments nginx-deployment -o jsonpath='{.spec.replicas}')
if [[ $REPLICA_COUNT -ne 5 ]]; then
echo "replica count is not 5"
exit 1
fi
- name: validate service
shell: bash
run: |
set -x
SELECTOR_NAME=$(kubectl get svc nginx-svc -o jsonpath='{.spec.selector.app}')
if [[ $SELECTOR_NAME != "nginx" ]]; then
echo "selector name is not nginx"
exit 1
fi