From c216c835c129ff1adf7680a754bdff9b86a6af5b Mon Sep 17 00:00:00 2001 From: Abanoub Fathy Date: Wed, 3 Apr 2024 04:32:59 +0200 Subject: [PATCH 1/4] add test:ci script in auth service --- auth/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auth/package.json b/auth/package.json index c38dfe5..fab1b35 100644 --- a/auth/package.json +++ b/auth/package.json @@ -4,8 +4,9 @@ "description": "", "main": "index.js", "scripts": { + "start": "nodemon src/index.ts", "test": "jest --watchAll --no-cache", - "start": "nodemon src/index.ts" + "test:ci": "jest" }, "jest": { "preset": "ts-jest", From d15a8ea452f9aaba5140aea069e9f8b87527f28c Mon Sep 17 00:00:00 2001 From: Abanoub Fathy Date: Thu, 4 Apr 2024 03:17:17 +0200 Subject: [PATCH 2/4] add workflow for each service conating tests --- .github/workflows/auth-service-testing.yml | 11 +++++++++++ .github/workflows/orders-service-testing.yml | 11 +++++++++++ .github/workflows/payments-service-testing.yml | 11 +++++++++++ .github/workflows/testing.yml | 12 ------------ .github/workflows/tickets-service-testing.yml | 11 +++++++++++ orders/package.json | 3 ++- payments/package.json | 3 ++- tickets/package.json | 3 ++- 8 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/auth-service-testing.yml create mode 100644 .github/workflows/orders-service-testing.yml create mode 100644 .github/workflows/payments-service-testing.yml delete mode 100644 .github/workflows/testing.yml create mode 100644 .github/workflows/tickets-service-testing.yml diff --git a/.github/workflows/auth-service-testing.yml b/.github/workflows/auth-service-testing.yml new file mode 100644 index 0000000..01b8d8e --- /dev/null +++ b/.github/workflows/auth-service-testing.yml @@ -0,0 +1,11 @@ +name: auth-service-testing + +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd auth && npm install && npm run test:ci diff --git a/.github/workflows/orders-service-testing.yml b/.github/workflows/orders-service-testing.yml new file mode 100644 index 0000000..aefa85f --- /dev/null +++ b/.github/workflows/orders-service-testing.yml @@ -0,0 +1,11 @@ +name: orders-service-testing + +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd orders && npm install && npm run test:ci diff --git a/.github/workflows/payments-service-testing.yml b/.github/workflows/payments-service-testing.yml new file mode 100644 index 0000000..33b7f39 --- /dev/null +++ b/.github/workflows/payments-service-testing.yml @@ -0,0 +1,11 @@ +name: payments-service-testing + +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd payments && npm install && npm run test:ci diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml deleted file mode 100644 index 51ccdfb..0000000 --- a/.github/workflows/testing.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: testing - -on: - pull_request - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - run: cd auth && npm install && npm run test:ci diff --git a/.github/workflows/tickets-service-testing.yml b/.github/workflows/tickets-service-testing.yml new file mode 100644 index 0000000..f05c87b --- /dev/null +++ b/.github/workflows/tickets-service-testing.yml @@ -0,0 +1,11 @@ +name: tickets-service-testing + +on: pull_request + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd tickets && npm install && npm run test:ci diff --git a/orders/package.json b/orders/package.json index 9d5eb12..691c08d 100644 --- a/orders/package.json +++ b/orders/package.json @@ -4,8 +4,9 @@ "description": "", "main": "index.js", "scripts": { + "start": "nodemon src/index.ts", "test": "jest --watchAll --no-cache", - "start": "nodemon src/index.ts" + "test:ci": "jest" }, "jest": { "preset": "ts-jest", diff --git a/payments/package.json b/payments/package.json index 16f1100..f84bbf8 100644 --- a/payments/package.json +++ b/payments/package.json @@ -4,8 +4,9 @@ "description": "", "main": "index.js", "scripts": { + "start": "nodemon src/index.ts", "test": "jest --watchAll --no-cache", - "start": "nodemon src/index.ts" + "test:ci": "jest" }, "jest": { "preset": "ts-jest", diff --git a/tickets/package.json b/tickets/package.json index e25dfed..bbb004e 100644 --- a/tickets/package.json +++ b/tickets/package.json @@ -4,8 +4,9 @@ "description": "", "main": "index.js", "scripts": { + "start": "nodemon src/index.ts", "test": "jest --watchAll --no-cache", - "start": "nodemon src/index.ts" + "test:ci": "jest" }, "jest": { "preset": "ts-jest", From 7b0e9d07adbee44b31ad81304c3ec3984021b748 Mon Sep 17 00:00:00 2001 From: Abanoub Fathy Date: Thu, 4 Apr 2024 03:36:27 +0200 Subject: [PATCH 3/4] make the workflow work only if its service is updated --- .github/workflows/auth-service-testing.yml | 5 ++++- .github/workflows/orders-service-testing.yml | 5 ++++- .github/workflows/payments-service-testing.yml | 5 ++++- .github/workflows/tickets-service-testing.yml | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auth-service-testing.yml b/.github/workflows/auth-service-testing.yml index 01b8d8e..2462079 100644 --- a/.github/workflows/auth-service-testing.yml +++ b/.github/workflows/auth-service-testing.yml @@ -1,6 +1,9 @@ name: auth-service-testing -on: pull_request +on: + pull_request: + paths: + - "auth/**" jobs: build: diff --git a/.github/workflows/orders-service-testing.yml b/.github/workflows/orders-service-testing.yml index aefa85f..96c10dd 100644 --- a/.github/workflows/orders-service-testing.yml +++ b/.github/workflows/orders-service-testing.yml @@ -1,6 +1,9 @@ name: orders-service-testing -on: pull_request +on: + pull_request: + paths: + - "orders/**" jobs: build: diff --git a/.github/workflows/payments-service-testing.yml b/.github/workflows/payments-service-testing.yml index 33b7f39..c11dd67 100644 --- a/.github/workflows/payments-service-testing.yml +++ b/.github/workflows/payments-service-testing.yml @@ -1,6 +1,9 @@ name: payments-service-testing -on: pull_request +on: + pull_request: + paths: + - "payments/**" jobs: build: diff --git a/.github/workflows/tickets-service-testing.yml b/.github/workflows/tickets-service-testing.yml index f05c87b..0992dfc 100644 --- a/.github/workflows/tickets-service-testing.yml +++ b/.github/workflows/tickets-service-testing.yml @@ -1,6 +1,9 @@ name: tickets-service-testing -on: pull_request +on: + pull_request: + paths: + - "tickets/**" jobs: build: From 7d64f315720ab7dbc26664ccc6e700aeb82e3b6a Mon Sep 17 00:00:00 2001 From: Abanoub Fathy Date: Mon, 8 Apr 2024 02:07:43 +0200 Subject: [PATCH 4/4] add initial deployment workflow for auth service --- .github/workflows/auth-service-deployment.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/auth-service-deployment.yml diff --git a/.github/workflows/auth-service-deployment.yml b/.github/workflows/auth-service-deployment.yml new file mode 100644 index 0000000..928f670 --- /dev/null +++ b/.github/workflows/auth-service-deployment.yml @@ -0,0 +1,21 @@ +name: auth-service-deployment + +on: + push: + branches: main + paths: + - "auth/**" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd auth && docker build -t $DOCKER_USER_NAME/auth . + - run: docker login -u $DOCKER_USER_NAME -p $DOCKER_PASSWORD + - run: docker push $DOCKER_USER_NAME/auth + +env: + DOCKER_USER_NAME: ${{ secrets.DOCKER_USER_NAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}