From d8a01f904d2d93dc94bd794aa8e288a7e2b847c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Eduardo=20Garc=C3=ADa=20M=C3=A1rquez?= Date: Fri, 9 Jan 2026 07:08:21 -0500 Subject: [PATCH] ci: add tests job before deploy, fix namespace to academia - Add test job that runs Domain, Application, and Integration tests - Deploy job now depends on test job (needs: test) - Fix namespace from student-enrollment to academia - Update sync path from student-enrollment to academia - Always apply kustomize before rollout restart --- .gitea/workflows/deploy.yaml | 53 +++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 8fb1000..4ad7a9e 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -1,4 +1,4 @@ -name: Deploy to k3s +name: Test and Deploy to k3s on: push: @@ -8,12 +8,39 @@ on: env: K3S_HOST: "100.67.198.92" K3S_USER: "andres" - NAMESPACE: "student-enrollment" + NAMESPACE: "academia" DOMAIN: "academia.ingeniumcodex.com" jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "10.0.x" + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore + + - name: Run Unit Tests + run: dotnet test tests/Domain.Tests --no-build --verbosity normal + + - name: Run Application Tests + run: dotnet test tests/Application.Tests --no-build --verbosity normal + + - name: Run Integration Tests + run: dotnet test tests/Integration.Tests --no-build --verbosity normal + deploy: runs-on: ubuntu-latest + needs: test steps: - name: Checkout uses: actions/checkout@v4 @@ -34,14 +61,12 @@ jobs: --exclude 'bin' \ --exclude 'obj' \ --exclude '.angular' \ - --exclude 'tests' \ - --exclude 'docs' \ - ./ ${{ env.K3S_USER }}@${{ env.K3S_HOST }}:~/student-enrollment/ + ./ ${{ env.K3S_USER }}@${{ env.K3S_HOST }}:~/academia/ - name: Build images (parallel) run: | ssh ${{ env.K3S_USER }}@${{ env.K3S_HOST }} << 'ENDSSH' - cd ~/student-enrollment + cd ~/academia export DOCKER_BUILDKIT=1 echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S docker build \ @@ -68,8 +93,8 @@ jobs: - name: Setup namespace if needed run: | ssh ${{ env.K3S_USER }}@${{ env.K3S_HOST }} << 'ENDSSH' - cd ~/student-enrollment/deploy/k3s - if ! echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl get ns student-enrollment &>/dev/null; then + cd ~/academia/deploy/k3s + if ! echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl get ns academia &>/dev/null; then echo "Creating namespace and resources..." echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl apply -k . fi @@ -78,22 +103,24 @@ jobs: - name: Deploy run: | ssh ${{ env.K3S_USER }}@${{ env.K3S_HOST }} << 'ENDSSH' + cd ~/academia/deploy/k3s + echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl apply -k . echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl rollout restart \ - deployment/student-api deployment/student-frontend -n student-enrollment + deployment/student-api deployment/student-frontend -n academia ENDSSH - name: Wait rollout run: | ssh ${{ env.K3S_USER }}@${{ env.K3S_HOST }} << 'ENDSSH' echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl rollout status \ - deployment/student-api -n student-enrollment --timeout=120s + deployment/student-api -n academia --timeout=120s echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl rollout status \ - deployment/student-frontend -n student-enrollment --timeout=60s + deployment/student-frontend -n academia --timeout=60s ENDSSH - name: Health check run: | - sleep 5 + sleep 10 curl -sf https://${{ env.DOMAIN }}/health || exit 1 curl -sf https://${{ env.DOMAIN }}/ || exit 1 @@ -102,5 +129,5 @@ jobs: run: | ssh ${{ env.K3S_USER }}@${{ env.K3S_HOST }} << 'ENDSSH' echo "${{ secrets.K3S_SUDO_PASS }}" | sudo -S kubectl rollout undo \ - deployment/student-api deployment/student-frontend -n student-enrollment 2>/dev/null || true + deployment/student-api deployment/student-frontend -n academia 2>/dev/null || true ENDSSH