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
6 changes: 5 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
"ignore": [],
"privatePackages": {
"version": true,
"tag": true
}
}
5 changes: 5 additions & 0 deletions .changeset/proud-gifts-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@repo/tools': minor
---

BANDA-899 feat: add runx deploy-published-workers script
25 changes: 25 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Setup Node.js Environment'
description: 'Install pnpm, Node.js, and project dependencies'

inputs:
node-version:
description: 'Node.js version to use'
required: false
default: '22'

runs:
using: "composite"
steps:
- name: Install pnpm
# note: version is inferred from the packageManager field in package.json
uses: pnpm/action-setup@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: 'pnpm'

- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile --child-concurrency=10
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
name: Test and check
name: Branches
on:
push:
branches-ignore: ['main']

env:
FORCE_COLOR: 1

jobs:
test:
name: Test & Check
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 10
strategy:
matrix:
node-version: [20, 22]
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.8.0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --child-concurrency=10

- name: Syncpack lint
run: pnpm check:deps
- name: Run linter
Expand All @@ -29,3 +30,4 @@ jobs:
run: pnpm check:format
- name: Run tests
run: pnpm test

22 changes: 8 additions & 14 deletions .github/workflows/evals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@ name: Evals
on:
push:

env:
FORCE_COLOR: 1

jobs:
eval:
name: Eval
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [22]
permissions:
contents: read
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.8.0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- uses: ./.github/actions/setup
- name: Create .dev.vars file
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" > ./apps/sandbox-container/.dev.vars
Expand All @@ -29,7 +25,5 @@ jobs:
run: |
du -h ./apps/sandbox-container/.dev.vars
du -h ./apps/workers-bindings/.dev.vars
- name: Install dependencies
run: pnpm install --frozen-lockfile --child-concurrency=10
- name: Run evals
run: pnpm eval:ci
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Main

on:
push:
branches: ['main']

env:
FORCE_COLOR: 1

jobs:
deploy-staging:
name: Deploy (staging)
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 10
concurrency: ${{ github.workflow }}-deploy-staging
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- uses: ./.github/actions/setup

# Run tests & checks before deploying
- name: Syncpack lint
run: pnpm check:deps
- name: Run linter
run: pnpm check:turbo
- name: Run linter (formatting)
run: pnpm check:format
- name: Run tests
run: pnpm test

- name: Deploy Workers (staging)
run: pnpm turbo deploy -- -e staging
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release

on:
push:
branches: ['main']

env:
FORCE_COLOR: 1

jobs:
create-release-pr:
name: Create Release PR
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
timeout-minutes: 5
concurrency: ${{ github.workflow }}-create-release-pr
outputs:
published: ${{ steps.create-release-pr.outputs.published }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Create Release PR
id: create-release-pr
uses: changesets/action@v1
with:
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save Published Packages
if: steps.create-release-pr.outputs.published == 'true'
run: |
echo '${{steps.create-release-pr.outputs.publishedPackages}}' \
> ${{ github.workspace }}/published-packages.json
- name: Upload Published Packages
if: steps.create-release-pr.outputs.published == 'true'
uses: actions/upload-artifact@v4
with:
name: published-packages
path: ${{ github.workspace }}/published-packages.json

deploy-production:
name: Deploy (production)
needs: create-release-pr
if: needs.create-release-pr.outputs.published == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 10
concurrency: ${{ github.workflow }}-deploy-production
permissions:
contents: read
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Download published packages
uses: actions/download-artifact@v4
with:
name: published-packages
path: ${{ runner.temp }}
- uses: ./.github/actions/setup
- name: Deploy Published Workers (production)
run: pnpm runx deploy-published-workers --env production
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ vitest.config.ts.timestamp*
vite.config.ts.timestamp*
worker-configuration.d.ts
**/dist/**
packages/tools/src/test/fixtures/changesets/invalid-json/*.json
6 changes: 6 additions & 0 deletions .syncpackrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const config = {
// snapTo removes it from syncpack update list, which is the main goal
snapTo: ['@repo/eslint-config'],
},
{
label: 'use zod v4 in packages/tools',
dependencies: ['zod'],
pinVersion: '4.0.0-beta.20250505T195954',
packages: ['@repo/tools'],
},
],
semverGroups: [
{
Expand Down
5 changes: 5 additions & 0 deletions packages/tools/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@repo/eslint-config/default.cjs'],
}
36 changes: 36 additions & 0 deletions packages/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# @repo/tools

A collection of shared scripts for automating the monorepo while ensuring consistency across packages.

## Scripts

### Bin Scripts

Simple shell scripts for common development tasks:

- `run-tsc`: Run TypeScript type checking
- `run-eslint-workers`: Run ESLint checks
- `run-vitest`: Run tests
- `run-vitest-ci`: Run tests in CI mode
- `run-turbo`: Run Turbo commands with tracking disabled
- `run-wrangler-deploy`: Deploy using Wrangler
- `run-wrangler-types`: Generate Wrangler types
- `run-fix-deps`: Fix dependencies

### Runx CLI

A TypeScript-based CLI for more complex automation tasks. While the bin scripts work well for simple tasks, the runx CLI provides better type safety and more sophisticated programmatic control.

Usage:

```bash
pnpm runx <command> [options]
```

Available commands:

- `deploy-published-workers`: Deploy Cloudflare Workers (based on which packages changesets marked as published in the release).

Note:

The CLI will automatically use Bun if available, but falls back to tsx if not installed.
13 changes: 13 additions & 0 deletions packages/tools/bin/runx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
set -eu

script_path="$(realpath "$(dirname "$0")/../src/bin/runx.ts")"

bin_dir="$(realpath "$(dirname "$0")")"
tsx_path="$(realpath "$bin_dir/../node_modules/.bin/tsx")"

if command -v bun >/dev/null 2>&1; then
bun "$script_path" "$@"
else
"$tsx_path" "$script_path" "$@"
fi
13 changes: 12 additions & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
"bin": "bin"
},
"devDependencies": {
"@types/node": "22.14.1"
"@types/fs-extra": "11.0.4",
"@types/node": "22.14.1",
"vitest": "3.0.9"
},
"dependencies": {
"@commander-js/extra-typings": "13.1.0",
"@jahands/cli-tools": "0.10.2",
"commander": "13.1.0",
"empathic": "1.1.0",
"tsx": "4.19.3",
"zod": "4.0.0-beta.20250505T195954",
"zx": "8.5.4"
}
}
20 changes: 20 additions & 0 deletions packages/tools/src/bin/runx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'zx/globals'

import { program } from '@commander-js/extra-typings'
import { catchProcessError } from '@jahands/cli-tools'

import { deployPublishedWorkersCmd } from '../cmd/deploy-published-packages'

program
.name('runx')
.description('A CLI for scripts that automate this repo')

// While `packages/tools/bin` scripts work well for simple tasks,
// a typescript CLI is nicer for more complex things.

.addCommand(deployPublishedWorkersCmd)

// Don't hang for unresolved promises
.hook('postAction', () => process.exit(0))
.parseAsync()
.catch(catchProcessError())
Loading