From d574e27f3d3cf894e2c349a397191cde3f6546ea Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 12:53:05 +0530 Subject: [PATCH 01/42] refactor: add dynamic Postman tests and improve CI pipeline for microservices --- .github/workflows/ci.yml | 34 ++- .../Task Manager E2E/create-task.request.yaml | 18 ++ .../Task Manager E2E/dashboard.request.yaml | 5 + .../Task Manager E2E/login.request.yaml | 32 +++ .../Task Manager E2E/register.request.yaml | 24 ++ postman_collection.json | 206 ++++++------------ postman_environment.json | 30 ++- 7 files changed, 188 insertions(+), 161 deletions(-) create mode 100644 postman/collections/Task Manager E2E/create-task.request.yaml create mode 100644 postman/collections/Task Manager E2E/dashboard.request.yaml create mode 100644 postman/collections/Task Manager E2E/login.request.yaml create mode 100644 postman/collections/Task Manager E2E/register.request.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c06255..ab70e66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,16 +31,16 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - name: Build auth-service - run: cd auth-service && mvn clean install + run: mvn -f auth-service/pom.xml clean install -DskipTests - name: Build task-service - run: cd task-service && mvn clean install + run: mvn -f task-service/pom.xml clean install -DskipTests - name: Build api-gateway - run: cd api-gateway && mvn clean install + run: mvn -f api-gateway/pom.xml clean install -DskipTests - name: Build service-registry - run: cd service-registry && mvn clean install + run: mvn -f service-registry/pom.xml clean install -DskipTests - name: Build Docker images run: | @@ -49,29 +49,20 @@ jobs: docker build -t task-manager-gateway ./api-gateway docker build -t task-manager-registry ./service-registry - - name: Build services (compose) - run: docker compose build - - name: Start services run: docker compose up -d - name: Wait for system readiness run: | for i in {1..40}; do - echo "Checking system readiness..." - - auth_status=$(curl -s -o /dev/null -w "%{http_code}" \ - -X POST http://localhost:8090/api/auth/login \ - -H "Content-Type: application/json" \ - -d '{"username":"test","password":"test"}' \ - || echo "000") + echo "Checking gateway..." - task_status=$(curl -s -o /dev/null -w "%{http_code}" \ - http://localhost:8090/api/tasks/dashboard || echo "000") + status=$(curl -s -o /dev/null -w "%{http_code}" \ + http://localhost:8090/api/auth/login || echo "000") - echo "Auth: $auth_status | Task: $task_status" + echo "Status: $status" - if [[ "$auth_status" =~ ^(200|400|401)$ ]] && [[ "$task_status" =~ ^(200|403)$ ]]; then + if [[ "$status" =~ ^(200|400|401)$ ]]; then echo "System is READY ✅" exit 0 fi @@ -92,18 +83,23 @@ jobs: run: npm install -g newman - name: Run Postman tests - run: newman run postman_collection.json -e postman_environment.json + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" - name: Stop services run: docker compose down -v - name: Login to DockerHub + if: github.ref == 'refs/heads/main' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Push Docker images + if: github.ref == 'refs/heads/main' run: | docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth diff --git a/postman/collections/Task Manager E2E/create-task.request.yaml b/postman/collections/Task Manager E2E/create-task.request.yaml new file mode 100644 index 0000000..fbed5b5 --- /dev/null +++ b/postman/collections/Task Manager E2E/create-task.request.yaml @@ -0,0 +1,18 @@ +$kind: http-request +name: create-task +url: "{{baseUrl}}/api/tasks" +method: POST +body: + type: json + content: "{\r + + \ \"title\": \"Task {{username}}\",\r + + \ \"description\": \"Generated dynamically\"\r + + }" +auth: + type: bearer + credentials: + token: auth_token +order: 4503596869659604 diff --git a/postman/collections/Task Manager E2E/dashboard.request.yaml b/postman/collections/Task Manager E2E/dashboard.request.yaml new file mode 100644 index 0000000..00f353f --- /dev/null +++ b/postman/collections/Task Manager E2E/dashboard.request.yaml @@ -0,0 +1,5 @@ +$kind: http-request +name: dashboard +url: "" +method: GET +order: 4503596896278070 diff --git a/postman/collections/Task Manager E2E/login.request.yaml b/postman/collections/Task Manager E2E/login.request.yaml new file mode 100644 index 0000000..40ca044 --- /dev/null +++ b/postman/collections/Task Manager E2E/login.request.yaml @@ -0,0 +1,32 @@ +$kind: http-request +name: login +url: "{{baseUrl}}/api/auth/login" +method: POST +body: + type: json + content: "{\r + + \ \"username\": \"{{username}}\",\r + + \ \"password\": \"{{password}}\"\r + + }" +scripts: + - type: beforeRequest + code: "const json = pm.response.json();\r + + \r + + pm.environment.set(\"auth_token\", json.token);\r + + \r + + pm.test(\"Login success\", function () \r + + {\r + + \ pm.expect(pm.response.code).to.eql(200);\r + + });" + language: text/javascript +order: 4503582524205482 diff --git a/postman/collections/Task Manager E2E/register.request.yaml b/postman/collections/Task Manager E2E/register.request.yaml new file mode 100644 index 0000000..27f0e61 --- /dev/null +++ b/postman/collections/Task Manager E2E/register.request.yaml @@ -0,0 +1,24 @@ +$kind: http-request +name: register +url: "{{baseUrl}}/api/auth/register" +method: POST +body: + type: json + content: "{\r + + \ \"username\": \"{{username}}\",\r + + \ \"password\": \"{{password}}\"\r + + }" +scripts: + - type: beforeRequest + code: "pm.test(\"Register success\", function () \r + + {\r + + \ pm.expect(pm.response.code).to.be.oneOf([200, 400]);\r + + });" + language: text/javascript +order: 4503535441727413 diff --git a/postman_collection.json b/postman_collection.json index 10122e9..df1ca92 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -1,211 +1,143 @@ { "info": { - "name": "Task Manager E2E", + "name": "Task Manager E2E (Dynamic)", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, - "item": [ + "event": [ { - "name": "register-yash", - "request": { - "method": "POST", - "header": [{ "key": "Content-Type", "value": "application/json" }], - "body": { - "mode": "raw", - "raw": "{ \"username\": \"yash\", \"password\": \"123\", \"role\": \"USER\" }" - }, - "url": "{{baseUrl}}/api/auth/register" + "listen": "prerequest", + "script": { + "exec": [ + "const unique = Date.now();", + "const username = 'user_' + unique;", + "const password = 'pass_' + unique;", + "", + "const statuses = ['TODO','IN_PROGRESS','DONE'];", + "const priorities = ['LOW','MEDIUM','HIGH'];", + "", + "const status = statuses[Math.floor(Math.random() * statuses.length)];", + "const priority = priorities[Math.floor(Math.random() * priorities.length)];", + "", + "const today = new Date();", + "const startDate = today.toISOString().split('T')[0];", + "", + "const due = new Date();", + "due.setDate(today.getDate() + 3);", + "const dueDate = due.toISOString().split('T')[0];", + "", + "pm.environment.set('username', username);", + "pm.environment.set('password', password);", + "pm.environment.set('status', status);", + "pm.environment.set('priority', priority);", + "pm.environment.set('startDate', startDate);", + "pm.environment.set('dueDate', dueDate);" + ] } - }, + } + ], - { - "name": "register-rahul", - "request": { - "method": "POST", - "header": [{ "key": "Content-Type", "value": "application/json" }], - "body": { - "mode": "raw", - "raw": "{ \"username\": \"rahul\", \"password\": \"123\", \"role\": \"USER\" }" - }, - "url": "{{baseUrl}}/api/auth/register" - } - }, + "item": [ { - "name": "register-admin", + "name": "register", "request": { "method": "POST", "header": [{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", - "raw": "{ \"username\": \"admin\", \"password\": \"123\", \"role\": \"ADMIN\" }" + "raw": "{ \"username\": \"{{username}}\", \"password\": \"{{password}}\", \"role\": \"USER\" }" }, "url": "{{baseUrl}}/api/auth/register" - } - }, - - { - "name": "login-yash", + }, "event": [{ "listen": "test", "script": { "exec": [ - "if (pm.response.code === 200) {", - " const json = pm.response.json();", - " pm.environment.set('token_yash', json.accessToken);", - "}" + "pm.test('Register success', function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201,400]);", + "});" ] } - }], - "request": { - "method": "POST", - "header": [{ "key": "Content-Type", "value": "application/json" }], - "body": { - "mode": "raw", - "raw": "{ \"username\": \"yash\", \"password\": \"123\" }" - }, - "url": "{{baseUrl}}/api/auth/login" - } + }] }, { - "name": "login-rahul", - "event": [{ - "listen": "test", - "script": { - "exec": [ - "if (pm.response.code === 200) {", - " const json = pm.response.json();", - " pm.environment.set('token_rahul', json.accessToken);", - "}" - ] - } - }], + "name": "login", "request": { "method": "POST", "header": [{ "key": "Content-Type", "value": "application/json" }], "body": { "mode": "raw", - "raw": "{ \"username\": \"rahul\", \"password\": \"123\" }" + "raw": "{ \"username\": \"{{username}}\", \"password\": \"{{password}}\" }" }, "url": "{{baseUrl}}/api/auth/login" - } - }, - - { - "name": "login-admin", + }, "event": [{ "listen": "test", "script": { "exec": [ - "if (pm.response.code === 200) {", - " const json = pm.response.json();", - " pm.environment.set('token_admin', json.accessToken);", - "}" + "const json = pm.response.json();", + "pm.environment.set('auth_token', json.accessToken);", + "", + "pm.test('Login success', function () {", + " pm.response.to.have.status(200);", + "});" ] } - }], - "request": { - "method": "POST", - "header": [{ "key": "Content-Type", "value": "application/json" }], - "body": { - "mode": "raw", - "raw": "{ \"username\": \"admin\", \"password\": \"123\" }" - }, - "url": "{{baseUrl}}/api/auth/login" - } + }] }, { - "name": "create-task-yash", + "name": "create-task", "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" }, - { "key": "Authorization", "value": "Bearer {{token_yash}}" } + { "key": "Authorization", "value": "Bearer {{auth_token}}" } ], "body": { "mode": "raw", - "raw": "{ \"title\": \"Yash Task\", \"description\": \"Only for yash\", \"status\": \"TODO\", \"priority\": \"HIGH\" }" + "raw": "{\n \"title\": \"Task {{username}}\",\n \"description\": \"Generated dynamically\",\n \"status\": \"{{status}}\",\n \"priority\": \"{{priority}}\",\n \"startDate\": \"{{startDate}}\",\n \"dueDate\": \"{{dueDate}}\",\n \"assignedUsername\": \"{{username}}\"\n}" }, "url": "{{baseUrl}}/api/tasks" - } - }, - - { - "name": "create-task-rahul", - "request": { - "method": "POST", - "header": [ - { "key": "Content-Type", "value": "application/json" }, - { "key": "Authorization", "value": "Bearer {{token_rahul}}" } - ], - "body": { - "mode": "raw", - "raw": "{ \"title\": \"Rahul Task\", \"description\": \"Only for rahul\", \"status\": \"TODO\", \"priority\": \"LOW\" }" - }, - "url": "{{baseUrl}}/api/tasks" - } - }, - - { - "name": "dashboard-yash", + }, "event": [{ "listen": "test", "script": { "exec": [ - "pm.test('Status is 200', function () { pm.response.to.have.status(200); });", - "pm.test('Has totalTasks', function () { pm.expect(pm.response.json()).to.have.property('totalTasks'); });" + "pm.test('Task created', function () {", + " pm.response.to.have.status(200);", + "});" ] } - }], - "request": { - "method": "GET", - "header": [ - { "key": "Authorization", "value": "Bearer {{token_yash}}" } - ], - "url": "{{baseUrl}}/api/tasks/dashboard" - } + }] }, { - "name": "dashboard-rahul", - "event": [{ - "listen": "test", - "script": { - "exec": [ - "pm.test('Status is 200', function () { pm.response.to.have.status(200); });", - "pm.test('Has totalTasks', function () { pm.expect(pm.response.json()).to.have.property('totalTasks'); });" - ] - } - }], + "name": "dashboard", "request": { "method": "GET", "header": [ - { "key": "Authorization", "value": "Bearer {{token_rahul}}" } + { "key": "Authorization", "value": "Bearer {{auth_token}}" } ], "url": "{{baseUrl}}/api/tasks/dashboard" - } - }, - - { - "name": "dashboard-admin", + }, "event": [{ "listen": "test", "script": { "exec": [ - "pm.test('Status is 200', function () { pm.response.to.have.status(200); });", - "pm.test('Has totalTasks', function () { pm.expect(pm.response.json()).to.have.property('totalTasks'); });" + "pm.test('Status is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test('Has totalTasks', function () {", + " const json = pm.response.json();", + " pm.expect(json).to.have.property('totalTasks');", + "});" ] } - }], - "request": { - "method": "GET", - "header": [ - { "key": "Authorization", "value": "Bearer {{token_admin}}" } - ], - "url": "{{baseUrl}}/api/tasks/dashboard" - } + }] } ] diff --git a/postman_environment.json b/postman_environment.json index 25aa58c..baeaced 100644 --- a/postman_environment.json +++ b/postman_environment.json @@ -3,23 +3,43 @@ "values": [ { "key": "baseUrl", - "value": "http://13.232.34.24:8090", + "value": "http://localhost:8090", "enabled": true }, { - "key": "token_yash", + "key": "username", "value": "", "enabled": true }, { - "key": "token_rahul", + "key": "password", "value": "", "enabled": true }, { - "key": "token_admin", + "key": "auth_token", + "value": "", + "enabled": true + }, + { + "key": "status", + "value": "", + "enabled": true + }, + { + "key": "priority", + "value": "", + "enabled": true + }, + { + "key": "startDate", + "value": "", + "enabled": true + }, + { + "key": "dueDate", "value": "", "enabled": true } ] -} +} \ No newline at end of file From 74aa9e9d9dc98e97907506fc7447ab4e56c7f8b4 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 12:57:50 +0530 Subject: [PATCH 02/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 194 +++++++++++++++++++-------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab70e66..3b91308 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,100 +15,100 @@ jobs: steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Cache Maven dependencies - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests - - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests - - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests - - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests - - - name: Build Docker images - run: | - docker build -t task-manager-auth ./auth-service - docker build -t task-manager-task ./task-service - docker build -t task-manager-gateway ./api-gateway - docker build -t task-manager-registry ./service-registry - - - name: Start services - run: docker compose up -d - - - name: Wait for system readiness - run: | - for i in {1..40}; do - echo "Checking gateway..." - - status=$(curl -s -o /dev/null -w "%{http_code}" \ - http://localhost:8090/api/auth/login || echo "000") - - echo "Status: $status" - - if [[ "$status" =~ ^(200|400|401)$ ]]; then - echo "System is READY ✅" - exit 0 - fi - - sleep 5 - done - - echo "System NOT ready ❌" - docker compose logs - exit 1 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install Newman - run: npm install -g newman - - - name: Run Postman tests - run: | - newman run postman_collection.json \ - -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" - - - name: Stop services - run: docker compose down -v - - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - - docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task - - docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - - docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests + + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests + + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests + + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests + + - name: Build Docker images + run: | + docker build -t task-manager-auth ./auth-service + docker build -t task-manager-task ./task-service + docker build -t task-manager-gateway ./api-gateway + docker build -t task-manager-registry ./service-registry + + - name: Start services + run: docker compose up -d + + - name: Wait for system readiness + run: | + for i in {1..40}; do + echo "Checking gateway..." + + status=$(curl -s -o /dev/null -w "%{http_code}" \ + http://localhost:8090/api/auth/login || echo "000") + + echo "Status: $status" + + if [[ "$status" =~ ^(200|400|401)$ ]]; then + echo "System is READY ✅" + exit 0 + fi + + sleep 5 + done + + echo "System NOT ready ❌" + docker compose logs + exit 1 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install Newman + run: npm install -g newman + + - name: Run Postman tests + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" + + - name: Stop services + run: docker compose down -v + + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Docker images + if: github.ref == 'refs/heads/main' + run: | + docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + + docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task + + docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + + docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file From 1dd0b1b9d2275e56dffd73c824a18dee80a31883 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:17:16 +0530 Subject: [PATCH 03/42] fix: check login with a wait for Eureka registration first, then Newman --- .github/workflows/ci.yml | 190 ++++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 84 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b91308..92d7f06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,114 +1,136 @@ name: CI/CD Pipeline on: - push: - branches: - - main - - feature/* - pull_request: - branches: - - main +push: +branches: +- main +- feature/* +pull_request: +branches: +- main jobs: - build: - runs-on: ubuntu-latest +build: +runs-on: ubuntu-latest - steps: +steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 - - name: Cache Maven dependencies - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests - - name: Build Docker images - run: | - docker build -t task-manager-auth ./auth-service - docker build -t task-manager-task ./task-service - docker build -t task-manager-gateway ./api-gateway - docker build -t task-manager-registry ./service-registry + - name: Build Docker images + run: | + docker build -t task-manager-auth ./auth-service + docker build -t task-manager-task ./task-service + docker build -t task-manager-gateway ./api-gateway + docker build -t task-manager-registry ./service-registry - - name: Start services - run: docker compose up -d + - name: Start services + run: docker compose up -d - - name: Wait for system readiness - run: | - for i in {1..40}; do - echo "Checking gateway..." + - name: Wait for Eureka + services + run: | + echo "Waiting for services to register in Eureka..." - status=$(curl -s -o /dev/null -w "%{http_code}" \ - http://localhost:8090/api/auth/login || echo "000") + for i in {1..50}; do + echo "Attempt $i..." - echo "Status: $status" + eureka=$(curl -s http://localhost:8761/eureka/apps || true) - if [[ "$status" =~ ^(200|400|401)$ ]]; then - echo "System is READY ✅" - exit 0 - fi + auth=$(echo "$eureka" | grep -c "AUTH-SERVICE" || true) + task=$(echo "$eureka" | grep -c "TASK-SERVICE" || true) - sleep 5 - done + echo "AUTH: $auth | TASK: $task" - echo "System NOT ready ❌" - docker compose logs - exit 1 + if [[ "$auth" -gt 0 && "$task" -gt 0 ]]; then + echo "Services registered in Eureka ✅" + break + fi - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 + sleep 5 + done - - name: Install Newman - run: npm install -g newman + - name: Wait for Gateway readiness + run: | + echo "Waiting for API Gateway..." - - name: Run Postman tests - run: | - newman run postman_collection.json \ - -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" + for i in {1..30}; do + status=$(curl -s -o /dev/null -w "%{http_code}" \ + http://localhost:8090/api/auth/login || echo "000") - - name: Stop services - run: docker compose down -v + echo "Gateway status: $status" - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + if [[ "$status" =~ ^(200|400|401)$ ]]; then + echo "Gateway is READY ✅" + exit 0 + fi - - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + sleep 5 + done - docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task + echo "Gateway NOT ready ❌" + docker compose logs + exit 1 - docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 - docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file + - name: Install Newman + run: npm install -g newman + + - name: Run Postman tests + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" + + - name: Stop services + run: docker compose down -v + + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Docker images + if: github.ref == 'refs/heads/main' + run: | + docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + + docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task + + docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + + docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry From e2ca59daf9b81eb932b49ca0e03fca183a0f2da2 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:21:28 +0530 Subject: [PATCH 04/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92d7f06..9197dd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,6 @@ build: runs-on: ubuntu-latest steps: - - name: Checkout code uses: actions/checkout@v4 @@ -54,30 +53,27 @@ steps: - name: Wait for Eureka + services run: | - echo "Waiting for services to register in Eureka..." - for i in {1..50}; do - echo "Attempt $i..." + echo "Checking Eureka..." eureka=$(curl -s http://localhost:8761/eureka/apps || true) - auth=$(echo "$eureka" | grep -c "AUTH-SERVICE" || true) - task=$(echo "$eureka" | grep -c "TASK-SERVICE" || true) + echo "$eureka" | grep -q "AUTH-SERVICE" + auth=$? - echo "AUTH: $auth | TASK: $task" + echo "$eureka" | grep -q "TASK-SERVICE" + task=$? - if [[ "$auth" -gt 0 && "$task" -gt 0 ]]; then - echo "Services registered in Eureka ✅" + if [ $auth -eq 0 ] && [ $task -eq 0 ]; then + echo "Services registered ✅" break fi sleep 5 done - - name: Wait for Gateway readiness + - name: Wait for Gateway run: | - echo "Waiting for API Gateway..." - for i in {1..30}; do status=$(curl -s -o /dev/null -w "%{http_code}" \ http://localhost:8090/api/auth/login || echo "000") @@ -85,7 +81,7 @@ steps: echo "Gateway status: $status" if [[ "$status" =~ ^(200|400|401)$ ]]; then - echo "Gateway is READY ✅" + echo "Gateway ready ✅" exit 0 fi From 0c54db88b12e667305ff9060ccc7b59fc621252f Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:22:44 +0530 Subject: [PATCH 05/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9197dd1..60ab132 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,7 @@ jobs: build: runs-on: ubuntu-latest +``` steps: - name: Checkout code uses: actions/checkout@v4 @@ -29,6 +30,8 @@ steps: path: ~/.m2 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + # -------- BUILD -------- + - name: Build auth-service run: mvn -f auth-service/pom.xml clean install -DskipTests @@ -41,6 +44,8 @@ steps: - name: Build service-registry run: mvn -f service-registry/pom.xml clean install -DskipTests + # -------- DOCKER -------- + - name: Build Docker images run: | docker build -t task-manager-auth ./auth-service @@ -51,6 +56,8 @@ steps: - name: Start services run: docker compose up -d + # -------- WAIT FOR EUREKA -------- + - name: Wait for Eureka + services run: | for i in {1..50}; do @@ -72,6 +79,8 @@ steps: sleep 5 done + # -------- WAIT FOR GATEWAY -------- + - name: Wait for Gateway run: | for i in {1..30}; do @@ -92,6 +101,8 @@ steps: docker compose logs exit 1 + # -------- TEST -------- + - name: Setup Node uses: actions/setup-node@v4 with: @@ -106,9 +117,13 @@ steps: -e postman_environment.json \ --env-var "baseUrl=http://localhost:8090" + # -------- CLEANUP -------- + - name: Stop services run: docker compose down -v + # -------- PUSH (ONLY MAIN) -------- + - name: Login to DockerHub if: github.ref == 'refs/heads/main' uses: docker/login-action@v3 @@ -130,3 +145,4 @@ steps: docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry +``` From 308050adea28f37e4d7317d74f72a6c86fd6945b Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:23:58 +0530 Subject: [PATCH 06/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60ab132..03e4df9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,6 @@ jobs: build: runs-on: ubuntu-latest -``` steps: - name: Checkout code uses: actions/checkout@v4 @@ -145,4 +144,3 @@ steps: docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry -``` From 2f9f9d4332eb76268cdaf6501727c18865671188 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:28:07 +0530 Subject: [PATCH 07/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 207 ++++++++++++++++++--------------------- 1 file changed, 94 insertions(+), 113 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03e4df9..c08d1e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,146 +1,127 @@ name: CI/CD Pipeline on: -push: -branches: -- main -- feature/* -pull_request: -branches: -- main + push: + branches: + - main + - feature/* + pull_request: + branches: + - main jobs: -build: -runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest -steps: - - name: Checkout code - uses: actions/checkout@v4 + steps: + - name: Checkout code + uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 - - name: Cache Maven dependencies - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - # -------- BUILD -------- + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests + - name: Build Docker images + run: | + docker build -t task-manager-auth ./auth-service + docker build -t task-manager-task ./task-service + docker build -t task-manager-gateway ./api-gateway + docker build -t task-manager-registry ./service-registry - # -------- DOCKER -------- + - name: Start services + run: docker compose up -d - - name: Build Docker images - run: | - docker build -t task-manager-auth ./auth-service - docker build -t task-manager-task ./task-service - docker build -t task-manager-gateway ./api-gateway - docker build -t task-manager-registry ./service-registry + - name: Wait for Eureka + services + run: | + for i in {1..50}; do + eureka=$(curl -s http://localhost:8761/eureka/apps || true) - - name: Start services - run: docker compose up -d + echo "$eureka" | grep -q "AUTH-SERVICE" + auth=$? - # -------- WAIT FOR EUREKA -------- + echo "$eureka" | grep -q "TASK-SERVICE" + task=$? - - name: Wait for Eureka + services - run: | - for i in {1..50}; do - echo "Checking Eureka..." + if [ $auth -eq 0 ] && [ $task -eq 0 ]; then + exit 0 + fi - eureka=$(curl -s http://localhost:8761/eureka/apps || true) + sleep 5 + done - echo "$eureka" | grep -q "AUTH-SERVICE" - auth=$? + docker compose logs + exit 1 - echo "$eureka" | grep -q "TASK-SERVICE" - task=$? + - name: Wait for Gateway + run: | + for i in {1..30}; do + status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") - if [ $auth -eq 0 ] && [ $task -eq 0 ]; then - echo "Services registered ✅" - break - fi + if [[ "$status" =~ ^(200|400|401)$ ]]; then + exit 0 + fi - sleep 5 - done + sleep 5 + done - # -------- WAIT FOR GATEWAY -------- + docker compose logs + exit 1 - - name: Wait for Gateway - run: | - for i in {1..30}; do - status=$(curl -s -o /dev/null -w "%{http_code}" \ - http://localhost:8090/api/auth/login || echo "000") + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 - echo "Gateway status: $status" + - name: Install Newman + run: npm install -g newman - if [[ "$status" =~ ^(200|400|401)$ ]]; then - echo "Gateway ready ✅" - exit 0 - fi + - name: Run Postman tests + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" - sleep 5 - done + - name: Stop services + run: docker compose down -v - echo "Gateway NOT ready ❌" - docker compose logs - exit 1 + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - # -------- TEST -------- + - name: Push Docker images + if: github.ref == 'refs/heads/main' + run: | + docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 + docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task - - name: Install Newman - run: npm install -g newman + docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - - name: Run Postman tests - run: | - newman run postman_collection.json \ - -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" - - # -------- CLEANUP -------- - - - name: Stop services - run: docker compose down -v - - # -------- PUSH (ONLY MAIN) -------- - - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - - docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task - - docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - - docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file From 49b0103c00068ef6f15d196e363676a59aeb9721 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:38:58 +0530 Subject: [PATCH 08/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c08d1e0..6d7b69b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: - name: Wait for Eureka + services run: | - for i in {1..50}; do + for i in $(seq 1 50); do eureka=$(curl -s http://localhost:8761/eureka/apps || true) echo "$eureka" | grep -q "AUTH-SERVICE" @@ -63,27 +63,33 @@ jobs: task=$? if [ $auth -eq 0 ] && [ $task -eq 0 ]; then + echo "Services registered" exit 0 fi sleep 5 done + echo "Eureka NOT ready" docker compose logs exit 1 - name: Wait for Gateway run: | - for i in {1..30}; do + for i in $(seq 1 30); do status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") - if [[ "$status" =~ ^(200|400|401)$ ]]; then + echo "Status: $status" + + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + echo "Gateway ready" exit 0 fi sleep 5 done + echo "Gateway NOT ready" docker compose logs exit 1 @@ -124,4 +130,4 @@ jobs: docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry From 6c18731dd870f449d55db8fc1a55b7442589b4fb Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:44:53 +0530 Subject: [PATCH 09/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 264 +++++++++++++++++++++------------------ 1 file changed, 143 insertions(+), 121 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d7b69b..01eecf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,133 +1,155 @@ name: CI/CD Pipeline on: - push: - branches: - - main - - feature/* - pull_request: - branches: - - main +push: +branches: +- main +- feature/* +pull_request: +branches: +- main jobs: - build: - runs-on: ubuntu-latest +build: +runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 +steps: + - name: Checkout code + uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Cache Maven dependencies - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests - - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests - - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests - - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests - - - name: Build Docker images - run: | - docker build -t task-manager-auth ./auth-service - docker build -t task-manager-task ./task-service - docker build -t task-manager-gateway ./api-gateway - docker build -t task-manager-registry ./service-registry - - - name: Start services - run: docker compose up -d - - - name: Wait for Eureka + services - run: | - for i in $(seq 1 50); do - eureka=$(curl -s http://localhost:8761/eureka/apps || true) - - echo "$eureka" | grep -q "AUTH-SERVICE" - auth=$? - - echo "$eureka" | grep -q "TASK-SERVICE" - task=$? - - if [ $auth -eq 0 ] && [ $task -eq 0 ]; then - echo "Services registered" - exit 0 - fi - - sleep 5 - done - - echo "Eureka NOT ready" - docker compose logs - exit 1 - - - name: Wait for Gateway - run: | - for i in $(seq 1 30); do - status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") - - echo "Status: $status" - - if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then - echo "Gateway ready" - exit 0 - fi - - sleep 5 - done - - echo "Gateway NOT ready" - docker compose logs - exit 1 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install Newman - run: npm install -g newman - - - name: Run Postman tests - run: | - newman run postman_collection.json \ - -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" - - - name: Stop services - run: docker compose down -v - - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests - docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests + + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests + + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests + + - name: Build Docker images + run: | + docker build -t task-manager-auth ./auth-service + docker build -t task-manager-task ./task-service + docker build -t task-manager-gateway ./api-gateway + docker build -t task-manager-registry ./service-registry + + - name: Start services + run: docker compose up -d + + - name: Wait before readiness checks + run: sleep 20 + + - name: Wait for Eureka to be ready + run: | + for i in $(seq 1 50); do + code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") + echo "Eureka status: $code" + + if [ "$code" = "200" ]; then + echo "Eureka is ready" + exit 0 + fi + + sleep 5 + done + + echo "Eureka NOT ready" + docker compose logs + exit 1 + + - name: Wait for AUTH-SERVICE and TASK-SERVICE in Eureka + run: | + for i in $(seq 1 50); do + eureka=$(curl -s http://localhost:8761/eureka/apps || true) + + echo "$eureka" | grep -q "AUTH-SERVICE" + auth=$? + + echo "$eureka" | grep -q "TASK-SERVICE" + task=$? + + echo "AUTH=$auth TASK=$task" + + if [ $auth -eq 0 ] && [ $task -eq 0 ]; then + echo "Services registered in Eureka" + exit 0 + fi + + sleep 5 + done + + echo "Services NOT registered in Eureka" + docker compose logs + exit 1 + + - name: Wait for Gateway + run: | + for i in $(seq 1 30); do + status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") + echo "Gateway status: $status" + + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + echo "Gateway ready" + exit 0 + fi + + sleep 5 + done + + echo "Gateway NOT ready" + docker compose logs + exit 1 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install Newman + run: npm install -g newman - docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + - name: Run Postman tests + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" - docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + - name: Stop services + run: docker compose down -v + + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Docker images + if: github.ref == 'refs/heads/main' + run: | + docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + + docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task + + docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + + docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file From a3d43eefca20e87ccd966245eac1c5d74e692128 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:46:47 +0530 Subject: [PATCH 10/42] fix: correct YAML indentation in CI pipeline --- api-gateway/src/main/resources/application-docker.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api-gateway/src/main/resources/application-docker.properties b/api-gateway/src/main/resources/application-docker.properties index 245fe44..eb485ec 100644 --- a/api-gateway/src/main/resources/application-docker.properties +++ b/api-gateway/src/main/resources/application-docker.properties @@ -2,8 +2,8 @@ server.port=8080 spring.application.name=api-gateway eureka.client.serviceUrl.defaultZone=http://service-registry:8761/eureka spring.cloud.gateway.routes[0].id=auth -spring.cloud.gateway.routes[0].uri=lb://auth-service +spring.cloud.gateway.routes[0].uri=lb://AUTH-SERVICE spring.cloud.gateway.routes[0].predicates[0]=Path=/api/auth/** spring.cloud.gateway.routes[1].id=task -spring.cloud.gateway.routes[1].uri=lb://task-service +spring.cloud.gateway.routes[1].uri=lb://TASK-SERVICE spring.cloud.gateway.routes[1].predicates[0]=Path=/api/tasks/** From 9f9b62ee376e698b9f37165fb6ec0c371e9bb429 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:50:41 +0530 Subject: [PATCH 11/42] fix: correct YAML indentation in CI pipeline --- .github/workflows/ci.yml | 281 ++++++++++++++++++--------------------- 1 file changed, 131 insertions(+), 150 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01eecf8..7e89578 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,155 +1,136 @@ name: CI/CD Pipeline on: -push: -branches: -- main -- feature/* -pull_request: -branches: -- main + push: + branches: + - main + - feature/* + pull_request: + branches: + - main jobs: -build: -runs-on: ubuntu-latest - -steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Cache Maven dependencies - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests - - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests - - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests - - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests - - - name: Build Docker images - run: | - docker build -t task-manager-auth ./auth-service - docker build -t task-manager-task ./task-service - docker build -t task-manager-gateway ./api-gateway - docker build -t task-manager-registry ./service-registry - - - name: Start services - run: docker compose up -d - - - name: Wait before readiness checks - run: sleep 20 - - - name: Wait for Eureka to be ready - run: | - for i in $(seq 1 50); do - code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") - echo "Eureka status: $code" - - if [ "$code" = "200" ]; then - echo "Eureka is ready" - exit 0 - fi - - sleep 5 - done - - echo "Eureka NOT ready" - docker compose logs - exit 1 - - - name: Wait for AUTH-SERVICE and TASK-SERVICE in Eureka - run: | - for i in $(seq 1 50); do - eureka=$(curl -s http://localhost:8761/eureka/apps || true) - - echo "$eureka" | grep -q "AUTH-SERVICE" - auth=$? - - echo "$eureka" | grep -q "TASK-SERVICE" - task=$? - - echo "AUTH=$auth TASK=$task" - - if [ $auth -eq 0 ] && [ $task -eq 0 ]; then - echo "Services registered in Eureka" - exit 0 - fi - - sleep 5 - done - - echo "Services NOT registered in Eureka" - docker compose logs - exit 1 - - - name: Wait for Gateway - run: | - for i in $(seq 1 30); do - status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") - echo "Gateway status: $status" - - if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then - echo "Gateway ready" - exit 0 - fi - - sleep 5 - done - - echo "Gateway NOT ready" - docker compose logs - exit 1 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install Newman - run: npm install -g newman - - - name: Run Postman tests - run: | - newman run postman_collection.json \ - -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" - - - name: Stop services - run: docker compose down -v - - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - - docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task - - docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - - docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests + + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests + + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests + + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests + + - name: Build Docker images + run: | + docker build -t task-manager-auth ./auth-service + docker build -t task-manager-task ./task-service + docker build -t task-manager-gateway ./api-gateway + docker build -t task-manager-registry ./service-registry + + - name: Start services + run: docker compose up -d + + - name: Wait before readiness checks + run: sleep 20 + + - name: Wait for Eureka to be ready + run: | + for i in $(seq 1 50); do + code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") + echo "Eureka status: $code" + if [ "$code" = "200" ]; then + exit 0 + fi + sleep 5 + done + docker compose logs + exit 1 + + - name: Wait for AUTH-SERVICE and TASK-SERVICE in Eureka + run: | + for i in $(seq 1 50); do + eureka=$(curl -s http://localhost:8761/eureka/apps || true) + echo "$eureka" | grep -q "AUTH-SERVICE" + auth=$? + echo "$eureka" | grep -q "TASK-SERVICE" + task=$? + if [ $auth -eq 0 ] && [ $task -eq 0 ]; then + exit 0 + fi + sleep 5 + done + docker compose logs + exit 1 + + - name: Wait for Gateway + run: | + for i in $(seq 1 30); do + status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") + echo "Gateway status: $status" + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + exit 0 + fi + sleep 5 + done + docker compose logs + exit 1 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install Newman + run: npm install -g newman + + - name: Run Postman tests + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" + + - name: Stop services + run: docker compose down -v + + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Docker images + if: github.ref == 'refs/heads/main' + run: | + docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + + docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task + + docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + + docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file From 2890a7d932fe86e18ae31d9fc3ee7ad31c9b9ed1 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 13:57:39 +0530 Subject: [PATCH 12/42] fix: stable CI pipeline with proper docker-compose startup --- .github/workflows/ci.yml | 42 +++++++++++++++++++++++----------------- docker-compose.yml | 22 +++++---------------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e89578..c966275 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,21 +42,21 @@ jobs: run: mvn -f service-registry/pom.xml clean install -DskipTests - name: Build Docker images - run: | - docker build -t task-manager-auth ./auth-service - docker build -t task-manager-task ./task-service - docker build -t task-manager-gateway ./api-gateway - docker build -t task-manager-registry ./service-registry + run: docker compose build - name: Start services run: docker compose up -d - name: Wait before readiness checks - run: sleep 20 + run: sleep 40 + + - name: Debug containers + run: | + docker compose ps - - name: Wait for Eureka to be ready + - name: Wait for Eureka run: | - for i in $(seq 1 50); do + for i in $(seq 1 60); do code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") echo "Eureka status: $code" if [ "$code" = "200" ]; then @@ -64,36 +64,42 @@ jobs: fi sleep 5 done - docker compose logs + docker compose logs --no-color exit 1 - - name: Wait for AUTH-SERVICE and TASK-SERVICE in Eureka + - name: Wait for services registration run: | - for i in $(seq 1 50); do + for i in $(seq 1 60); do eureka=$(curl -s http://localhost:8761/eureka/apps || true) + echo "$eureka" | grep -q "AUTH-SERVICE" auth=$? + echo "$eureka" | grep -q "TASK-SERVICE" task=$? + if [ $auth -eq 0 ] && [ $task -eq 0 ]; then exit 0 fi + sleep 5 done - docker compose logs + docker compose logs --no-color exit 1 - name: Wait for Gateway run: | - for i in $(seq 1 30); do + for i in $(seq 1 40); do status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") echo "Gateway status: $status" + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then exit 0 fi + sleep 5 done - docker compose logs + docker compose logs --no-color exit 1 - name: Setup Node @@ -123,14 +129,14 @@ jobs: - name: Push Docker images if: github.ref == 'refs/heads/main' run: | - docker tag task-manager-auth ${{ secrets.DOCKER_USERNAME }}/task-manager-auth + docker tag task-manager-microservices-auth-service ${{ secrets.DOCKER_USERNAME }}/task-manager-auth docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - docker tag task-manager-task ${{ secrets.DOCKER_USERNAME }}/task-manager-task + docker tag task-manager-microservices-task-service ${{ secrets.DOCKER_USERNAME }}/task-manager-task docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task - docker tag task-manager-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway + docker tag task-manager-microservices-api-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - docker tag task-manager-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + docker tag task-manager-microservices-service-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 94e54fb..d5961bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,29 +4,23 @@ services: service-registry: build: ./service-registry - container_name: service-registry ports: - "8761:8761" networks: - microservices-net environment: - SPRING_PROFILES_ACTIVE=docker + redis: image: redis:7 - container_name: redis ports: - "6379:6379" command: ["redis-server", "--bind", "0.0.0.0", "--protected-mode", "no"] networks: - microservices-net - healthcheck: - test: ["CMD", "redis-cli", "ping"] - interval: 5s - timeout: 3s - retries: 5 + auth-service: build: ./auth-service - container_name: auth-service ports: - "8085:8081" depends_on: @@ -39,15 +33,11 @@ services: task-service: build: ./task-service - container_name: task-service ports: - "8082:8082" depends_on: - service-registry : - condition: service_started - redis : - condition: service_healthy - restart: always + - service-registry + - redis environment: - SPRING_PROFILES_ACTIVE=docker networks: @@ -55,7 +45,6 @@ services: api-gateway: build: ./api-gateway - container_name: api-gateway ports: - "8090:8080" depends_on: @@ -69,5 +58,4 @@ services: networks: microservices-net: - driver: bridge - + driver: bridge \ No newline at end of file From 40dd642d863cfd3c521e114047852761cc8792e7 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 14:14:20 +0530 Subject: [PATCH 13/42] removed docker-application.properties --- api-gateway/docker-application.properties | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 api-gateway/docker-application.properties diff --git a/api-gateway/docker-application.properties b/api-gateway/docker-application.properties deleted file mode 100644 index 2199cec..0000000 --- a/api-gateway/docker-application.properties +++ /dev/null @@ -1,12 +0,0 @@ -server.port=8080 -spring.application.name=api-gateway - -eureka.client.service-url.defaultZone=http://service-registry:8761/eureka - -spring.cloud.gateway.routes[0].id=auth -spring.cloud.gateway.routes[0].uri=lb://auth-service -spring.cloud.gateway.routes[0].predicates[0]=Path=/api/auth/** - -spring.cloud.gateway.routes[1].id=task -spring.cloud.gateway.routes[1].uri=lb://task-service -spring.cloud.gateway.routes[1].predicates[0]=Path=/api/tasks/** From 214d956089e1020106608a250d7441909bc6566f Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 15:32:20 +0530 Subject: [PATCH 14/42] fix: gateway readiness + routing stability in CI --- .github/workflows/ci.yml | 23 ++++++++++++++++--- .../resources/application-docker.properties | 2 ++ docker-compose.yml | 11 +++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c966275..fbf8174 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,12 +51,11 @@ jobs: run: sleep 40 - name: Debug containers - run: | - docker compose ps + run: docker compose ps - name: Wait for Eureka run: | - for i in $(seq 1 60); do + for i in $(seq 1 80); do code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") echo "Eureka status: $code" if [ "$code" = "200" ]; then @@ -87,6 +86,24 @@ jobs: docker compose logs --no-color exit 1 + - name: Wait for Gateway route resolution + run: | + for i in $(seq 1 40); do + resp=$(curl -s http://localhost:8090/actuator/gateway/routes || true) + + echo "$resp" | grep -q "AUTH-SERVICE" + if [ $? -eq 0 ]; then + echo "Gateway routing ready" + exit 0 + fi + + sleep 5 + done + + echo "Gateway routing NOT ready" + docker compose logs --no-color + exit 1 + - name: Wait for Gateway run: | for i in $(seq 1 40); do diff --git a/api-gateway/src/main/resources/application-docker.properties b/api-gateway/src/main/resources/application-docker.properties index eb485ec..0ff94ee 100644 --- a/api-gateway/src/main/resources/application-docker.properties +++ b/api-gateway/src/main/resources/application-docker.properties @@ -7,3 +7,5 @@ spring.cloud.gateway.routes[0].predicates[0]=Path=/api/auth/** spring.cloud.gateway.routes[1].id=task spring.cloud.gateway.routes[1].uri=lb://TASK-SERVICE spring.cloud.gateway.routes[1].predicates[0]=Path=/api/tasks/** +spring.cloud.gateway.discovery.locator.enabled=true +spring.cloud.loadbalancer.retry.enabled=true diff --git a/docker-compose.yml b/docker-compose.yml index d5961bf..d9e4c64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,9 +48,12 @@ services: ports: - "8090:8080" depends_on: - - service-registry - - auth-service - - task-service + service-registry : + condition: service_started + auth-service : + condition: service_started + task-service : + condition: service_started environment: - SPRING_PROFILES_ACTIVE=docker networks: @@ -58,4 +61,4 @@ services: networks: microservices-net: - driver: bridge \ No newline at end of file + driver: bridge From 9f82194fdec21e19cf3b805df61ae3a789376a76 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 15:40:07 +0530 Subject: [PATCH 15/42] fix: stable CI with real gateway readiness check --- .github/workflows/ci.yml | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbf8174..4539ecf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: run: docker compose up -d - name: Wait before readiness checks - run: sleep 40 + run: sleep 60 - name: Debug containers run: docker compose ps @@ -86,36 +86,26 @@ jobs: docker compose logs --no-color exit 1 - - name: Wait for Gateway route resolution + - name: Wait for Gateway (real routing check) run: | - for i in $(seq 1 40); do - resp=$(curl -s http://localhost:8090/actuator/gateway/routes || true) + for i in $(seq 1 50); do + status=$(curl -s -o /dev/null -w "%{http_code}" \ + -X POST http://localhost:8090/api/auth/login \ + -H "Content-Type: application/json" \ + -d '{"username":"test","password":"test"}' \ + || echo "000") - echo "$resp" | grep -q "AUTH-SERVICE" - if [ $? -eq 0 ]; then - echo "Gateway routing ready" - exit 0 - fi - - sleep 5 - done - - echo "Gateway routing NOT ready" - docker compose logs --no-color - exit 1 - - - name: Wait for Gateway - run: | - for i in $(seq 1 40); do - status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8090/api/auth/login || echo "000") echo "Gateway status: $status" if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + echo "Gateway ready" exit 0 fi sleep 5 done + + echo "Gateway NOT ready" docker compose logs --no-color exit 1 @@ -156,4 +146,4 @@ jobs: docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway docker tag task-manager-microservices-service-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry \ No newline at end of file + docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry From 323abe62df7bf2e92ff89b7992949f168723f30c Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 16:00:21 +0530 Subject: [PATCH 16/42] fix: pre-request should run only once --- .github/workflows/ci.yml | 2 ++ postman_collection.json | 54 ++++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4539ecf..cd4edaa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,6 +122,8 @@ jobs: newman run postman_collection.json \ -e postman_environment.json \ --env-var "baseUrl=http://localhost:8090" + --env-var "username=" \ + --env-var "password=" - name: Stop services run: docker compose down -v diff --git a/postman_collection.json b/postman_collection.json index df1ca92..86b4416 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -9,29 +9,32 @@ "listen": "prerequest", "script": { "exec": [ - "const unique = Date.now();", - "const username = 'user_' + unique;", - "const password = 'pass_' + unique;", + "if (!pm.environment.get('username')) {", + " const unique = Date.now();", "", - "const statuses = ['TODO','IN_PROGRESS','DONE'];", - "const priorities = ['LOW','MEDIUM','HIGH'];", + " const username = 'user_' + unique;", + " const password = 'pass_' + unique;", "", - "const status = statuses[Math.floor(Math.random() * statuses.length)];", - "const priority = priorities[Math.floor(Math.random() * priorities.length)];", + " const statuses = ['TODO','IN_PROGRESS','DONE'];", + " const priorities = ['LOW','MEDIUM','HIGH'];", "", - "const today = new Date();", - "const startDate = today.toISOString().split('T')[0];", + " const status = statuses[Math.floor(Math.random() * statuses.length)];", + " const priority = priorities[Math.floor(Math.random() * priorities.length)];", "", - "const due = new Date();", - "due.setDate(today.getDate() + 3);", - "const dueDate = due.toISOString().split('T')[0];", + " const today = new Date();", + " const startDate = today.toISOString().split('T')[0];", "", - "pm.environment.set('username', username);", - "pm.environment.set('password', password);", - "pm.environment.set('status', status);", - "pm.environment.set('priority', priority);", - "pm.environment.set('startDate', startDate);", - "pm.environment.set('dueDate', dueDate);" + " const due = new Date();", + " due.setDate(today.getDate() + 3);", + " const dueDate = due.toISOString().split('T')[0];", + "", + " pm.environment.set('username', username);", + " pm.environment.set('password', password);", + " pm.environment.set('status', status);", + " pm.environment.set('priority', priority);", + " pm.environment.set('startDate', startDate);", + " pm.environment.set('dueDate', dueDate);", + "}" ] } } @@ -78,11 +81,14 @@ "script": { "exec": [ "const json = pm.response.json();", - "pm.environment.set('auth_token', json.accessToken);", "", "pm.test('Login success', function () {", - " pm.response.to.have.status(200);", - "});" + " pm.expect(pm.response.code).to.eql(200);", + "});", + "", + "if (pm.response.code === 200) {", + " pm.environment.set('auth_token', json.accessToken || json.token);", + "}" ] } }] @@ -107,7 +113,7 @@ "script": { "exec": [ "pm.test('Task created', function () {", - " pm.response.to.have.status(200);", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", "});" ] } @@ -127,8 +133,8 @@ "listen": "test", "script": { "exec": [ - "pm.test('Status is 200', function () {", - " pm.response.to.have.status(200);", + "pm.test('Dashboard OK', function () {", + " pm.expect(pm.response.code).to.eql(200);", "});", "", "pm.test('Has totalTasks', function () {", From 9c46bcabbbc74c58471390d51f21e0beb8669014 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 16:12:52 +0530 Subject: [PATCH 17/42] fix: shell syntax for env --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd4edaa..3a1f8e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,7 +123,8 @@ jobs: -e postman_environment.json \ --env-var "baseUrl=http://localhost:8090" --env-var "username=" \ - --env-var "password=" + --env-var "password=" \ + --env-var "auth_token=" - name: Stop services run: docker compose down -v From 8c32c385d99f0b4fef8dd4d32b5b95d453286a2c Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 16:18:41 +0530 Subject: [PATCH 18/42] fix: shell syntax for env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a1f8e9..e286135 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,7 +121,7 @@ jobs: run: | newman run postman_collection.json \ -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" + --env-var "baseUrl=http://localhost:8090" \ --env-var "username=" \ --env-var "password=" \ --env-var "auth_token=" From c3339ae1bbcbcadd62668099613799a2451f1cb5 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 16:59:00 +0530 Subject: [PATCH 19/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 13 +------------ docker-compose.yml | 4 ++++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e286135..594c6e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,15 +138,4 @@ jobs: - name: Push Docker images if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-microservices-auth-service ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-auth - - docker tag task-manager-microservices-task-service ${{ secrets.DOCKER_USERNAME }}/task-manager-task - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-task - - docker tag task-manager-microservices-api-gateway ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-gateway - - docker tag task-manager-microservices-service-registry ${{ secrets.DOCKER_USERNAME }}/task-manager-registry - docker push ${{ secrets.DOCKER_USERNAME }}/task-manager-registry + run: docker compose push diff --git a/docker-compose.yml b/docker-compose.yml index d9e4c64..1572d18 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: service-registry: build: ./service-registry + image: yash9912/task-manager-registry ports: - "8761:8761" networks: @@ -21,6 +22,7 @@ services: auth-service: build: ./auth-service + image: yash9912/task-manager-auth ports: - "8085:8081" depends_on: @@ -33,6 +35,7 @@ services: task-service: build: ./task-service + image: yash9912/task-manager-task ports: - "8082:8082" depends_on: @@ -45,6 +48,7 @@ services: api-gateway: build: ./api-gateway + image: yash9912/task-manager-gateway ports: - "8090:8080" depends_on: From d18c1dbf988d0e4b65876cd13aa7940af2599fe2 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 17:09:37 +0530 Subject: [PATCH 20/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 594c6e5..a706aac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: run: mvn -f service-registry/pom.xml clean install -DskipTests - name: Build Docker images - run: docker compose build + run: docker compose build --no-cache - name: Start services run: docker compose up -d @@ -86,7 +86,7 @@ jobs: docker compose logs --no-color exit 1 - - name: Wait for Gateway (real routing check) + - name: Wait for Gateway run: | for i in $(seq 1 50); do status=$(curl -s -o /dev/null -w "%{http_code}" \ @@ -121,14 +121,14 @@ jobs: run: | newman run postman_collection.json \ -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" \ - --env-var "username=" \ - --env-var "password=" \ - --env-var "auth_token=" + --env-var "baseUrl=http://localhost:8090" - name: Stop services run: docker compose down -v + - name: Debug Docker images + run: docker images + - name: Login to DockerHub if: github.ref == 'refs/heads/main' uses: docker/login-action@v3 @@ -138,4 +138,4 @@ jobs: - name: Push Docker images if: github.ref == 'refs/heads/main' - run: docker compose push + run: docker compose push \ No newline at end of file From 595d23601718b806ec8b1af20249b729a2d2a2ae Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 17:36:32 +0530 Subject: [PATCH 21/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a706aac..e65b0a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,6 +136,18 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Tag Docker images + if: github.ref == 'refs/heads/main' + run: | + docker tag task-manager-microservices-auth-service yash9912/task-manager-auth:latest + docker tag task-manager-microservices-task-service yash9912/task-manager-task:latest + docker tag task-manager-microservices-api-gateway yash9912/task-manager-gateway:latest + docker tag task-manager-microservices-service-registry yash9912/task-manager-registry:latest + - name: Push Docker images if: github.ref == 'refs/heads/main' - run: docker compose push \ No newline at end of file + run: | + docker push yash9912/task-manager-auth + docker push yash9912/task-manager-task + docker push yash9912/task-manager-gateway + docker push yash9912/task-manager-registry From 7f4ee0f2ba8de98a5cb377f4d81e0ac30a18170f Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 17:50:03 +0530 Subject: [PATCH 22/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e65b0a7..6f20699 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,23 +131,14 @@ jobs: - name: Login to DockerHub if: github.ref == 'refs/heads/main' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Tag Docker images - if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-microservices-auth-service yash9912/task-manager-auth:latest - docker tag task-manager-microservices-task-service yash9912/task-manager-task:latest - docker tag task-manager-microservices-api-gateway yash9912/task-manager-gateway:latest - docker tag task-manager-microservices-service-registry yash9912/task-manager-registry:latest + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Push Docker images - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' run: | - docker push yash9912/task-manager-auth - docker push yash9912/task-manager-task - docker push yash9912/task-manager-gateway + docker push yash9912/task-manager-auth + docker push yash9912/task-manager-task + docker push yash9912/task-manager-gateway docker push yash9912/task-manager-registry + - name: Verify Docker login + run: docker info From d001ba18f2ad788329c2773115487b79c3c353a6 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 17:51:10 +0530 Subject: [PATCH 23/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f20699..2d64238 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,5 +140,6 @@ jobs: docker push yash9912/task-manager-task docker push yash9912/task-manager-gateway docker push yash9912/task-manager-registry + - name: Verify Docker login run: docker info From 8338b680f311f2a50212176393517e2dffc5b192 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 17:54:42 +0530 Subject: [PATCH 24/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d64238..85b7481 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,11 +134,11 @@ jobs: run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Push Docker images - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' run: | - docker push yash9912/task-manager-auth - docker push yash9912/task-manager-task - docker push yash9912/task-manager-gateway + docker push yash9912/task-manager-auth + docker push yash9912/task-manager-task + docker push yash9912/task-manager-gateway docker push yash9912/task-manager-registry - name: Verify Docker login From c9fae21dec41c876b53a984e6eeff92cc2a8e987 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 18:20:46 +0530 Subject: [PATCH 25/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85b7481..b2f39c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,6 +140,3 @@ jobs: docker push yash9912/task-manager-task docker push yash9912/task-manager-gateway docker push yash9912/task-manager-registry - - - name: Verify Docker login - run: docker info From 2e6eca01ddde39bc25de11bf85574f4b41ca2f48 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 18:28:41 +0530 Subject: [PATCH 26/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2f39c3..cc27d81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,12 +131,19 @@ jobs: - name: Login to DockerHub if: github.ref == 'refs/heads/main' - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + run: | + echo "Logging in..." + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Verify login + if: github.ref == 'refs/heads/main' + run: docker info - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - docker push yash9912/task-manager-auth - docker push yash9912/task-manager-task - docker push yash9912/task-manager-gateway - docker push yash9912/task-manager-registry + if: github.ref == 'refs/heads/main' + run: | + set -x + docker push yash9912/task-manager-auth:latest + docker push yash9912/task-manager-task:latest + docker push yash9912/task-manager-gateway:latest + docker push yash9912/task-manager-registry:latest From 30c2bd4015c7cdd9d0de20184f84d8406f38b5cb Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 18:30:54 +0530 Subject: [PATCH 27/42] fix:docker hub login and push images in CI --- .github/workflows/ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc27d81..cd89aaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,18 +132,18 @@ jobs: - name: Login to DockerHub if: github.ref == 'refs/heads/main' run: | - echo "Logging in..." - echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + echo "Logging in..." + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Verify login - if: github.ref == 'refs/heads/main' - run: docker info + if: github.ref == 'refs/heads/main' + run: docker info - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - set -x - docker push yash9912/task-manager-auth:latest - docker push yash9912/task-manager-task:latest - docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest + if: github.ref == 'refs/heads/main' + run: | + set -x + docker push yash9912/task-manager-auth:latest + docker push yash9912/task-manager-task:latest + docker push yash9912/task-manager-gateway:latest + docker push yash9912/task-manager-registry:latest \ No newline at end of file From 7e5c722577dc3ab0271a51559f1b152254d70230 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 18:45:43 +0530 Subject: [PATCH 28/42] fix: docker tagging + stable CI --- .github/workflows/ci.yml | 264 ++++++++++++++++++--------------------- 1 file changed, 120 insertions(+), 144 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd89aaf..b53682d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,149 +1,125 @@ name: CI/CD Pipeline on: - push: - branches: - - main - - feature/* - pull_request: - branches: - - main +push: +branches: +- main +- feature/* +pull_request: +branches: +- main jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Cache Maven dependencies - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests - - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests - - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests - - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests - - - name: Build Docker images - run: docker compose build --no-cache - - - name: Start services - run: docker compose up -d - - - name: Wait before readiness checks - run: sleep 60 - - - name: Debug containers - run: docker compose ps - - - name: Wait for Eureka - run: | - for i in $(seq 1 80); do - code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") - echo "Eureka status: $code" - if [ "$code" = "200" ]; then - exit 0 - fi - sleep 5 - done - docker compose logs --no-color - exit 1 - - - name: Wait for services registration - run: | - for i in $(seq 1 60); do - eureka=$(curl -s http://localhost:8761/eureka/apps || true) - - echo "$eureka" | grep -q "AUTH-SERVICE" - auth=$? - - echo "$eureka" | grep -q "TASK-SERVICE" - task=$? - - if [ $auth -eq 0 ] && [ $task -eq 0 ]; then - exit 0 - fi - - sleep 5 - done - docker compose logs --no-color - exit 1 - - - name: Wait for Gateway - run: | - for i in $(seq 1 50); do - status=$(curl -s -o /dev/null -w "%{http_code}" \ - -X POST http://localhost:8090/api/auth/login \ - -H "Content-Type: application/json" \ - -d '{"username":"test","password":"test"}' \ - || echo "000") - - echo "Gateway status: $status" - - if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then - echo "Gateway ready" - exit 0 - fi - - sleep 5 - done - - echo "Gateway NOT ready" - docker compose logs --no-color - exit 1 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install Newman - run: npm install -g newman - - - name: Run Postman tests - run: | - newman run postman_collection.json \ - -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" - - - name: Stop services - run: docker compose down -v - - - name: Debug Docker images - run: docker images - - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' - run: | - echo "Logging in..." - echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - - - name: Verify login - if: github.ref == 'refs/heads/main' - run: docker info - - - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - set -x - docker push yash9912/task-manager-auth:latest - docker push yash9912/task-manager-task:latest - docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest \ No newline at end of file +build: +runs-on: ubuntu-latest + +steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + # -------- BUILD -------- + + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests + + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests + + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests + + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests + + # -------- DOCKER -------- + + - name: Build Docker images + run: docker compose build --no-cache + + - name: Start services + run: docker compose up -d + + # -------- WAIT FOR SYSTEM -------- + + - name: Wait for system readiness + run: | + echo "Waiting for system..." + + for i in $(seq 1 80); do + status=$(curl -s -o /dev/null -w "%{http_code}" \ + -X POST http://localhost:8090/api/auth/login \ + -H "Content-Type: application/json" \ + -d '{"username":"test","password":"test"}' \ + || echo "000") + + echo "Gateway status: $status" + + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + echo "System READY ✅" + exit 0 + fi + + sleep 5 + done + + echo "System NOT ready ❌" + docker compose logs --no-color + exit 1 + + # -------- TESTING -------- + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install Newman + run: npm install -g newman + + - name: Run Postman tests + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" + + # -------- CLEANUP -------- + + - name: Stop services + run: docker compose down -v + + # -------- DOCKER PUSH (MAIN ONLY) -------- + + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Tag Docker images + if: github.ref == 'refs/heads/main' + run: | + docker tag task-manager-microservices-auth-service yash9912/task-manager-auth:latest + docker tag task-manager-microservices-task-service yash9912/task-manager-task:latest + docker tag task-manager-microservices-api-gateway yash9912/task-manager-gateway:latest + docker tag task-manager-microservices-service-registry yash9912/task-manager-registry:latest + + - name: Push Docker images + if: github.ref == 'refs/heads/main' + run: | + docker push yash9912/task-manager-auth:latest + docker push yash9912/task-manager-task:latest + docker push yash9912/task-manager-gateway:latest + docker push yash9912/task-manager-registry:latest From b2b3f974827f605b4aacb647d488df8249af2e5a Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 18:51:35 +0530 Subject: [PATCH 29/42] fix: docker tagging + stable CI --- .github/workflows/ci.yml | 258 +++++++++++++++++++++------------------ 1 file changed, 138 insertions(+), 120 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b53682d..efff63f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,125 +1,143 @@ name: CI/CD Pipeline on: -push: -branches: -- main -- feature/* -pull_request: -branches: -- main + push: + branches: + - main + - feature/* + pull_request: + branches: + - main jobs: -build: -runs-on: ubuntu-latest - -steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Cache Maven dependencies - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - # -------- BUILD -------- - - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests - - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests - - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests - - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests - - # -------- DOCKER -------- - - - name: Build Docker images - run: docker compose build --no-cache - - - name: Start services - run: docker compose up -d - - # -------- WAIT FOR SYSTEM -------- - - - name: Wait for system readiness - run: | - echo "Waiting for system..." - - for i in $(seq 1 80); do - status=$(curl -s -o /dev/null -w "%{http_code}" \ - -X POST http://localhost:8090/api/auth/login \ - -H "Content-Type: application/json" \ - -d '{"username":"test","password":"test"}' \ - || echo "000") - - echo "Gateway status: $status" - - if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then - echo "System READY ✅" - exit 0 - fi - - sleep 5 - done - - echo "System NOT ready ❌" - docker compose logs --no-color - exit 1 - - # -------- TESTING -------- - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install Newman - run: npm install -g newman - - - name: Run Postman tests - run: | - newman run postman_collection.json \ - -e postman_environment.json \ - --env-var "baseUrl=http://localhost:8090" - - # -------- CLEANUP -------- - - - name: Stop services - run: docker compose down -v - - # -------- DOCKER PUSH (MAIN ONLY) -------- - - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Tag Docker images - if: github.ref == 'refs/heads/main' - run: | - docker tag task-manager-microservices-auth-service yash9912/task-manager-auth:latest - docker tag task-manager-microservices-task-service yash9912/task-manager-task:latest - docker tag task-manager-microservices-api-gateway yash9912/task-manager-gateway:latest - docker tag task-manager-microservices-service-registry yash9912/task-manager-registry:latest - - - name: Push Docker images - if: github.ref == 'refs/heads/main' - run: | - docker push yash9912/task-manager-auth:latest - docker push yash9912/task-manager-task:latest - docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests + + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests + + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests + + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests + + - name: Build Docker images + run: docker compose build --no-cache + + - name: Start services + run: docker compose up -d + + - name: Wait before readiness checks + run: sleep 60 + + - name: Debug containers + run: docker compose ps + + - name: Wait for Eureka + run: | + for i in $(seq 1 80); do + code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") + echo "Eureka status: $code" + if [ "$code" = "200" ]; then + exit 0 + fi + sleep 5 + done + docker compose logs --no-color + exit 1 + + - name: Wait for services registration + run: | + for i in $(seq 1 60); do + eureka=$(curl -s http://localhost:8761/eureka/apps || true) + + echo "$eureka" | grep -q "AUTH-SERVICE" + auth=$? + + echo "$eureka" | grep -q "TASK-SERVICE" + task=$? + + if [ $auth -eq 0 ] && [ $task -eq 0 ]; then + exit 0 + fi + + sleep 5 + done + + docker compose logs --no-color + exit 1 + + - name: Wait for Gateway + run: | + for i in $(seq 1 50); do + status=$(curl -s -o /dev/null -w "%{http_code}" \ + -X POST http://localhost:8090/api/auth/login \ + -H "Content-Type: application/json" \ + -d '{"username":"test","password":"test"}' \ + || echo "000") + + echo "Gateway status: $status" + + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + echo "Gateway ready" + exit 0 + fi + + sleep 5 + done + + echo "Gateway NOT ready" + docker compose logs --no-color + exit 1 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install Newman + run: npm install -g newman + + - name: Run Postman tests + run: | + newman run postman_collection.json \ + -e postman_environment.json \ + --env-var "baseUrl=http://localhost:8090" + + - name: Stop services + run: docker compose down -v + + - name: Debug Docker images + run: docker images + + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Push Docker images + if: github.ref == 'refs/heads/main' + run: | + docker push yash9912/task-manager-auth:latest + docker push yash9912/task-manager-task:latest + docker push yash9912/task-manager-gateway:latest + docker push yash9912/task-manager-registry:latest \ No newline at end of file From 0629eac9763486f579355153736a153e486f5c1f Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 19:00:14 +0530 Subject: [PATCH 30/42] fix: docker tagging + stable CI --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efff63f..f01790c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,12 +132,16 @@ jobs: - name: Login to DockerHub if: github.ref == 'refs/heads/main' - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + run: | + set -euxo pipefail + docker logout || true + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Push Docker images if: github.ref == 'refs/heads/main' run: | + set -euxo pipefail docker push yash9912/task-manager-auth:latest docker push yash9912/task-manager-task:latest docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest \ No newline at end of file + docker push yash9912/task-manager-registry:latest From b49174c83fed42a58b0a7539be1bbc4067a0ce62 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 19:09:28 +0530 Subject: [PATCH 31/42] fix: docker tagging + stable CI --- .github/workflows/ci.yml | 75 ++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f01790c..762639f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,21 +29,18 @@ jobs: path: ~/.m2 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests - - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests - - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests - - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests + # ---------------- BUILD ---------------- + - name: Build services + run: | + mvn -f auth-service/pom.xml clean install -DskipTests + mvn -f task-service/pom.xml clean install -DskipTests + mvn -f api-gateway/pom.xml clean install -DskipTests + mvn -f service-registry/pom.xml clean install -DskipTests - name: Build Docker images run: docker compose build --no-cache + # ---------------- TEST ---------------- - name: Start services run: docker compose up -d @@ -57,36 +54,12 @@ jobs: run: | for i in $(seq 1 80); do code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") - echo "Eureka status: $code" - if [ "$code" = "200" ]; then - exit 0 - fi + if [ "$code" = "200" ]; then exit 0; fi sleep 5 done docker compose logs --no-color exit 1 - - name: Wait for services registration - run: | - for i in $(seq 1 60); do - eureka=$(curl -s http://localhost:8761/eureka/apps || true) - - echo "$eureka" | grep -q "AUTH-SERVICE" - auth=$? - - echo "$eureka" | grep -q "TASK-SERVICE" - task=$? - - if [ $auth -eq 0 ] && [ $task -eq 0 ]; then - exit 0 - fi - - sleep 5 - done - - docker compose logs --no-color - exit 1 - - name: Wait for Gateway run: | for i in $(seq 1 50); do @@ -96,17 +69,11 @@ jobs: -d '{"username":"test","password":"test"}' \ || echo "000") - echo "Gateway status: $status" - - if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then - echo "Gateway ready" + if [[ "$status" == "200" || "$status" == "400" || "$status" == "401" ]]; then exit 0 fi - sleep 5 done - - echo "Gateway NOT ready" docker compose logs --no-color exit 1 @@ -127,21 +94,29 @@ jobs: - name: Stop services run: docker compose down -v - - name: Debug Docker images + # ---------------- PUSH FIX ---------------- + - name: List images (debug) run: docker images - - name: Login to DockerHub + - name: Tag images explicitly if: github.ref == 'refs/heads/main' run: | - set -euxo pipefail - docker logout || true - echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + docker tag yash9912/task-manager-auth:latest yash9912/task-manager-auth:latest + docker tag yash9912/task-manager-task:latest yash9912/task-manager-task:latest + docker tag yash9912/task-manager-gateway:latest yash9912/task-manager-gateway:latest + docker tag yash9912/task-manager-registry:latest yash9912/task-manager-registry:latest + + - name: Login to DockerHub + if: github.ref == 'refs/heads/main' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Push Docker images if: github.ref == 'refs/heads/main' run: | - set -euxo pipefail docker push yash9912/task-manager-auth:latest docker push yash9912/task-manager-task:latest docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest + docker push yash9912/task-manager-registry:latest \ No newline at end of file From a13cefd8b14a8bf6044645d211d817f1448509b3 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sat, 25 Apr 2026 19:13:47 +0530 Subject: [PATCH 32/42] fix: docker tagging + stable CI --- .github/workflows/ci.yml | 67 ++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 762639f..dc4fb91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,18 +29,21 @@ jobs: path: ~/.m2 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - # ---------------- BUILD ---------------- - - name: Build services - run: | - mvn -f auth-service/pom.xml clean install -DskipTests - mvn -f task-service/pom.xml clean install -DskipTests - mvn -f api-gateway/pom.xml clean install -DskipTests - mvn -f service-registry/pom.xml clean install -DskipTests + - name: Build auth-service + run: mvn -f auth-service/pom.xml clean install -DskipTests + + - name: Build task-service + run: mvn -f task-service/pom.xml clean install -DskipTests + + - name: Build api-gateway + run: mvn -f api-gateway/pom.xml clean install -DskipTests + + - name: Build service-registry + run: mvn -f service-registry/pom.xml clean install -DskipTests - name: Build Docker images run: docker compose build --no-cache - # ---------------- TEST ---------------- - name: Start services run: docker compose up -d @@ -54,7 +57,10 @@ jobs: run: | for i in $(seq 1 80); do code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") - if [ "$code" = "200" ]; then exit 0; fi + echo "Eureka status: $code" + if [ "$code" = "200" ]; then + exit 0 + fi sleep 5 done docker compose logs --no-color @@ -69,11 +75,17 @@ jobs: -d '{"username":"test","password":"test"}' \ || echo "000") - if [[ "$status" == "200" || "$status" == "400" || "$status" == "401" ]]; then + echo "Gateway status: $status" + + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + echo "Gateway ready" exit 0 fi + sleep 5 done + + echo "Gateway NOT ready" docker compose logs --no-color exit 1 @@ -94,18 +106,9 @@ jobs: - name: Stop services run: docker compose down -v - # ---------------- PUSH FIX ---------------- - - name: List images (debug) + - name: Debug Docker images run: docker images - - name: Tag images explicitly - if: github.ref == 'refs/heads/main' - run: | - docker tag yash9912/task-manager-auth:latest yash9912/task-manager-auth:latest - docker tag yash9912/task-manager-task:latest yash9912/task-manager-task:latest - docker tag yash9912/task-manager-gateway:latest yash9912/task-manager-gateway:latest - docker tag yash9912/task-manager-registry:latest yash9912/task-manager-registry:latest - - name: Login to DockerHub if: github.ref == 'refs/heads/main' uses: docker/login-action@v3 @@ -113,10 +116,22 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push Docker images + - name: Show Docker login user if: github.ref == 'refs/heads/main' - run: | - docker push yash9912/task-manager-auth:latest - docker push yash9912/task-manager-task:latest - docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest \ No newline at end of file + run: docker info | grep Username || true + + - name: Push auth image + if: github.ref == 'refs/heads/main' + run: docker push yash9912/task-manager-auth:latest 2>&1 | tee /tmp/push-auth.log + + - name: Push task image + if: github.ref == 'refs/heads/main' + run: docker push yash9912/task-manager-task:latest 2>&1 | tee /tmp/push-task.log + + - name: Push gateway image + if: github.ref == 'refs/heads/main' + run: docker push yash9912/task-manager-gateway:latest 2>&1 | tee /tmp/push-gateway.log + + - name: Push registry image + if: github.ref == 'refs/heads/main' + run: docker push yash9912/task-manager-registry:latest 2>&1 | tee /tmp/push-registry.log \ No newline at end of file From 93e4e3ec7f00117f86e73c19fde983bdf81a8c82 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 11:41:23 +0530 Subject: [PATCH 33/42] fix: docker push order + cleanup --- .github/workflows/ci.yml | 24 ++++++++---------------- docker-compose.yml | 2 -- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc4fb91..65d753d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,9 +103,6 @@ jobs: -e postman_environment.json \ --env-var "baseUrl=http://localhost:8090" - - name: Stop services - run: docker compose down -v - - name: Debug Docker images run: docker images @@ -120,18 +117,13 @@ jobs: if: github.ref == 'refs/heads/main' run: docker info | grep Username || true - - name: Push auth image + - name: Push images if: github.ref == 'refs/heads/main' - run: docker push yash9912/task-manager-auth:latest 2>&1 | tee /tmp/push-auth.log - - - name: Push task image - if: github.ref == 'refs/heads/main' - run: docker push yash9912/task-manager-task:latest 2>&1 | tee /tmp/push-task.log - - - name: Push gateway image - if: github.ref == 'refs/heads/main' - run: docker push yash9912/task-manager-gateway:latest 2>&1 | tee /tmp/push-gateway.log + run: | + docker push yash9912/task-manager-auth:latest + docker push yash9912/task-manager-task:latest + docker push yash9912/task-manager-gateway:latest + docker push yash9912/task-manager-registry:latest - - name: Push registry image - if: github.ref == 'refs/heads/main' - run: docker push yash9912/task-manager-registry:latest 2>&1 | tee /tmp/push-registry.log \ No newline at end of file + - name: Stop services + run: docker compose down -v \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1572d18..614fbed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.9" - services: service-registry: From 5ee4766f83e7fb641c250921701594d43d7de458 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 11:56:39 +0530 Subject: [PATCH 34/42] fix: docker push order + cleanup --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65d753d..769f156 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,6 +117,9 @@ jobs: if: github.ref == 'refs/heads/main' run: docker info | grep Username || true + - name: Debug Docker login + run: docker info + - name: Push images if: github.ref == 'refs/heads/main' run: | @@ -126,4 +129,5 @@ jobs: docker push yash9912/task-manager-registry:latest - name: Stop services - run: docker compose down -v \ No newline at end of file + run: docker compose down -v + From f87d700e60c353eb963d2f66f647af97aaa7fbdd Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 12:07:55 +0530 Subject: [PATCH 35/42] testing docker images push on feature branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 769f156..09db540 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: run: docker images - name: Login to DockerHub - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/feature/') uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} From 76f2cec04ca5756cd6782a227bd7efc4c9f6cde9 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 12:15:05 +0530 Subject: [PATCH 36/42] remove condition branch push for images --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09db540..71da696 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,8 +106,7 @@ jobs: - name: Debug Docker images run: docker images - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/feature/') + - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} From 6ba7ff694abb782d47b00510b0d21020f0a985a3 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 12:25:39 +0530 Subject: [PATCH 37/42] remove condition branch push for images --- .github/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71da696..9ad4386 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,7 +106,7 @@ jobs: - name: Debug Docker images run: docker images - - name: Login to DockerHub + - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -118,6 +118,16 @@ jobs: - name: Debug Docker login run: docker info + + - name: Tag images + run: | + docker tag task-manager-microservices-auth-service yash9912/task-manager-auth:latest + docker tag task-manager-microservices-task-service yash9912/task-manager-task:latest + docker tag task-manager-microservices-api-gateway yash9912/task-manager-gateway:latest + docker tag task-manager-microservices-service-registry yash9912/task-manager-registry:latest + + - name: Debug images + run: docker images - name: Push images if: github.ref == 'refs/heads/main' From c17ca0fed03ecb83cd48e6eaec341f046ea9431e Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 12:41:15 +0530 Subject: [PATCH 38/42] fix: remove incorrect docker tagging --- .github/workflows/ci.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ad4386..ad00041 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,25 +112,13 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Show Docker login user - if: github.ref == 'refs/heads/main' - run: docker info | grep Username || true - - name: Debug Docker login run: docker info - - name: Tag images - run: | - docker tag task-manager-microservices-auth-service yash9912/task-manager-auth:latest - docker tag task-manager-microservices-task-service yash9912/task-manager-task:latest - docker tag task-manager-microservices-api-gateway yash9912/task-manager-gateway:latest - docker tag task-manager-microservices-service-registry yash9912/task-manager-registry:latest - - name: Debug images run: docker images - name: Push images - if: github.ref == 'refs/heads/main' run: | docker push yash9912/task-manager-auth:latest docker push yash9912/task-manager-task:latest From e885ceffa12b2a76b81ad5747ba008dbd0823241 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 12:55:58 +0530 Subject: [PATCH 39/42] make CI faster --- .github/workflows/ci.yml | 116 ++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 63 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad00041..b5d96a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,100 +2,85 @@ name: CI/CD Pipeline on: push: - branches: - - main - - feature/* + branches: [main, feature/*] pull_request: - branches: - - main + branches: [main] jobs: - build: + + # 🔹 Build all services in parallel + build-services: runs-on: ubuntu-latest + strategy: + matrix: + service: [auth-service, task-service, api-gateway, service-registry] steps: - - name: Checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 + - uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 - - name: Cache Maven dependencies - uses: actions/cache@v4 + - uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - name: Build auth-service - run: mvn -f auth-service/pom.xml clean install -DskipTests + - name: Build ${{ matrix.service }} + run: mvn -f ${{ matrix.service }}/pom.xml clean install -DskipTests - - name: Build task-service - run: mvn -f task-service/pom.xml clean install -DskipTests - - name: Build api-gateway - run: mvn -f api-gateway/pom.xml clean install -DskipTests + # 🔹 Docker + Integration Tests + integration-test: + runs-on: ubuntu-latest + needs: build-services - - name: Build service-registry - run: mvn -f service-registry/pom.xml clean install -DskipTests + steps: + - uses: actions/checkout@v4 - - name: Build Docker images - run: docker compose build --no-cache + - name: Build Docker images (WITH CACHE) + run: docker compose build - name: Start services run: docker compose up -d - - name: Wait before readiness checks - run: sleep 60 - - - name: Debug containers - run: docker compose ps + - name: Wait for services + run: sleep 40 # reduced from 60 - name: Wait for Eureka run: | - for i in $(seq 1 80); do + for i in $(seq 1 40); do code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") echo "Eureka status: $code" - if [ "$code" = "200" ]; then - exit 0 - fi - sleep 5 + [ "$code" = "200" ] && exit 0 + sleep 3 done - docker compose logs --no-color + docker compose logs exit 1 - name: Wait for Gateway run: | - for i in $(seq 1 50); do + for i in $(seq 1 30); do status=$(curl -s -o /dev/null -w "%{http_code}" \ -X POST http://localhost:8090/api/auth/login \ -H "Content-Type: application/json" \ - -d '{"username":"test","password":"test"}' \ - || echo "000") + -d '{"username":"test","password":"test"}' || echo "000") echo "Gateway status: $status" - if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then - echo "Gateway ready" - exit 0 - fi - - sleep 5 + [[ "$status" == "200" || "$status" == "400" || "$status" == "401" ]] && exit 0 + sleep 3 done - - echo "Gateway NOT ready" - docker compose logs --no-color + docker compose logs exit 1 - - name: Setup Node - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: node-version: 18 - - name: Install Newman - run: npm install -g newman + - run: npm install -g newman - name: Run Postman tests run: | @@ -103,28 +88,33 @@ jobs: -e postman_environment.json \ --env-var "baseUrl=http://localhost:8090" - - name: Debug Docker images - run: docker images + - name: Stop services + run: docker compose down -v + - - name: Login to DockerHub + # 🔹 Push images (only on main) + push-images: + runs-on: ubuntu-latest + needs: integration-test + + steps: + - uses: actions/checkout@v4 + + - name: Build images again (fast due to cache) + run: docker compose build + + - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Debug Docker login - run: docker info - - - name: Debug images - run: docker images + - name: Verify login + run: docker info | grep Username - - name: Push images + - name: Push images (with debug) run: | docker push yash9912/task-manager-auth:latest docker push yash9912/task-manager-task:latest docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest - - - name: Stop services - run: docker compose down -v - + docker push yash9912/task-manager-registry:latest \ No newline at end of file From 3a93ce57abd9317ee3cfc81140088bcc44107439 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 13:13:45 +0530 Subject: [PATCH 40/42] make CI faster by parallelizing the service builds and keep the Postman E2E flow sequential --- .github/workflows/ci.yml | 137 ++++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 51 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5d96a0..eff718e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,85 +2,134 @@ name: CI/CD Pipeline on: push: - branches: [main, feature/*] + branches: + - main + - feature/* pull_request: - branches: [main] + branches: + - main jobs: - - # 🔹 Build all services in parallel - build-services: + build-jars: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - service: [auth-service, task-service, api-gateway, service-registry] + service: + - auth-service + - task-service + - api-gateway + - service-registry steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - uses: actions/setup-java@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 - - uses: actions/cache@v4 + - name: Cache Maven dependencies + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - name: Build ${{ matrix.service }} - run: mvn -f ${{ matrix.service }}/pom.xml clean install -DskipTests + run: mvn -f ${{ matrix.service }}/pom.xml clean package -DskipTests + - name: Upload JAR + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.service }}-jar + path: ${{ matrix.service }}/target/*.jar + if-no-files-found: error - # 🔹 Docker + Integration Tests - integration-test: + integration: runs-on: ubuntu-latest - needs: build-services + needs: build-jars steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Cache Maven dependencies + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + - name: Download auth-service jar + uses: actions/download-artifact@v4 + with: + name: auth-service-jar + path: auth-service/target + + - name: Download task-service jar + uses: actions/download-artifact@v4 + with: + name: task-service-jar + path: task-service/target + + - name: Download api-gateway jar + uses: actions/download-artifact@v4 + with: + name: api-gateway-jar + path: api-gateway/target - - name: Build Docker images (WITH CACHE) + - name: Download service-registry jar + uses: actions/download-artifact@v4 + with: + name: service-registry-jar + path: service-registry/target + + - name: Build Docker images run: docker compose build - name: Start services run: docker compose up -d - - name: Wait for services - run: sleep 40 # reduced from 60 - - - name: Wait for Eureka - run: | - for i in $(seq 1 40); do - code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8761/eureka/apps || echo "000") - echo "Eureka status: $code" - [ "$code" = "200" ] && exit 0 - sleep 3 - done - docker compose logs - exit 1 + - name: Wait before readiness checks + run: sleep 40 - name: Wait for Gateway run: | - for i in $(seq 1 30); do + for i in $(seq 1 50); do status=$(curl -s -o /dev/null -w "%{http_code}" \ -X POST http://localhost:8090/api/auth/login \ -H "Content-Type: application/json" \ - -d '{"username":"test","password":"test"}' || echo "000") + -d '{"username":"test","password":"test"}' \ + || echo "000") echo "Gateway status: $status" - [[ "$status" == "200" || "$status" == "400" || "$status" == "401" ]] && exit 0 - sleep 3 + if [ "$status" = "200" ] || [ "$status" = "400" ] || [ "$status" = "401" ]; then + echo "Gateway ready" + exit 0 + fi + + sleep 5 done - docker compose logs + + echo "Gateway NOT ready" + docker compose logs --no-color exit 1 - - uses: actions/setup-node@v4 + - name: Setup Node + uses: actions/setup-node@v4 with: node-version: 18 - - run: npm install -g newman + - name: Install Newman + run: npm install -g newman - name: Run Postman tests run: | @@ -91,28 +140,14 @@ jobs: - name: Stop services run: docker compose down -v - - # 🔹 Push images (only on main) - push-images: - runs-on: ubuntu-latest - needs: integration-test - - steps: - - uses: actions/checkout@v4 - - - name: Build images again (fast due to cache) - run: docker compose build - - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Verify login - run: docker info | grep Username - - - name: Push images (with debug) + - name: Push images + if: github.ref == 'refs/heads/main' run: | docker push yash9912/task-manager-auth:latest docker push yash9912/task-manager-task:latest From 5df4cd74bada80de77175c43a71f97dc7d47dfa9 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 13:17:24 +0530 Subject: [PATCH 41/42] make CI faster by parallelizing the service builds and keep the Postman E2E flow sequential --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eff718e..c918600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,7 +147,6 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Push images - if: github.ref == 'refs/heads/main' run: | docker push yash9912/task-manager-auth:latest docker push yash9912/task-manager-task:latest From a53633ad4ca7ae409e02d567a117f1fe97414457 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Sun, 26 Apr 2026 13:31:27 +0530 Subject: [PATCH 42/42] fix: restrict docker push to main --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c918600..0f8abb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,8 +147,9 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Push images + if: github.ref == 'refs/heads/main' run: | docker push yash9912/task-manager-auth:latest docker push yash9912/task-manager-task:latest docker push yash9912/task-manager-gateway:latest - docker push yash9912/task-manager-registry:latest \ No newline at end of file + docker push yash9912/task-manager-registry:latest \ No newline at end of file