From eb271d47c787db4ab90ba1a38c41f48de7897125 Mon Sep 17 00:00:00 2001 From: rajdip-b Date: Fri, 26 Jul 2024 21:39:59 +0530 Subject: [PATCH 1/4] chore(ci): Disabled platform and api deployments --- .github/workflows/deploy-api.yml | 128 +++++++++++++------------- .github/workflows/deploy-platform.yml | 86 ++++++++--------- 2 files changed, 107 insertions(+), 107 deletions(-) diff --git a/.github/workflows/deploy-api.yml b/.github/workflows/deploy-api.yml index 45ce9a95..0271908f 100644 --- a/.github/workflows/deploy-api.yml +++ b/.github/workflows/deploy-api.yml @@ -17,78 +17,78 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.SECRET_KEY }} - aws-region: ap-south-1 + # - name: Configure AWS credentials + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-access-key-id: ${{ secrets.ACCESS_KEY }} + # aws-secret-access-key: ${{ secrets.SECRET_KEY }} + # aws-region: ap-south-1 - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 + # - name: Login to Amazon ECR + # id: login-ecr + # uses: aws-actions/amazon-ecr-login@v2 - - name: Build Docker image - id: build - env: - ECR_REGISTRY: ${{ vars.ECR_REGISTRY }} - ECR_REPOSITORY: ${{ vars.ECR_API_REPOSITORY }} - run: | - # Build a docker container and push it to ECR - aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin $ECR_REGISTRY - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f ./apps/api/Dockerfile . - echo "Pushing image to ECR..." - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest - docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} - echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT + # - name: Build Docker image + # id: build + # env: + # ECR_REGISTRY: ${{ vars.ECR_REGISTRY }} + # ECR_REPOSITORY: ${{ vars.ECR_API_REPOSITORY }} + # run: | + # # Build a docker container and push it to ECR + # aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin $ECR_REGISTRY + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f ./apps/api/Dockerfile . + # echo "Pushing image to ECR..." + # docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest + # docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} + # echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT - setup-database: - needs: build - name: Setup Database - runs-on: ubuntu-latest - environment: alpha + # setup-database: + # needs: build + # name: Setup Database + # runs-on: ubuntu-latest + # environment: alpha - steps: - - name: Checkout - uses: actions/checkout@v4 + # steps: + # - name: Checkout + # uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 + # - name: Install Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: 20 - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.2.0 - run_install: false + # - name: Install pnpm + # uses: pnpm/action-setup@v4 + # with: + # version: 9.2.0 + # run_install: false - - name: Deploy migrations - env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} - run: pnpm db:deploy-migrations + # - name: Deploy migrations + # env: + # DATABASE_URL: ${{ secrets.DATABASE_URL }} + # run: pnpm db:deploy-migrations - deploy: - needs: [build, setup-database] - runs-on: ubuntu-latest - environment: alpha - name: Deploy API docker image for release + # deploy: + # needs: [build, setup-database] + # runs-on: ubuntu-latest + # environment: alpha + # name: Deploy API docker image for release - steps: - - name: Checkout - uses: actions/checkout@v4 + # steps: + # - name: Checkout + # uses: actions/checkout@v4 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.SECRET_KEY }} - aws-region: ap-south-1 + # - name: Configure AWS credentials + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-access-key-id: ${{ secrets.ACCESS_KEY }} + # aws-secret-access-key: ${{ secrets.SECRET_KEY }} + # aws-region: ap-south-1 - - name: Force re-deploy task in service - id: force-redeploy - env: - ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} - ECS_SERVICE: ${{ vars.ECS_API_SERVICE }} - run: | - aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment + # - name: Force re-deploy task in service + # id: force-redeploy + # env: + # ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} + # ECS_SERVICE: ${{ vars.ECS_API_SERVICE }} + # run: | + # aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment diff --git a/.github/workflows/deploy-platform.yml b/.github/workflows/deploy-platform.yml index 74f293bf..8ac2eeb5 100644 --- a/.github/workflows/deploy-platform.yml +++ b/.github/workflows/deploy-platform.yml @@ -22,52 +22,52 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.SECRET_KEY }} - aws-region: ap-south-1 + # - name: Configure AWS credentials + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-access-key-id: ${{ secrets.ACCESS_KEY }} + # aws-secret-access-key: ${{ secrets.SECRET_KEY }} + # aws-region: ap-south-1 - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 + # - name: Login to Amazon ECR + # id: login-ecr + # uses: aws-actions/amazon-ecr-login@v2 - - name: Build Docker image - id: build - env: - ECR_REGISTRY: ${{ vars.ECR_REGISTRY }} - ECR_REPOSITORY: ${{ vars.ECR_PLATFORM_REPOSITORY }} - run: | - # Build a docker container and push it to ECR - aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin $ECR_REGISTRY - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f ./apps/platform/Dockerfile . - echo "Pushing image to ECR..." - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest - docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} - echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT + # - name: Build Docker image + # id: build + # env: + # ECR_REGISTRY: ${{ vars.ECR_REGISTRY }} + # ECR_REPOSITORY: ${{ vars.ECR_PLATFORM_REPOSITORY }} + # run: | + # # Build a docker container and push it to ECR + # aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin $ECR_REGISTRY + # docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f ./apps/platform/Dockerfile . + # echo "Pushing image to ECR..." + # docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest + # docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6} + # echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT - deploy: - needs: build - runs-on: ubuntu-latest - environment: alpha - name: Deploy Platform docker image for release + # deploy: + # needs: build + # runs-on: ubuntu-latest + # environment: alpha + # name: Deploy Platform docker image for release - steps: - - name: Checkout - uses: actions/checkout@v4 + # steps: + # - name: Checkout + # uses: actions/checkout@v4 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.SECRET_KEY }} - aws-region: ap-south-1 + # - name: Configure AWS credentials + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-access-key-id: ${{ secrets.ACCESS_KEY }} + # aws-secret-access-key: ${{ secrets.SECRET_KEY }} + # aws-region: ap-south-1 - - name: Force re-deploy task in service - id: force-redeploy - env: - ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} - ECS_SERVICE: ${{ vars.ECS_PLATFORM_SERVICE }} - run: | - aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment + # - name: Force re-deploy task in service + # id: force-redeploy + # env: + # ECS_CLUSTER: ${{ vars.ECS_CLUSTER }} + # ECS_SERVICE: ${{ vars.ECS_PLATFORM_SERVICE }} + # run: | + # aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment From ba231836375647ece5f8ba48cea91c96388bd83d Mon Sep 17 00:00:00 2001 From: Dhairya Majmudar <124715224+DhairyaMajmudar@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:32:18 +0530 Subject: [PATCH 2/4] chore(ci): Adding validate pipeline (#372) --- .github/workflows/validate-platform.yaml | 61 +++++++++++++++++++++++ apps/api/src/user/service/user.service.ts | 13 ++++- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/validate-platform.yaml diff --git a/.github/workflows/validate-platform.yaml b/.github/workflows/validate-platform.yaml new file mode 100644 index 00000000..c29b2b67 --- /dev/null +++ b/.github/workflows/validate-platform.yaml @@ -0,0 +1,61 @@ +name: Validate Platform + +on: + push: + branches: + - '!develop' + - '!main' + paths: + [ + 'apps/platform/**', + '.github/workflows/validate-platform.yml', + '.github/workflows/deploy-platform.yml' + ] + pull_request: + paths: + [ + 'apps/platform/**', + '.github/workflows/deploy-platform.yml', + '.github/workflows/validate-platform.yml' + ] + +jobs: + validate: + runs-on: ubuntu-latest + name: Validate Platform + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.2.0 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install packages + run: | + pnpm i + + - name: Lint + run: | + pnpm run lint:platform \ No newline at end of file diff --git a/apps/api/src/user/service/user.service.ts b/apps/api/src/user/service/user.service.ts index b94f7d5c..2b1437e6 100644 --- a/apps/api/src/user/service/user.service.ts +++ b/apps/api/src/user/service/user.service.ts @@ -1,9 +1,18 @@ -import { ConflictException, Inject, Injectable, Logger, UnauthorizedException } from '@nestjs/common' +import { + ConflictException, + Inject, + Injectable, + Logger, + UnauthorizedException +} from '@nestjs/common' import { UpdateUserDto } from '../dto/update.user/update.user' import { AuthProvider, User } from '@prisma/client' import { PrismaService } from '../../prisma/prisma.service' import { CreateUserDto } from '../dto/create.user/create.user' -import { IMailService, MAIL_SERVICE } from '../../mail/services/interface.service' +import { + IMailService, + MAIL_SERVICE +} from '../../mail/services/interface.service' import createUser from '../../common/create-user' import generateOtp from '../../common/generate-otp' import { EnvSchema } from '../../common/env/env.schema' From 898e9c23c22d3f0bdc210acdf52a1cd956e982fb Mon Sep 17 00:00:00 2001 From: Dhairya Majmudar <124715224+DhairyaMajmudar@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:33:37 +0530 Subject: [PATCH 3/4] chore(ci): Add validate CLI pipeline (#373) --- .github/workflows/validate-cli.yaml | 61 +++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/validate-cli.yaml diff --git a/.github/workflows/validate-cli.yaml b/.github/workflows/validate-cli.yaml new file mode 100644 index 00000000..34577cc2 --- /dev/null +++ b/.github/workflows/validate-cli.yaml @@ -0,0 +1,61 @@ +name: Validate Cli + +on: + push: + branches: + - '!develop' + - '!main' + paths: + [ + 'apps/cli/**', + '.github/workflows/validate-cli.yml', + '.github/workflows/deploy-cli.yml' + ] + pull_request: + paths: + [ + 'apps/cli/**', + '.github/workflows/deploy-cli.yml', + '.github/workflows/validate-cli.yml' + ] + +jobs: + validate: + runs-on: ubuntu-latest + name: Validate Cli + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.2.0 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install packages + run: | + pnpm i + + - name: Lint + run: | + pnpm run lint:cli \ No newline at end of file diff --git a/package.json b/package.json index fd845f09..51451c08 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,7 @@ "lint:api": "turbo run lint --filter=api", "lint:web": "turbo run lint --filter=web", "lint:platform": "turbo run lint --filter=platform", + "lint:cli": "turbo run lint --filter=cli", "lint:api-client": "pnpm run --filter=api-client lint", "build": "turbo run build", "build:api": "pnpm db:generate-types && turbo run build --filter=api", From 92daef910056dfcde352bb29f76d82406a454145 Mon Sep 17 00:00:00 2001 From: rajdip-b Date: Sat, 27 Jul 2024 11:52:43 +0530 Subject: [PATCH 4/4] refactor(api): Updated path of some endpoints in project controller --- apps/api/src/project/controller/project.controller.ts | 4 ++-- apps/api/src/project/project.e2e.spec.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/api/src/project/controller/project.controller.ts b/apps/api/src/project/controller/project.controller.ts index bcc8fa51..7c947dc0 100644 --- a/apps/api/src/project/controller/project.controller.ts +++ b/apps/api/src/project/controller/project.controller.ts @@ -68,7 +68,7 @@ export class ProjectController { return await this.service.forkProject(user, projectId, forkMetadata) } - @Put(':projectId/sync-fork') + @Put(':projectId/fork') @RequiredApiKeyAuthorities(Authority.READ_PROJECT, Authority.UPDATE_PROJECT) async syncFork( @CurrentUser() user: User, @@ -78,7 +78,7 @@ export class ProjectController { return await this.service.syncFork(user, projectId, hardSync) } - @Put(':projectId/unlink-fork') + @Delete(':projectId/fork') @RequiredApiKeyAuthorities(Authority.UPDATE_PROJECT) async unlinkFork( @CurrentUser() user: User, diff --git a/apps/api/src/project/project.e2e.spec.ts b/apps/api/src/project/project.e2e.spec.ts index 698dfb6e..4bbb40c2 100644 --- a/apps/api/src/project/project.e2e.spec.ts +++ b/apps/api/src/project/project.e2e.spec.ts @@ -1441,7 +1441,7 @@ describe('Project Controller Tests', () => { // Sync the fork await app.inject({ method: 'PUT', - url: `/project/${forkedProject.id}/sync-fork`, + url: `/project/${forkedProject.id}/fork`, headers: { 'x-e2e-user-email': user2.email } @@ -1631,7 +1631,7 @@ describe('Project Controller Tests', () => { // Sync the fork await app.inject({ method: 'PUT', - url: `/project/${forkedProject.id}/sync-fork?hardSync=true`, + url: `/project/${forkedProject.id}/fork?hardSync=true`, headers: { 'x-e2e-user-email': user2.email } @@ -1666,7 +1666,7 @@ describe('Project Controller Tests', () => { it('should not be able to sync a project that is not forked', async () => { const response = await app.inject({ method: 'PUT', - url: `/project/${project3.id}/sync-fork`, + url: `/project/${project3.id}/fork`, headers: { 'x-e2e-user-email': user1.email } @@ -1690,8 +1690,8 @@ describe('Project Controller Tests', () => { ) const response = await app.inject({ - method: 'PUT', - url: `/project/${forkedProject.id}/unlink-fork`, + method: 'DELETE', + url: `/project/${forkedProject.id}/fork`, headers: { 'x-e2e-user-email': user2.email }