From aaa08821a58c4d8f7c6758f00fa02f7b62a03a62 Mon Sep 17 00:00:00 2001 From: abdellah hariti Date: Tue, 12 Nov 2024 16:40:51 +0100 Subject: [PATCH] Conditional changelog builds (#11770) * move prisma seed config to changelog package.json * get rid of prisma related dependencies and scripts from the main app package.json * fail seed script on errors * skip changelog builds on related source code chnage * simple skip build logic for changelog --- apps/changelog/package.json | 3 +++ apps/changelog/prisma/seed/seed.mjs | 1 + package.json | 9 +-------- skip-build.sh | 11 +++++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/changelog/package.json b/apps/changelog/package.json index f79aa468c46a1..3803d835f56da 100644 --- a/apps/changelog/package.json +++ b/apps/changelog/package.json @@ -14,6 +14,9 @@ "lint": "next lint", "migrate:dev": "dotenv -e .env.development -- yarn prisma migrate reset" }, + "prisma": { + "seed": "node prisma/seed/seed.mjs" + }, "dependencies": { "@auth/prisma-adapter": "^1.2.0", "@google-cloud/storage": "^7.7.0", diff --git a/apps/changelog/prisma/seed/seed.mjs b/apps/changelog/prisma/seed/seed.mjs index 052f2b50ce3e5..fa745011fdd53 100644 --- a/apps/changelog/prisma/seed/seed.mjs +++ b/apps/changelog/prisma/seed/seed.mjs @@ -76,6 +76,7 @@ async function seed() { console.log('Seed data created successfully!'); } catch (error) { console.error('Error seeding data:', error); + process.exit(1); } finally { await prisma.$disconnect(); } diff --git a/package.json b/package.json index 9ae83b51a4be6..bbbc249110441 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,9 @@ "dev": "yarn enforce-redirects && concurrently \"yarn sidecar\" \"node ./src/hotReloadWatcher.mjs\" \"next dev\"", "dev:developer-docs": "yarn enforce-redirects && NEXT_PUBLIC_DEVELOPER_DOCS=1 yarn dev", "build:developer-docs": "yarn enforce-redirects && git submodule init && git submodule update && NEXT_PUBLIC_DEVELOPER_DOCS=1 yarn build", - "build": "yarn enforce-redirects && prisma generate && next build", + "build": "yarn enforce-redirects && next build", "vercel:build:developer-docs": "yarn enforce-redirects && git submodule init && git submodule update && NEXT_PUBLIC_DEVELOPER_DOCS=1 yarn build", "start": "next start", - "migrate:dev": "dotenv -e .env.development -- yarn prisma migrate reset", "lint": "next lint", "lint:ts": "tsc --skipLibCheck", "lint:docs": "bin/lint-docs.ts", @@ -35,12 +34,8 @@ "test:ci": "vitest run", "enforce-redirects": "node ./scripts/no-vercel-json-redirects.mjs" }, - "prisma": { - "seed": "node prisma/seed/seed.mjs" - }, "dependencies": { "@ariakit/react": "^0.4.5", - "@auth/prisma-adapter": "^1.2.0", "@emotion/core": "^11.0.0", "@emotion/react": "^11.11.0", "@emotion/styled": "^11.0.0", @@ -50,7 +45,6 @@ "@next/mdx": "^14.2.4", "@popperjs/core": "^2.11.8", "@prettier/plugin-xml": "^3.3.1", - "@prisma/client": "^5.8.1", "@radix-ui/colors": "^3.0.0", "@radix-ui/react-collapsible": "^1.0.3", "@radix-ui/react-dropdown-menu": "^2.0.6", @@ -126,7 +120,6 @@ "jest-environment-jsdom": "^29.5.0", "postcss": "^8.4.33", "prettier": "^3.2.4", - "prisma": "^5.8.1", "tailwindcss": "^3.4.1", "ts-node": "^10.9.1", "typescript": "^5", diff --git a/skip-build.sh b/skip-build.sh index 49dfbc783f63d..654c6fe0b0025 100755 --- a/skip-build.sh +++ b/skip-build.sh @@ -14,6 +14,17 @@ docs_diff_status=$(git diff HEAD^ HEAD --quiet -- docs includes platform-include # have changes occurred outside of the content directories non_content_diff_status=$(git diff HEAD^ HEAD --name-only | grep -vE '^(docs/|platform-includes/|includes/|develop-docs/)' | wc -l) +# apps/changelog changes or workspace deps changes (yarn.lock) +changelog_diff_status=$(git diff HEAD^ HEAD --name-only | grep -E '^(apps/changelog/|yarn.lock)' | wc -l) + +if [[ "$NEXT_PUBLIC_CHANGELOG" == "1" ]] ; then + if [[ $changelog_diff_status -gt 0 ]] ; then + exit 1 + else + exit 0 + fi +fi + # always build on changes in non-content related directories if [[ $non_content_diff_status -gt 0 ]] ; then exit 1