Skip to content

Commit 64f4c35

Browse files
[codecane] feat: deploy new cli app in staging (#344)
Co-authored-by: Codebuff <noreply@codebuff.com>
1 parent d902ca1 commit 64f4c35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3090
-877
lines changed

.bin/bun

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ create_cache() {
172172
fi
173173
}
174174

175+
# Function to check if tmux is installed
176+
check_tmux_installed() {
177+
if ! command -v tmux &> /dev/null; then
178+
return 1
179+
fi
180+
return 0
181+
}
182+
175183
# Function to check if command doesn't need secrets
176184
# Returns 0 if secrets are NOT needed, 1 if they ARE needed
177185
doesnt_need_secrets() {
@@ -248,6 +256,43 @@ doesnt_need_secrets() {
248256
;;
249257
esac
250258
;;
259+
# Test command needs special handling
260+
test)
261+
# Check for integration/e2e tests that require tmux
262+
# Convention: test files matching *integration*.test.ts or *e2e*.test.ts
263+
local needs_tmux=false
264+
265+
for arg in "$@"; do
266+
# Check if running integration or e2e tests
267+
if [[ "$arg" =~ (integration|e2e).*\.test\.(ts|tsx|js|jsx) ]]; then
268+
needs_tmux=true
269+
break
270+
fi
271+
# Also check if running all tests and integration files exist
272+
if [[ "$arg" == "test" ]] || [[ -z "$arg" ]]; then
273+
if ls */src/__tests__/*integration*.test.ts 2>/dev/null || ls */src/__tests__/*e2e*.test.ts 2>/dev/null; then
274+
needs_tmux=true
275+
break
276+
fi
277+
fi
278+
done
279+
280+
# If running integration/e2e tests, check tmux availability
281+
if [ "$needs_tmux" = true ]; then
282+
if ! check_tmux_installed; then
283+
echo "⚠️ tmux not found but required for integration/E2E tests"
284+
echo ""
285+
echo "📦 Install tmux:"
286+
echo " macOS: brew install tmux"
287+
echo " Ubuntu: sudo apt-get install tmux"
288+
echo " Windows: Use WSL and run 'sudo apt-get install tmux'"
289+
echo ""
290+
echo "ℹ️ Skipping tmux-dependent tests..."
291+
echo ""
292+
fi
293+
fi
294+
return 1 # Tests need secrets
295+
;;
251296
*)
252297
# Default to needing secrets for all other commands
253298
return 1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Setup Project'
2+
description: 'Setup Bun, cache dependencies, and install packages'
3+
4+
inputs:
5+
bun-version:
6+
description: 'Bun version to install'
7+
required: false
8+
default: '1.3.0'
9+
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Set up Bun
14+
uses: oven-sh/setup-bun@v2
15+
with:
16+
bun-version: ${{ inputs.bun-version }}
17+
18+
- name: Cache dependencies
19+
uses: actions/cache@v4
20+
with:
21+
path: |
22+
node_modules
23+
*/node_modules
24+
key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock*', '**/package.json') }}
25+
restore-keys: |
26+
${{ runner.os }}-deps-${{ hashFiles('**/bun.lock*') }}
27+
${{ runner.os }}-deps-
28+
29+
- name: Install dependencies
30+
shell: bash
31+
run: bun install --frozen-lockfile

.github/knowledge.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
1-
# GitHub Actions Knowledge
1+
# GitHub Workflows
2+
3+
## Refactoring Patterns
4+
5+
### Composite Actions
6+
7+
Common setup steps (checkout, Bun setup, caching, installation) have been extracted to `.github/actions/setup-project/action.yml`.
8+
9+
Usage:
10+
11+
```yaml
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
# checkout-specific params
16+
17+
- uses: ./.github/actions/setup-project
18+
```
19+
20+
Note: Checkout must be separate from the composite action to avoid circular dependencies.
21+
22+
### Environment Variables
23+
24+
GitHub API URLs are extracted as environment variables to avoid duplication:
25+
26+
```yaml
27+
env:
28+
GITHUB_API_URL: https://api.github.com/repos/CodebuffAI/codebuff
29+
GITHUB_UPLOADS_URL: https://uploads.github.com/repos/CodebuffAI/codebuff
30+
```
31+
32+
This pattern:
33+
34+
- Reduces duplication across workflow steps
35+
- Makes repository changes easier (single point of change)
36+
- Improves readability and maintainability
237
338
## CI/CD Pipeline Overview
439

.github/workflows/ci.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
env:
4444
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
4545
run: |
46-
VAR_NAMES=$(node scripts/generate-ci-env.js)
46+
VAR_NAMES=$(bun scripts/generate-ci-env.js)
4747
echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
4848
to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
4949
' >> $GITHUB_ENV
@@ -121,7 +121,7 @@ jobs:
121121
env:
122122
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
123123
run: |
124-
VAR_NAMES=$(node scripts/generate-ci-env.js)
124+
VAR_NAMES=$(bun scripts/generate-ci-env.js)
125125
echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
126126
to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
127127
' >> $GITHUB_ENV
@@ -130,6 +130,9 @@ jobs:
130130
echo "NEXT_PUBLIC_INFISICAL_UP=true" >> $GITHUB_ENV
131131
echo "CODEBUFF_GITHUB_TOKEN=${{ secrets.CODEBUFF_GITHUB_TOKEN }}" >> $GITHUB_ENV
132132
133+
- name: Build SDK before tests
134+
run: cd sdk && bun run build
135+
133136
- name: Run ${{ matrix.package }} tests
134137
uses: nick-fields/retry@v3
135138
with:
@@ -192,7 +195,7 @@ jobs:
192195
env:
193196
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
194197
run: |
195-
VAR_NAMES=$(node scripts/generate-ci-env.js)
198+
VAR_NAMES=$(bun scripts/generate-ci-env.js)
196199
echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
197200
to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
198201
' >> $GITHUB_ENV
@@ -201,6 +204,9 @@ jobs:
201204
echo "NEXT_PUBLIC_INFISICAL_UP=true" >> $GITHUB_ENV
202205
echo "CODEBUFF_GITHUB_TOKEN=${{ secrets.CODEBUFF_GITHUB_TOKEN }}" >> $GITHUB_ENV
203206
207+
- name: Build SDK before integration tests
208+
run: cd sdk && bun run build
209+
204210
- name: Run ${{ matrix.package }} integration tests
205211
uses: nick-fields/retry@v3
206212
with:

0 commit comments

Comments
 (0)