Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ Verify a deploy the way Vercel does, not the way CI does:
`cd packages/<app> && CI=1 pnpm install && ./node_modules/.bin/next build`.
A green `pnpm install --frozen-lockfile` at the repo root does not exercise this path.

Because `rootDirectory` is set, Vercel reads `vercel.json` from `packages/<app>/`, not
the repo root. Each package's `vercel.json` wires `scripts/vercel-ignore.sh` as the
Ignored Build Step: it skips Preview builds of `main`/`testnet` (each is production for
one project and a wasted Preview on the others) and skips any build where nothing under
the package or the workspace manifests changed since the last successful deployment.
Every retained deployment holds a ~23 MB function bundle, and Vercel keeps the last 20
production + 20 preview deployments per project regardless of retention policy, so
deployment count is what drives Functions Storage.

## Maintaining this file

Keep this file for knowledge useful to almost every future agent session in this project.
Expand Down
4 changes: 4 additions & 0 deletions packages/app-sol/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"ignoreCommand": "bash \"$(git rev-parse --show-toplevel)/scripts/vercel-ignore.sh\" packages/app-sol"
}
4 changes: 4 additions & 0 deletions packages/app/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"ignoreCommand": "bash \"$(git rev-parse --show-toplevel)/scripts/vercel-ignore.sh\" packages/app"
}
43 changes: 43 additions & 0 deletions scripts/vercel-ignore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Vercel "Ignored Build Step" for one package of this monorepo.
#
# Exit 0 = skip the build, exit 1 = build. Anything uncertain builds.
# Wired from packages/<app>/vercel.json (Vercel reads vercel.json from each
# project's Root Directory, so the shared logic lives here).
#
# Every push used to build all three Vercel projects, and the two deployment
# branches each produced a Preview on the projects they are not production
# for. That tripled Functions Storage for nothing.
set -u
pkg="${1:?usage: vercel-ignore.sh packages/<app>}"
cd "$(git rev-parse --show-toplevel)" || exit 1

# 1. `main` is production for ripguard + ripguard-sol, `testnet` for
# ripguard-testnet. A push to either also triggers a Preview build on the
# other project(s) that nobody looks at.
if [ "${VERCEL_ENV:-}" = "preview" ]; then
case "${VERCEL_GIT_COMMIT_REF:-}" in
main|testnet)
echo "ignore: preview of deployment branch '$VERCEL_GIT_COMMIT_REF'"
exit 0
;;
esac
fi

# 2. Nothing this package depends on changed since the last successful
# deployment of this branch. Compare against that SHA, not HEAD^: a
# fast-forward of `testnet` lands several commits at once and HEAD^ would
# only see the last one. Unknown base (first deploy, shallow clone too
# short) -> build.
base="${VERCEL_GIT_PREVIOUS_SHA:-}"
if [ -n "$base" ] && git cat-file -e "${base}^{commit}" 2>/dev/null; then
if git diff --quiet "$base" HEAD -- \
"$pkg" \
package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc .node-version \
scripts/vercel-ignore.sh; then
echo "ignore: no changes under $pkg or the workspace manifests since ${base:0:7}"
exit 0
fi
fi

exit 1
Loading