From 0daeff3422818463077e02d681715a945bf21340 Mon Sep 17 00:00:00 2001 From: rajdip-b Date: Tue, 6 Feb 2024 00:26:30 +0530 Subject: [PATCH] chore(ci): integrated codecov --- .github/workflows/api.yaml | 6 +++++ .github/workflows/web.yaml | 5 ++++ apps/api/project.json | 4 +-- .../migrations/20240205044521_/migration.sql | 8 ------ .../migrations/20240205044826_/migration.sql | 26 ------------------ .../migrations/20240205100104_/migration.sql | 1 - .../migrations/20240205101804_/migration.sql | 2 -- .../migration.sql | 27 ++++++++++++++++++- jest.config.ts | 4 +-- package.json | 4 +-- 10 files changed, 43 insertions(+), 44 deletions(-) delete mode 100644 apps/api/src/prisma/migrations/20240205044521_/migration.sql delete mode 100644 apps/api/src/prisma/migrations/20240205044826_/migration.sql delete mode 100644 apps/api/src/prisma/migrations/20240205100104_/migration.sql delete mode 100644 apps/api/src/prisma/migrations/20240205101804_/migration.sql rename apps/api/src/prisma/migrations/{20240205042913_migrate_role => 20240205190216_migrate_role}/migration.sql (79%) diff --git a/.github/workflows/api.yaml b/.github/workflows/api.yaml index 02ef40c8..5bbad867 100644 --- a/.github/workflows/api.yaml +++ b/.github/workflows/api.yaml @@ -60,6 +60,12 @@ jobs: pnpm run e2e:api docker compose down + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + directory: ./coverage/apps/api + build-api-alpha: needs: validate runs-on: ubuntu-latest diff --git a/.github/workflows/web.yaml b/.github/workflows/web.yaml index 3892851f..c8af925b 100644 --- a/.github/workflows/web.yaml +++ b/.github/workflows/web.yaml @@ -51,6 +51,11 @@ jobs: run: | pnpm run test:web + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + build-web-alpha: needs: validate runs-on: ubuntu-latest diff --git a/apps/api/project.json b/apps/api/project.json index 8b53f765..dc984dde 100644 --- a/apps/api/project.json +++ b/apps/api/project.json @@ -64,9 +64,9 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage-e2e/{projectRoot}"], "options": { + "runInBand": true, "devServerTarget": "api:serve", - "jestConfig": "apps/api/jest.e2e-config.ts", - "runInBand": true + "jestConfig": "apps/api/jest.e2e-config.ts" }, "configurations": { "development": { diff --git a/apps/api/src/prisma/migrations/20240205044521_/migration.sql b/apps/api/src/prisma/migrations/20240205044521_/migration.sql deleted file mode 100644 index b5dcdbb8..00000000 --- a/apps/api/src/prisma/migrations/20240205044521_/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[workspaceId,hasAdminAuthority]` on the table `WorkspaceRole` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "WorkspaceRole_workspaceId_hasAdminAuthority_key" ON "WorkspaceRole"("workspaceId", "hasAdminAuthority"); diff --git a/apps/api/src/prisma/migrations/20240205044826_/migration.sql b/apps/api/src/prisma/migrations/20240205044826_/migration.sql deleted file mode 100644 index df46517f..00000000 --- a/apps/api/src/prisma/migrations/20240205044826_/migration.sql +++ /dev/null @@ -1,26 +0,0 @@ --- DropForeignKey -ALTER TABLE "Project" DROP CONSTRAINT "Project_lastUpdatedById_fkey"; - --- DropForeignKey -ALTER TABLE "Secret" DROP CONSTRAINT "Secret_lastUpdatedById_fkey"; - --- DropForeignKey -ALTER TABLE "SecretVersion" DROP CONSTRAINT "SecretVersion_createdById_fkey"; - --- AlterTable -ALTER TABLE "Project" ALTER COLUMN "lastUpdatedById" DROP NOT NULL; - --- AlterTable -ALTER TABLE "Secret" ALTER COLUMN "lastUpdatedById" DROP NOT NULL; - --- AlterTable -ALTER TABLE "SecretVersion" ALTER COLUMN "createdById" DROP NOT NULL; - --- AddForeignKey -ALTER TABLE "Project" ADD CONSTRAINT "Project_lastUpdatedById_fkey" FOREIGN KEY ("lastUpdatedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SecretVersion" ADD CONSTRAINT "SecretVersion_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Secret" ADD CONSTRAINT "Secret_lastUpdatedById_fkey" FOREIGN KEY ("lastUpdatedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/apps/api/src/prisma/migrations/20240205100104_/migration.sql b/apps/api/src/prisma/migrations/20240205100104_/migration.sql deleted file mode 100644 index af5102c8..00000000 --- a/apps/api/src/prisma/migrations/20240205100104_/migration.sql +++ /dev/null @@ -1 +0,0 @@ --- This is an empty migration. \ No newline at end of file diff --git a/apps/api/src/prisma/migrations/20240205101804_/migration.sql b/apps/api/src/prisma/migrations/20240205101804_/migration.sql deleted file mode 100644 index 0365ee8b..00000000 --- a/apps/api/src/prisma/migrations/20240205101804_/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- DropIndex -DROP INDEX "WorkspaceRole_workspaceId_hasAdminAuthority_key"; diff --git a/apps/api/src/prisma/migrations/20240205042913_migrate_role/migration.sql b/apps/api/src/prisma/migrations/20240205190216_migrate_role/migration.sql similarity index 79% rename from apps/api/src/prisma/migrations/20240205042913_migrate_role/migration.sql rename to apps/api/src/prisma/migrations/20240205190216_migrate_role/migration.sql index adcfed8e..35f0fed7 100644 --- a/apps/api/src/prisma/migrations/20240205042913_migrate_role/migration.sql +++ b/apps/api/src/prisma/migrations/20240205190216_migrate_role/migration.sql @@ -18,6 +18,15 @@ ALTER TABLE "ApiKeyWorkspaceScope" DROP CONSTRAINT "ApiKeyWorkspaceScope_apiKeyI -- DropForeignKey ALTER TABLE "ApiKeyWorkspaceScope" DROP CONSTRAINT "ApiKeyWorkspaceScope_workspaceId_fkey"; +-- DropForeignKey +ALTER TABLE "Project" DROP CONSTRAINT "Project_lastUpdatedById_fkey"; + +-- DropForeignKey +ALTER TABLE "Secret" DROP CONSTRAINT "Secret_lastUpdatedById_fkey"; + +-- DropForeignKey +ALTER TABLE "SecretVersion" DROP CONSTRAINT "SecretVersion_createdById_fkey"; + -- DropIndex DROP INDEX "Workspace_isDefault_ownerId_key"; @@ -29,7 +38,14 @@ ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL; -- AlterTable ALTER TABLE "Project" ADD COLUMN "apiKeyWorkspaceAuthorityId" TEXT, ADD COLUMN "isPublic" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "workspaceRoleId" TEXT; +ADD COLUMN "workspaceRoleId" TEXT, +ALTER COLUMN "lastUpdatedById" DROP NOT NULL; + +-- AlterTable +ALTER TABLE "Secret" ALTER COLUMN "lastUpdatedById" DROP NOT NULL; + +-- AlterTable +ALTER TABLE "SecretVersion" ALTER COLUMN "createdById" DROP NOT NULL; -- AlterTable ALTER TABLE "Workspace" DROP COLUMN "isDefault"; @@ -82,6 +98,9 @@ CREATE UNIQUE INDEX "WorkspaceMemberRoleAssociation_roleId_workspaceMemberId_key -- CreateIndex CREATE UNIQUE INDEX "Workspace_name_ownerId_key" ON "Workspace"("name", "ownerId"); +-- AddForeignKey +ALTER TABLE "Project" ADD CONSTRAINT "Project_lastUpdatedById_fkey" FOREIGN KEY ("lastUpdatedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + -- AddForeignKey ALTER TABLE "Project" ADD CONSTRAINT "Project_workspaceRoleId_fkey" FOREIGN KEY ("workspaceRoleId") REFERENCES "WorkspaceRole"("id") ON DELETE SET NULL ON UPDATE CASCADE; @@ -93,3 +112,9 @@ ALTER TABLE "WorkspaceMemberRoleAssociation" ADD CONSTRAINT "WorkspaceMemberRole -- AddForeignKey ALTER TABLE "WorkspaceMemberRoleAssociation" ADD CONSTRAINT "WorkspaceMemberRoleAssociation_workspaceMemberId_fkey" FOREIGN KEY ("workspaceMemberId") REFERENCES "WorkspaceMember"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "SecretVersion" ADD CONSTRAINT "SecretVersion_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Secret" ADD CONSTRAINT "Secret_lastUpdatedById_fkey" FOREIGN KEY ("lastUpdatedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/jest.config.ts b/jest.config.ts index e861d4fa..15f85d1d 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,5 +1,5 @@ -import { getJestProjects } from '@nx/jest'; +import { getJestProjects } from '@nx/jest' export default { projects: getJestProjects() -}; +} diff --git a/package.json b/package.json index b326fd91..f37f7454 100644 --- a/package.json +++ b/package.json @@ -105,9 +105,9 @@ "build:workspace": "nx run workspace:build", "build:cli": "nx run cli:build", "test": "nx run-many -t test --parallel", - "test:api": "nx run api:test", + "test:api": "nx run api:test -- --collectCoverage --coverageReporters=json", "e2e:api:prepare": "NODE_ENV='e2e' DATABASE_URL='postgresql://prisma:prisma@localhost:5433/tests' pnpm run db:deploy-migrations", - "e2e:api": "pnpm run e2e:api:prepare && NODE_ENV='e2e' DATABASE_URL='postgresql://prisma:prisma@localhost:5433/tests' nx run api:test:e2e", + "e2e:api": "pnpm run e2e:api:prepare && NODE_ENV='e2e' DATABASE_URL='postgresql://prisma:prisma@localhost:5433/tests' nx run api:test:e2e -- --collectCoverage --coverageReporters=json", "test:web": "nx run web:test", "test:workspace": "nx run workspace:test", "test:cli": "nx run cli:test",