Scheduling infrastructure for absolutely everyone.
ci: reduce e2e-api-v2 test overhead with caching and Jest optimizations (#26331)
Anik Dhabal Babu17224d9df36b
diff --git a/.github/workflows/api-v2-production-build.yml b/.github/workflows/api-v2-production-build.ymlindex a4336b19cb2..177199661f6 100644--- a/.github/workflows/api-v2-production-build.yml+++ b/.github/workflows/api-v2-production-build.yml@@ -6,6 +6,8 @@ on:env:DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}DATABASE_DIRECT_URL: ${{ secrets.CI_DATABASE_URL }}+ TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}+ TURBO_TEAM: ${{ secrets.TURBO_TEAM }}jobs:build:@@ -35,29 +37,11 @@ jobs:- uses: actions/checkout@v4- uses: ./.github/actions/dangerous-git-checkout- uses: ./.github/actions/yarn-install- - name: Cache API v2 production build- uses: actions/cache@v4- id: cache-api-v2-build- env:- cache-name: api-v2-build- key-1: ${{ hashFiles('yarn.lock') }}- key-2: ${{ hashFiles('apps/api/v2/**.[jt]s', 'apps/api/v2/**.[jt]sx', '!**/node_modules') }}- key-3: ${{ github.event.pull_request.number || github.ref }}- # Ensures production-build.yml will always be fresh- key-4: ${{ github.sha }}- with:- path: |- **/dist/**- key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.key-1 }}-${{ env.key-2 }}-${{ env.key-3 }}-${{ env.key-4 }}- - name: Log Cache Hit- if: steps.cache-api-v2-build.outputs.cache-hit == 'true'- run: echo "Cache hit for API v2 build. Skipping build."- - name: Run build- if: steps.cache-api-v2-build.outputs.cache-hit != 'true'+ - name: Generate Prisma schemas+ working-directory: apps/api/v2+ run: yarn workspace @calcom/api-v2 run generate-schemas+ - name: Build API v2 with Turborun: |export NODE_OPTIONS="--max_old_space_size=8192"- yarn workspace @calcom/api-v2 run generate-schemas &&- rm -rf apps/api/v2/node_modules &&- yarn install &&- yarn workspace @calcom/api-v2 run build+ yarn turbo run build --filter=@calcom/api-v2shell: bashdiff --git a/.github/workflows/e2e-api-v2.yml b/.github/workflows/e2e-api-v2.ymlindex d080eb8e298..267c6baf958 100644--- a/.github/workflows/e2e-api-v2.yml+++ b/.github/workflows/e2e-api-v2.yml@@ -27,6 +27,8 @@ env:VAPID_PRIVATE_KEY: ${{ secrets.VAPID_PRIVATE_KEY }}JWT_SECRET: ${{ secrets.CI_JWT_SECRET }}NODE_ENV: ${{ vars.CI_NODE_ENV }}+ TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}+ TURBO_TEAM: ${{ secrets.TURBO_TEAM }}jobs:e2e:timeout-minutes: 20@@ -75,13 +77,22 @@ jobs:- uses: ./.github/actions/dangerous-git-checkout- uses: ./.github/actions/yarn-install- uses: ./.github/actions/cache-db+ - name: Build platform packages with Turbo+ run: |+ yarn turbo run build \+ --filter=@calcom/platform-constants \+ --filter=@calcom/platform-enums \+ --filter=@calcom/platform-utils \+ --filter=@calcom/platform-types \+ --filter=@calcom/platform-libraries \+ --filter=@calcom/trpc- name: Run Testsworking-directory: apps/api/v2run: |- yarn test:e2e --shard=${{ matrix.shard }}/${{ strategy.job-total }}+ yarn test:e2e:ci --shard=${{ matrix.shard }}/${{ strategy.job-total }}EXIT_CODE=$?- echo "yarn test:e2e --shard=${{ matrix.shard }}/${{ strategy.job-total }} command exit code: $EXIT_CODE"+ echo "yarn test:e2e:ci --shard=${{ matrix.shard }}/${{ strategy.job-total }} command exit code: $EXIT_CODE"exit $EXIT_CODE- name: Upload Test Resultsdiff --git a/apps/api/v2/jest-e2e.ts b/apps/api/v2/jest-e2e.tsindex 2112133a39f..59125eebdc6 100644--- a/apps/api/v2/jest-e2e.ts+++ b/apps/api/v2/jest-e2e.ts@@ -18,7 +18,6 @@ const getMaxWorkers = () => {const maxWorkers = getMaxWorkers();const config: Config = {- preset: "ts-jest",moduleFileExtensions: ["js", "json", "ts"],rootDir: ".",moduleNameMapper: {@@ -28,7 +27,15 @@ const config: Config = {testEnvironment: "node",testRegex: ".e2e-spec.ts$",transform: {- "^.+\\.ts$": "ts-jest",+ "^.+\\.ts$": [+ "ts-jest",+ process.env.CI+ ? {+ isolatedModules: true,+ diagnostics: false,+ }+ : {},+ ],},setupFiles: ["<rootDir>/test/setEnvVars.ts", "jest-date-mock"],setupFilesAfterEnv: ["<rootDir>/test/jest.setup-e2e.ts"],diff --git a/apps/api/v2/package.json b/apps/api/v2/package.jsonindex e73c3c82178..5c3734cf033 100644--- a/apps/api/v2/package.json+++ b/apps/api/v2/package.json@@ -26,6 +26,7 @@"test:cov": "yarn dev:build && jest --coverage","test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand","test:e2e": "yarn dev:build && NODE_OPTIONS='--max_old_space_size=8192 --experimental-vm-modules' jest --ci --forceExit --config ./jest-e2e.ts",+ "test:e2e:ci": "NODE_OPTIONS='--max_old_space_size=8192 --experimental-vm-modules' jest --ci --forceExit --config ./jest-e2e.ts","test:e2e:local": "yarn test:e2e --maxWorkers=4","test:e2e:watch": "yarn dev:build && jest --runInBand --detectOpenHandles --forceExit --config ./jest-e2e.ts --watch","prisma": "yarn workspace @calcom/prisma prisma",diff --git a/apps/api/v2/src/modules/organizations/teams/index/organizations-teams.controller.ts b/apps/api/v2/src/modules/organizations/teams/index/organizations-teams.controller.tsindex 9d8a1e20832..479a422d5a2 100644--- a/apps/api/v2/src/modules/organizations/teams/index/organizations-teams.controller.ts+++ b/apps/api/v2/src/modules/organizations/teams/index/organizations-teams.controller.ts@@ -43,7 +43,7 @@ import { plainToClass } from "class-transformer";import { Request } from "express";import { SUCCESS_STATUS, X_CAL_CLIENT_ID } from "@calcom/platform-constants";-import { OrgTeamOutputDto, type SkipTakePagination } from "@calcom/platform-types";+import { OrgTeamOutputDto, SkipTakePagination } from "@calcom/platform-types";import type { Team } from "@calcom/prisma/client";@Controller({