Skip to content

feat: add rag-embedding function with node-sql template #59

feat: add rag-embedding function with node-sql template

feat: add rag-embedding function with node-sql template #59

name: CI Test K8s
on:
pull_request:
branches:
- main
- release/*
paths:
- "k8s/**"
- "tests/e2e/**"
- "functions/**"
- ".github/workflows/test-k8s-deployment.yaml"
push:
branches:
- main
- release/*
paths:
- "k8s/**"
- "tests/e2e/**"
- "functions/**"
- ".github/workflows/test-k8s-deployment.yaml"
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-test-deployment
cancel-in-progress: true
jobs:
k8s-ci-test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install pnpm
run: npm install -g pnpm@10.12.2
- name: Install project dependencies
run: pnpm install
- name: Generate workspace packages
run: pnpm generate
- name: Setup kind cluster
uses: helm/kind-action@v1
with:
cluster_name: ci
wait: 120s
- name: Verify cluster
run: |
kubectl version
kubectl get nodes -o wide
- name: Install Skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin/
- name: Create namespace and GHCR pull secret
env:
GHCR_USERNAME: ${{ secrets.GH_USERNAME }}
GHCR_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
GHCR_EMAIL: ${{ secrets.GH_EMAIL }}
run: |
set -e
kubectl create namespace constructive-functions --dry-run=client -o yaml | kubectl apply -f -
if [ -n "${GHCR_USERNAME:-}" ] && [ -n "${GHCR_TOKEN:-}" ]; then
echo "Creating ghcr-pull secret in constructive-functions namespace"
kubectl create secret docker-registry ghcr-pull \
--docker-server=ghcr.io \
--docker-username="${GHCR_USERNAME}" \
--docker-password="${GHCR_TOKEN}" \
--docker-email="${GHCR_EMAIL:-devnull@example.com}" \
--dry-run=client -o yaml | kubectl apply -n constructive-functions -f -
kubectl patch serviceaccount default -n constructive-functions \
-p '{"imagePullSecrets": [{"name": "ghcr-pull"}]}'
else
echo "GHCR_USERNAME/GHCR_TOKEN not set; assuming images are public."
fi
- name: Deploy with Skaffold (local-simple)
run: skaffold run -p local-simple
- name: Wait for pods to stabilize
run: |
echo "Waiting for deployments..."
kubectl rollout status deploy --all -n constructive-functions --timeout=180s || true
echo "Pod status:"
kubectl get pods -n constructive-functions -o wide
- name: Wait for DB setup job
run: |
kubectl wait --for=condition=complete job/constructive-db \
-n constructive-functions --timeout=180s
- name: Port-forward postgres and run e2e tests
env:
PGHOST: localhost
PGPORT: "5432"
PGUSER: postgres
PGPASSWORD: "postgres123!"
PGDATABASE: constructive
run: |
kubectl port-forward -n constructive-functions svc/postgres 5432:5432 &
sleep 3
pnpm test:e2e
- name: Dump diagnostics on failure
if: failure()
run: |
NS=constructive-functions
echo "=== Namespaces ==="
kubectl get ns
echo "=== Pods ==="
kubectl get pods -n $NS -o wide || true
echo "=== Events ==="
kubectl get events -n $NS --sort-by=.lastTimestamp || true
echo "=== Deployments ==="
kubectl get deploy -n $NS -o wide || true
echo "=== Logs ==="
for pod in $(kubectl get pods -n $NS -o jsonpath='{.items[*].metadata.name}'); do
echo "--------------------------------------------------"
echo "Logs for $pod"
kubectl describe pod -n $NS "$pod" || true
kubectl logs -n $NS "$pod" --all-containers --tail=200 || true
done