Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI Workflow

# Trigger the workflow on schedule (nightly at 12:00) and manually on the main branch
on:
schedule:
- cron: '0 0 * * *' # Runs every day at 12:00 AM (UTC)
workflow_dispatch: # Allows manual trigger
push:
branches:
- main

jobs:
setup-kind:
runs-on: ubuntu-latest
services:
docker:
image: docker:19.03.12
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install necessary packages (curl, kubectl, kind)
run: |
sudo apt-get update
sudo apt-get install -y curl bash
# Download and install kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
# Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl

- name: Create Kind Cluster
run: kind create cluster --wait 5m

- name: Setup kubeconfig
run: |
kind get kubeconfig > $GITHUB_WORKSPACE/kubeconfig
env:
KUBECONFIG: $GITHUB_WORKSPACE/kubeconfig

- name: Verify Kubernetes Cluster
run: |
kubectl cluster-info
kubectl get nodes

test_application:
needs: setup-kind
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set kubeconfig
run: |
echo "$KUBECONFIG" > kubeconfig
env:
KUBECONFIG: $GITHUB_WORKSPACE/kubeconfig

- name: Apply Kubernetes Manifests
run: |
kubectl apply -f ./tests/nginx.yaml
kubectl wait --for=condition=ready pod -n ci-test --timeout=300s
kubectl get pods

cleanup:
needs: test_application
runs-on: ubuntu-latest
steps:
- name: Delete Kind Cluster
run: kind delete cluster
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Home-Assistant on K3s Cluster
[![Docker Build for Bluez Service](https://github.com/mysticrenji/home-assistant-on-kubernetes/actions/workflows/main.yaml/badge.svg?branch=main)](https://github.com/mysticrenji/home-assistant-on-kubernetes/actions/workflows/main.yaml)
[![Nightly Build test for Home Assistant](https://github.com/mysticrenji/home-assistant-on-kubernetes/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/mysticrenji/home-assistant-on-kubernetes/actions/workflows/tests.yaml)

Personal project to run home-assistant on K3s locally on Nvidia Jetson(ARM64)

Expand Down
18 changes: 18 additions & 0 deletions tests/nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Namespace
metadata:
name: ci-test
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
namespace: ci-test
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80