Build, tests & checks
before every release.
One command runs every check: typecheck, lint, format check and the automated test suites. Then the production builds.
01Test databases (once)
The commands on this page are written for a bash shell: Terminal on macOS or Linux. On Windows, run them in WSL 2 (Ubuntu) with Node.js, pnpm and PostgreSQL installed inside WSL, and paste them unchanged. Some commands set a variable in front of the command (DATABASE_URL=... pnpm ...), which PowerShell does not accept; commands that only call pnpm or node also work in PowerShell or Git Bash.
The API, airdrop and E2E tests run against real PostgreSQL databases. Create and migrate them once:
createdb campaign_kit_test
DATABASE_URL=postgres://localhost:5432/campaign_kit_test pnpm db:migrate
createdb campaign_kit_e2e
DATABASE_URL=postgres://localhost:5432/campaign_kit_e2e pnpm db:migrate
The test suites truncate their tables between tests. The airdrop tests refuse a database whose name does not end in _test, the E2E test anything other than campaign_kit_e2e.
02Run the checks
Run everything with one command from the repository root:
pnpm check
pnpm check runs, in this order, and stops at the first failure:
| Step | Command on its own | What it does |
|---|---|---|
| Typecheck | pnpm typecheck | TypeScript check of every package (pnpm -r typecheck). |
| Lint | pnpm lint | ESLint (flat config, eslint.config.js). |
| Format check | pnpm format:check | Prettier, 120 columns. It only reports; pnpm format rewrites the files in place. |
| Tests | pnpm test | Every automated test suite (table below). |
After you change code, run pnpm format first, then pnpm check. pnpm test runs the packages one at a time because the API and airdrop suites share the test database.
The test suites
337 automated tests in total:
| Suite | Tests | What it covers |
|---|---|---|
API (apps/api) | 141 | Against a real PostgreSQL database: auth, game, quests, referrals, shop, ads callback, wallets, admin, seasons, squads, puzzles, fairness, analytics, links, reports, broadcasts, sponsors, revenue, clone, /paysupport, edits that keep unsent fields, start-up checks and /health; Telegram calls mocked |
Admin (apps/admin) | 69 | Pages and forms |
Mini App (apps/miniapp) | 60 | Screens, launch parameters, claim transaction |
Airdrop (packages/airdrop) | 24 | Signals, allocation, fair multipliers, publish, distributor address check |
Contract (packages/ton-claim) | 27 | The Tact distributor contract in a TON sandbox (real TVM emulation in @ton/sandbox) |
Shared (packages/shared) | 7 | Economy maths |
On-chain E2E (e2e) | 9 | Full airdrop chain in the sandbox: API, database, contract, claims, withdraw |
The E2E test writes its result to e2e/results/airdrop-e2e.json.
The automated tests mock the Telegram Bot API and run the contract in a sandbox. Telegram itself is connected by you: create your bot in @BotFather, test Stars payments in Telegram's test environment and run the airdrop on TON testnet before mainnet (see the Go-live checklist).
03Production builds
| Command | Output |
|---|---|
pnpm --filter @kit/api build | apps/api/dist/index.js + dist/migrate.js (the Docker image does this for you) |
pnpm --filter @kit/miniapp build | apps/miniapp/dist + generated TON Connect manifest |
pnpm --filter @kit/admin build | apps/admin/dist + TON Connect manifest |
pnpm --filter @kit/ton-claim build | Only when you change the contract (Tact compile + wrappers) |
04Go-live checklist
/healthanswers over https with"database":"ok"and the API start-up log shows no production warnings; Workspace settings show https and the right network.- Webhook registered and menu button set in the Launch checklist.
- Main Mini App set in BotFather with
?c=<slug>; one tracked link and one squad invite tested. - Both TON Connect manifests load over https.
- A test Stars purchase and a refund done with your own account in Telegram's test environment.
- Payment support reply set in Settings → Branding; the bot's menu lists
/startand/paysupport, and/paysupportanswers with your text (see Payment support reply). - Adsgram Reward URL tested, if you use ads.
- A full airdrop run on testnet, including a claim and the withdraw.
- Backups scheduled and one restore tested.
DEMO_READ_ONLYis not set (it is only for a public showcase install).