From 11aa888eda67196dc10761fd73daab9722310fb4 Mon Sep 17 00:00:00 2001 From: Connor Prussin Date: Wed, 26 Mar 2025 09:10:53 -0700 Subject: [PATCH] Only build stuff that requires Vercel env to build on Vercel For many of our UI applications, in order to build the package, a number of environment variables must be present. The values for these env vars are stored in Vercel, however not everyone who contributes to this repository will have access to Vercel. This PR modifies the turbo config to not build those packages on `turbo build`. This is generally probably the right thing since we don't want those packages to build in Github Actions either, given the environment is not going to be present in GHA and so the builds would likely fail there too. After this PR, to build any packages that rely on Vercel environments, you will run `turbo build:vercelonly`. Running `turbo build` will build everything else and will exclude anything that depends on the Vercel env. --- .github/workflows/ci-turbo-build.yml | 2 +- .github/workflows/publish-js.yml | 2 +- apps/api-reference/package.json | 2 +- apps/api-reference/turbo.json | 2 +- apps/api-reference/vercel.json | 3 ++- apps/insights/package.json | 2 +- apps/insights/turbo.json | 2 +- apps/insights/vercel.json | 3 ++- apps/staking/package.json | 2 +- apps/staking/turbo.json | 2 +- apps/staking/vercel.json | 3 ++- .../packages/xc_admin_frontend/package.json | 2 +- .../packages/xc_admin_frontend/turbo.json | 2 +- .../packages/xc_admin_frontend/vercel.json | 3 ++- package.json | 1 - turbo.json | 19 +++++++++++++++++++ 16 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-turbo-build.yml b/.github/workflows/ci-turbo-build.yml index eb179bf850..b9b1955f70 100644 --- a/.github/workflows/ci-turbo-build.yml +++ b/.github/workflows/ci-turbo-build.yml @@ -33,4 +33,4 @@ jobs: - name: Cache for Turbo uses: rharkor/caching-for-turbo@v1.5 - name: Build - run: pnpm build:ci + run: pnpm run turbo build diff --git a/.github/workflows/publish-js.yml b/.github/workflows/publish-js.yml index da5750fa20..5093cc0534 100644 --- a/.github/workflows/publish-js.yml +++ b/.github/workflows/publish-js.yml @@ -26,5 +26,5 @@ jobs: run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - run: pnpm build:ci + run: pnpm run turbo build - run: pnpm run publish diff --git a/apps/api-reference/package.json b/apps/api-reference/package.json index af03d2ed42..42815cd082 100644 --- a/apps/api-reference/package.json +++ b/apps/api-reference/package.json @@ -7,7 +7,7 @@ "node": "22" }, "scripts": { - "build": "next build", + "build:vercelonly": "next build", "fix:format": "prettier --write .", "fix:lint": "eslint --fix . --max-warnings 0", "pull:env": "[ $CI ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_gbljYVzp0m5EpCuOF6nZpM4WMFM6 vercel env pull", diff --git a/apps/api-reference/turbo.json b/apps/api-reference/turbo.json index 02dce5c7d2..c558c77a4c 100644 --- a/apps/api-reference/turbo.json +++ b/apps/api-reference/turbo.json @@ -2,7 +2,7 @@ "$schema": "https://turbo.build/schema.json", "extends": ["//"], "tasks": { - "build": { + "build:vercelonly": { "env": [ "WALLETCONNECT_PROJECT_ID", "AMPLITUDE_API_KEY", diff --git a/apps/api-reference/vercel.json b/apps/api-reference/vercel.json index be286409fa..b1aa0da41a 100644 --- a/apps/api-reference/vercel.json +++ b/apps/api-reference/vercel.json @@ -1,4 +1,5 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", - "ignoreCommand": "../../vercel-ignore.sh" + "ignoreCommand": "../../vercel-ignore.sh", + "buildCommand": "turbo run build:vercelonly --filter @pythnetwork/api-reference" } diff --git a/apps/insights/package.json b/apps/insights/package.json index b3442f7ff3..1ba0afd325 100644 --- a/apps/insights/package.json +++ b/apps/insights/package.json @@ -7,7 +7,7 @@ "node": "22" }, "scripts": { - "build": "next build", + "build:vercelonly": "next build", "fix:format": "prettier --write .", "fix:lint:eslint": "eslint --fix .", "fix:lint:stylelint": "stylelint --fix 'src/**/*.scss'", diff --git a/apps/insights/turbo.json b/apps/insights/turbo.json index c6a8e5ea6a..3141a689a9 100644 --- a/apps/insights/turbo.json +++ b/apps/insights/turbo.json @@ -2,7 +2,7 @@ "$schema": "https://turbo.build/schema.json", "extends": ["//"], "tasks": { - "build": { + "build:vercelonly": { "env": [ "VERCEL_ENV", "GOOGLE_ANALYTICS_ID", diff --git a/apps/insights/vercel.json b/apps/insights/vercel.json index be286409fa..c978616ffb 100644 --- a/apps/insights/vercel.json +++ b/apps/insights/vercel.json @@ -1,4 +1,5 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", - "ignoreCommand": "../../vercel-ignore.sh" + "ignoreCommand": "../../vercel-ignore.sh", + "buildCommand": "turbo run build:vercelonly --filter @pythnetwork/insights" } diff --git a/apps/staking/package.json b/apps/staking/package.json index f0c2e237e3..6383747713 100644 --- a/apps/staking/package.json +++ b/apps/staking/package.json @@ -7,7 +7,7 @@ "node": "22" }, "scripts": { - "build": "next build", + "build:vercelonly": "next build", "fix:format": "prettier --write .", "fix:lint": "eslint --fix . --max-warnings 0", "pull:env": "[ $CI ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_3TIYzlYYncZx7wRtfmzG2YUsNzKp vercel env pull", diff --git a/apps/staking/turbo.json b/apps/staking/turbo.json index 1982bac221..cabafa0169 100644 --- a/apps/staking/turbo.json +++ b/apps/staking/turbo.json @@ -2,7 +2,7 @@ "$schema": "https://turbo.build/schema.json", "extends": ["//"], "tasks": { - "build": { + "build:vercelonly": { "env": [ "IP_ALLOWLIST", "GOVERNANCE_ONLY_REGIONS", diff --git a/apps/staking/vercel.json b/apps/staking/vercel.json index be286409fa..477ed07ac4 100644 --- a/apps/staking/vercel.json +++ b/apps/staking/vercel.json @@ -1,4 +1,5 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", - "ignoreCommand": "../../vercel-ignore.sh" + "ignoreCommand": "../../vercel-ignore.sh", + "buildCommand": "turbo run build:vercelonly --filter @pythnetwork/staking" } diff --git a/governance/xc_admin/packages/xc_admin_frontend/package.json b/governance/xc_admin/packages/xc_admin_frontend/package.json index f1471e286e..d3eff1c9f6 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/package.json +++ b/governance/xc_admin/packages/xc_admin_frontend/package.json @@ -6,7 +6,7 @@ "node": "22" }, "scripts": { - "build": "next build", + "build:vercelonly": "next build", "pull:env": "[ $CI ] || VERCEL_ORG_ID=team_BKQrg3JJFLxZyTqpuYtIY0rj VERCEL_PROJECT_ID=prj_TCjesnm3pxM7Ay8oxlTH4xLkkmP9 vercel env pull", "start:dev": "next dev --port 3004", "start:prod": "next start --port 3004", diff --git a/governance/xc_admin/packages/xc_admin_frontend/turbo.json b/governance/xc_admin/packages/xc_admin_frontend/turbo.json index b2a3d39221..5bfac5c51f 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/turbo.json +++ b/governance/xc_admin/packages/xc_admin_frontend/turbo.json @@ -2,7 +2,7 @@ "$schema": "https://turbo.build/schema.json", "extends": ["//"], "tasks": { - "build": { + "build:vercelonly": { "env": [ "BUILD_STANDALONE", "NEXT_PUBLIC_MAINNET_RPC", diff --git a/governance/xc_admin/packages/xc_admin_frontend/vercel.json b/governance/xc_admin/packages/xc_admin_frontend/vercel.json index abc38291e8..249c16e10d 100644 --- a/governance/xc_admin/packages/xc_admin_frontend/vercel.json +++ b/governance/xc_admin/packages/xc_admin_frontend/vercel.json @@ -1,4 +1,5 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", - "ignoreCommand": "../../../../vercel-ignore.sh" + "ignoreCommand": "../../../../vercel-ignore.sh", + "buildCommand": "turbo run build:vercelonly --filter @pythnetwork/xc-admin-frontend" } diff --git a/package.json b/package.json index eb01f6afbb..c57b5f9d19 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "pnpm": "^9.15.3" }, "scripts": { - "build:ci": "turbo build --filter=!./apps/api-reference --filter=!./apps/insights --filter=!./apps/staking", "fix:format": "prettier --write .", "install:modules": "[ $CI ] && true || pnpm install", "publish": "lerna publish from-package --no-private --no-git-tag-version --yes", diff --git a/turbo.json b/turbo.json index 39b6e92795..8aba65e5ed 100644 --- a/turbo.json +++ b/turbo.json @@ -70,6 +70,25 @@ ], "outputs": ["lib/**", "dist/**", ".next/**", "!.next/cache/**"] }, + "build:vercelonly": { + "dependsOn": [ + "//#install:modules", + "pull:env", + "^build", + "build:cjs", + "build:esm" + ], + "inputs": [ + "$TURBO_DEFAULT$", + "!README.md", + "!**/*.test.*", + "!jest.config.js", + "!eslint.config.js", + "!prettier.config.js", + "!vercel.json" + ], + "outputs": ["lib/**", "dist/**", ".next/**", "!.next/cache/**"] + }, "build:cjs": { "dependsOn": ["//#install:modules"], "inputs": [