test: add unit tests and code coverage #416
Workflow file for this run
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
name: charts | |
on: | |
release: | |
types: [created] | |
pull_request: | |
branches: | |
- main | |
paths: | |
- charts/** | |
- .github/workflows/charts.yml | |
- "**.go" | |
permissions: read-all | |
jobs: | |
# SKIP: Need more refactoring for this workflow, it needs images to be pushed to registry first | |
# lint-helm-chart-test: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0 | |
# with: | |
# fetch-depth: 0 | |
# - name: Set up Helm | |
# uses: Azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 | |
# with: | |
# version: v3.12.1 | |
# - uses: actions/setup-python@v4 | |
# with: | |
# python-version: '3.9' | |
# check-latest: true | |
# - name: Set up chart-testing | |
# uses: helm/[email protected] | |
# - name: Run chart-testing (list-changed) | |
# id: list-changed | |
# run: | | |
# changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) | |
# if [[ -n "$changed" ]]; then | |
# echo "changed=true" >> "$GITHUB_OUTPUT" | |
# fi | |
# - name: Run chart-testing (lint) | |
# if: steps.list-changed.outputs.changed == 'true' | |
# run: ct lint --target-branch ${{ github.event.repository.default_branch }} | |
# - name: Create kind cluster | |
# if: steps.list-changed.outputs.changed == 'true' | |
# uses: helm/[email protected] | |
# - name: Run chart-testing (install) | |
# if: steps.list-changed.outputs.changed == 'true' | |
# run: ct install --target-branch ${{ github.event.repository.default_branch }} | |
charts-test: | |
runs-on: ubuntu-latest | |
# needs: lint-helm-chart-test | |
env: | |
GOPATH: ${{ github.workspace }}/../go | |
HOME: ${{ github.workspace }}/.. | |
steps: | |
- name: Checkout | |
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0 | |
with: | |
submodules: "recursive" | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #4.1.0 | |
with: | |
go-version: "1.21" | |
cache: false | |
- name: Install helm | |
uses: Azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 | |
- name: Kind Cluster | |
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 #v1.8.0 | |
with: | |
config: "dev/cluster-config.yaml" | |
cluster_name: tarian-helm-chart-testing | |
- name: Testing Kind cluster setup | |
run: | | |
set -x | |
# Verify Kind cluster setup | |
kubectl cluster-info | |
kubectl get pods -n kube-system | |
echo "kubectl config current-context:" $(kubectl config current-context) | |
echo "KUBECONFIG env var:" ${KUBECONFIG} | |
- name: Create Kind registry | |
run: | | |
set -x | |
# Create a Kind registry | |
./dev/run-kind-registry.sh | |
- name: Build Tarian | |
run: | | |
set -x | |
sudo apt update && sudo apt install -y jq pkg-config libelf-dev clang | |
go install google.golang.org/protobuf/cmd/protoc-gen-go@32051b4f86e54c2142c7c05362c6e96ae3454a1c # @v1.28.0 | |
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@938f6e2f7550e542bd78f3b9e8812665db109e02 # @v1.1.0 | |
make bin/protoc bin/goreleaser | |
bash ./dev/run-kind-registry.sh | |
make ebpf generate | |
./bin/goreleaser release --snapshot --rm-dist | |
make push-local-images | |
cp dist/tarianctl_linux_amd64/tarianctl ./bin/ | |
- name: Create namespace | |
run: | | |
set -x | |
kubectl create namespace tarian-system | |
- name: Install NATS | |
run: | | |
set -x | |
helm repo add nats https://nats-io.github.io/k8s/helm/charts/ | |
helm upgrade -i nats nats/nats -n tarian-system -f ./dev/nats-helm-values.yaml --version 0.19.16 | |
- name: Install dgraph | |
run: | | |
set -x | |
kubectl apply -f ./dev/config/tarian-server/dgraph-single.yaml -n tarian-system | |
- name: Install Tarian server | |
run: | | |
set -x | |
helm install tarian-server ./charts/tarian-server \ | |
-n tarian-system \ | |
--set server.image.name=localhost:5000/tarian-server \ | |
--set server.image.tag=latest \ | |
--set server.service.type=NodePort \ | |
--set server.service.nodePort=31051 | |
- name: Install Tarian cluster agent | |
run: | | |
set -x | |
helm install tarian-cluster-agent ./charts/tarian-cluster-agent/ \ | |
-n tarian-system \ | |
--set clusterAgent.image.name=localhost:5000/tarian-cluster-agent \ | |
--set clusterAgent.image.tag=latest \ | |
--set clusterAgent.service.type=NodePort \ | |
--set clusterAgent.service.nodePort=31052 \ | |
--set clusterAgent.enableAddConstraint=true \ | |
--set nodeAgent.image.name=localhost:5000/tarian-node-agent \ | |
--set nodeAgent.image.tag=latest \ | |
--set nodeAgent.hostProcDir=/host/proc \ | |
--set webhook.podAgentContainerImage.name=localhost:5000/tarian-pod-agent \ | |
--set webhook.podAgentContainerImage.tag=latest | |
- name: Wait for pods to be ready | |
id: wait-until-tarian-is-ready | |
run: | | |
set -x | |
# Wait for all pods in the tarian-system namespace to be in the "Ready" state | |
kubectl wait --for=condition=ready pod --all -n tarian-system --timeout=300s | |
continue-on-error: true | |
- name: Run tests | |
id: run-tests | |
if: steps.wait-until-tarian-is-ready.outcome == 'success' | |
run: make k8s-test | |
continue-on-error: true | |
- name: Collect deployment information in case of failure | |
if: steps.wait-until-tarian-is-ready.outcome != 'success' || steps.run-tests.outcome != 'success' | |
run: | | |
set -x | |
# Collect logs and information for debugging in case of failure | |
kubectl get pods -n tarian-system | |
echo "======================================================================================================================" | |
kubectl describe pods -n tarian-system | |
echo "======================================================================================================================" | |
kubectl logs -n tarian-system deploy/tarian-server | |
echo "======================================================================================================================" | |
kubectl logs -n tarian-system deploy/tarian-cluster-agent | |
echo "======================================================================================================================" | |
kubectl logs -n tarian-system deploy/tarian-cluster-agent-controller-manager | |
echo "======================================================================================================================" | |
kubectl logs -n tarian-system daemonsets/tarian-node-agent | |
echo "======================================================================================================================" | |
exit 1 | |
# SKIP: Add this part into release workflow | |
# release: | |
# if: startsWith(github.ref, 'refs/heads/main') | |
# needs: charts-test | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: write | |
# env: | |
# GOPATH: ${{ github.workspace }}/../go | |
# HOME: ${{ github.workspace }}/.. | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # @3.1.0 | |
# with: | |
# fetch-depth: 0 | |
# - name: Configure Git | |
# run: | | |
# git config user.name "$GITHUB_ACTOR" | |
# git config user.email "[email protected]" | |
# - name: Install Helm | |
# uses: Azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 # @v3.5 | |
# with: | |
# version: '3.11.0' | |
# - name: Run chart-releaser | |
# uses: helm/chart-releaser-action@c25b74a986eb925b398320414b576227f375f946 # @v1.2.1 | |
# with: | |
# config: .cr.yaml | |
# env: | |
# CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |