Skip to content

Commit

Permalink
Conditional changelog builds (#11770)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
a-hariti authored Nov 12, 2024
1 parent 0717c17 commit aaa0882
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions apps/changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions apps/changelog/prisma/seed/seed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions skip-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aaa0882

Please sign in to comment.