The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat: lazy dev env setup for Claude CI workflow (#17621)
Félix Malfait749bda92e396
diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.ymlindex 1ddb66fb8b8..4e4d74dabcb 100644--- a/.github/workflows/claude.yml+++ b/.github/workflows/claude.yml@@ -30,7 +30,6 @@ jobs:pull-requests: writeissues: writeid-token: write- actions: readservices:postgres:image: postgres:16@@ -56,25 +55,18 @@ jobs:fetch-depth: 0- name: Install dependenciesuses: ./.github/actions/yarn-install- - name: Build shared dependencies- run: |- npx nx build twenty-shared- npx nx build twenty-emails- - name: Setup env files- run: |- npx nx reset:env twenty-front- npx nx reset:env twenty-server- - name: Create databases- run: |- PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";'- PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "test";'- name: Run Claude Codeuses: anthropics/claude-code-action@v1with:claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}- additional_permissions: |- actions: readclaude_args: "--max-turns 50 --model opus"+ allowed_tools: "Bash(bash packages/twenty-utils/setup-dev-env.sh),Bash(npx nx *),Bash(npx jest *),Bash(yarn *)"+ settings: |+ {+ "env": {+ "PG_DATABASE_URL": "postgres://postgres:postgres@localhost:5432/default"+ }+ }claude-cross-repo:if: github.event_name == 'repository_dispatch'@@ -104,18 +96,6 @@ jobs:fetch-depth: 0- name: Install dependenciesuses: ./.github/actions/yarn-install- - name: Build shared dependencies- run: |- npx nx build twenty-shared- npx nx build twenty-emails- - name: Setup env files- run: |- npx nx reset:env twenty-front- npx nx reset:env twenty-server- - name: Create databases- run: |- PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";'- PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "test";'- name: Build prompt from dispatch payloadid: promptuses: actions/github-script@v7@@ -137,9 +117,14 @@ jobs:with:claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}prompt: ${{ steps.prompt.outputs.prompt }}- additional_permissions: |- actions: readclaude_args: "--max-turns 50 --model opus"+ allowed_tools: "Bash(bash packages/twenty-utils/setup-dev-env.sh),Bash(npx nx *),Bash(npx jest *),Bash(yarn *)"+ settings: |+ {+ "env": {+ "PG_DATABASE_URL": "postgres://postgres:postgres@localhost:5432/default"+ }+ }- name: Post response to source issueif: always()uses: actions/github-script@v7diff --git a/CLAUDE.md b/CLAUDE.mdindex e4631c43017..520f33036dd 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -186,6 +186,14 @@ IMPORTANT: Use Context7 for code generation, setup or configuration steps, or li- Descriptive test names: "should [behavior] when [condition]"- Clear mocks between tests with `jest.clearAllMocks()`+## CI Environment (GitHub Actions)++When running in CI, the dev environment is **not** pre-configured. Dependencies are installed but builds, env files, and databases are not set up.++- **Before running tests, builds, lint, type checks, or DB operations**, run: `bash packages/twenty-utils/setup-dev-env.sh`+- **Skip the setup script** for tasks that only read code — architecture questions, code review, documentation, etc.+- The script is idempotent and safe to run multiple times.+## Important Files- `nx.json` - Nx workspace configuration with task definitions- `tsconfig.base.json` - Base TypeScript configurationdiff --git a/packages/twenty-utils/setup-dev-env.sh b/packages/twenty-utils/setup-dev-env.shnew file mode 100755index 00000000000..c1ba8a00100--- /dev/null+++ b/packages/twenty-utils/setup-dev-env.sh@@ -0,0 +1,12 @@+#!/bin/bash+set -e++echo "Setting up dev environment..."++npx nx reset:env twenty-front+npx nx reset:env twenty-server++PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";' 2>/dev/null || true+PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "test";' 2>/dev/null || true++echo "Dev environment ready."