fix: CI/CD pipeline validate k3s manifests #22
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install fastapi uvicorn pytest pytest-httpx prometheus-fastapi-instrumentator | |
| - name: Run tests | |
| run: pytest test_main.py -v | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| run: docker build -t fastapi-app:latest . | |
| validate-k8s: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install kubectl | |
| run: | | |
| curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64 | |
| sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64 | |
| - name: Validate Kubernetes manifests | |
| run: | | |
| for file in prometheus-service.yml *.yaml; do | |
| [ -e "$file" ] || continue | |
| kubectl apply -f "$file" --dry-run=client | |
| done |