From 8744fc4d5fcfb2e07dcf017bb79be7e4748c025f Mon Sep 17 00:00:00 2001 From: Ben Davis Date: Thu, 19 Mar 2026 23:31:14 -0700 Subject: [PATCH] rwx added in --- .captain/config.yml | 9 +++++ .rwx/ci.yml | 78 ++++++++++++++++++++++++++++++++++++ .rwx/main.yml | 24 +++++++++++ .rwx/pr.yml | 73 +++++++++++++++++++++++++++++++++ apps/sandbox/src/snapshot.ts | 8 +++- package.json | 1 + turbo.json | 3 ++ 7 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 .captain/config.yml create mode 100644 .rwx/ci.yml create mode 100644 .rwx/main.yml create mode 100644 .rwx/pr.yml diff --git a/.captain/config.yml b/.captain/config.yml new file mode 100644 index 00000000..bb300d6c --- /dev/null +++ b/.captain/config.yml @@ -0,0 +1,9 @@ +test-suites: + better-context-bun: + command: bun test --reporter=junit --reporter-outfile bun.xml + results: + language: JavaScript + framework: bun + path: bun.xml + retries: + command: bun test '{{ file }}' --test-name-pattern '{{ testNamePattern }}' --reporter=junit --reporter-outfile bun.xml diff --git a/.rwx/ci.yml b/.rwx/ci.yml new file mode 100644 index 00000000..92cd12eb --- /dev/null +++ b/.rwx/ci.yml @@ -0,0 +1,78 @@ +on: + cli: + init: + commit-sha: ${{ event.git.sha }} + +base: + image: ubuntu:24.04 + config: rwx/base 1.0.0 + arch: ${{ init.arch }} + +aliases: + shared-env: &shared-env # TODO: These must be set somewhere we can't see + PUBLIC_CONVEX_URL: https://example.com + PUBLIC_CLERK_PUBLISHABLE_KEY: abc123 + +tasks: + - key: code + call: git/clone 2.0.6 + with: + repository: https://github.com/davis7dotsh/better-context.git + ref: ${{ init.commit-sha }} + + - key: bun-version + use: code + run: jq -r '.packageManager | split("@")[1]' package.json > ${RWX_VALUES}/version + filter: + - package.json + + - key: bun + run: | + curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" + echo "${HOME}/.bun" > "${RWX_ENV}/BUN_INSTALL" + echo "${HOME}/.bun/bin" > "${RWX_ENV}/PATH" + ~/.bun/bin/bun --print process.version | tr -d 'v' > ${RWX_VALUES}/node-version + env: + BUN_VERSION: ${{ tasks.bun-version.values.version}} + + - key: node + use: bun + call: nodejs/install 1.1.13 + with: + node-version: ${{ tasks.bun.values.node-version }} + + - key: bun-install + use: [code, bun, node] + # TODO: add --frozen-lockfile back once packages are updated + run: bun install + filter: + - bun.lock + - bunfig.toml + - package.json + - apps/**/package.json + - packages/**/package.json + + - key: lint + use: bun-install + run: bun run lint:all + + - key: install-mintlify + use: bun-install + run: bun add -d @mintlify/cli + + - key: bun-check + use: install-mintlify + run: bun run check:all + env: *shared-env + + - key: bun-build + use: bun-check + run: bun run build:all + env: *shared-env + + - key: captain + call: rwx/install-captain 1.1.5 + + - key: test + use: [captain, bun-install] + run: captain run better-context-bun diff --git a/.rwx/main.yml b/.rwx/main.yml new file mode 100644 index 00000000..10a6945e --- /dev/null +++ b/.rwx/main.yml @@ -0,0 +1,24 @@ +on: + github: + push: + if: ${{ event.git.branch == 'main' }} + init: + ref: ${{ event.git.ref }} + commit-sha: ${{ event.git.sha }} + +base: + image: ubuntu:24.04 + config: rwx/base 1.0.0 + +tasks: + - key: ci-x86_64 + call: ${{ run.dir }}/ci.yml + init: + arch: x86_64 + commit-sha: ${{ init.commit-sha }} + + - key: ci-arm64 + call: ${{ run.dir }}/ci.yml + init: + arch: arm64 + commit-sha: ${{ init.commit-sha }} diff --git a/.rwx/pr.yml b/.rwx/pr.yml new file mode 100644 index 00000000..9b80ed9d --- /dev/null +++ b/.rwx/pr.yml @@ -0,0 +1,73 @@ +on: + cli: + init: + commit-sha: ${{ event.git.sha }} + pr-number: "0" + github: + pull_request: + init: + commit-sha: ${{ event.git.sha }} + pr-number: ${{ event.github.pull_request.number }} + +base: + image: ubuntu:24.04 + config: rwx/base 1.0.0 + +concurrency-pools: + - id: davis7dotsh/better-context:pull-request:${{ init.pr-number }} + if: ${{ init.pr-number != "0" }} + capacity: 1 + on-overflow: cancel-running + +tasks: + - key: code + call: git/clone 2.0.6 + with: + repository: https://github.com/davis7dotsh/better-context.git + ref: ${{ init.commit-sha }} + + - key: bun-version + use: code + run: jq -r '.packageManager | split("@")[1]' package.json > ${RWX_VALUES}/version + filter: + - package.json + + - key: bun + run: | + curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" + echo "${HOME}/.bun" > "${RWX_ENV}/BUN_INSTALL" + echo "${HOME}/.bun/bin" > "${RWX_ENV}/PATH" + ~/.bun/bin/bun --print process.version | tr -d 'v' > ${RWX_VALUES}/node-version + env: + BUN_VERSION: ${{ tasks.bun-version.values.version}} + + - key: node + use: bun + call: nodejs/install 1.1.13 + with: + node-version: ${{ tasks.bun.values.node-version }} + + - key: bun-install + use: [code, bun, node] + run: bun install + filter: + - bun.lock + - bunfig.toml + - package.json + - apps/**/package.json + - packages/**/package.json + + - key: lint + use: bun-install + run: bun run lint:all + + - key: install-mintlify + use: bun-install + run: bun add -d @mintlify/cli + + - key: check + use: install-mintlify + run: bun run check:all + env: + PUBLIC_CONVEX_URL: https://example.com + PUBLIC_CLERK_PUBLISHABLE_KEY: abc123 diff --git a/apps/sandbox/src/snapshot.ts b/apps/sandbox/src/snapshot.ts index f9fdeb72..7ce3c19f 100644 --- a/apps/sandbox/src/snapshot.ts +++ b/apps/sandbox/src/snapshot.ts @@ -52,8 +52,12 @@ async function main(): Promise { console.log('\nRun sandboxes with: bun sandbox'); } -// Only run when executed directly, not when imported -if (import.meta.main) { +// Only run when executed directly, not when imported. +const mainModuleUrl = + process.argv[1] === undefined ? undefined : `file://${encodeURI(process.argv[1])}`; +const isMainModule = mainModuleUrl !== undefined && import.meta.url === mainModuleUrl; + +if (isMainModule) { main().catch((error) => { console.error('Error:', error); process.exit(1); diff --git a/package.json b/package.json index fc7d1a3e..586f3840 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "build:cli": "turbo build --filter=btca", "build:web": "turbo build --filter=@btca/web", "check:all": "turbo check", + "lint:all": "turbo lint", "check:docs": "turbo check --filter=@btca/docs", "check:cli": "turbo check --filter=btca", "check:web": "turbo check --filter=@btca/web", diff --git a/turbo.json b/turbo.json index e75d9d0a..eef1d772 100644 --- a/turbo.json +++ b/turbo.json @@ -12,6 +12,9 @@ "format": { "dependsOn": ["^format"] }, + "lint": { + "dependsOn": ["^lint"] + }, "check": { "dependsOn": ["^check"] },