ci: reduce e2e-api-v2 test overhead with caching and Jest optimizations (#26331)
* perf: increase E2E test shards from 4 to 6 for faster CI Increase the number of parallel E2E test shards from 4 to 6 to reduce overall CI wall-clock time. Each shard runs on a separate 4-vCPU runner with 4 workers, so adding more shards increases total parallelism. This should reduce E2E test time from ~3 minutes per shard to ~2 minutes per shard by distributing tests across more parallel jobs. Co-Authored-By: anik@cal.com <adhabal2002@gmail.com> * update * fix * update * readd * final update * fix flake --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
5 files changed
+31
-28
No files matched your search
@@ -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 Turbo
|
||||
run: |
|
||||
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-v2
|
||||
shell: bash
|
||||
@@ -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 Tests
|
||||
working-directory: apps/api/v2
|
||||
run: |
|
||||
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 Results
|
||||
|
||||
@@ -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"],
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in new issue
Block a user