Skip to content

Commit 84b8a80

Browse files
committed
Fix git permissions issues
1 parent 4e4521d commit 84b8a80

File tree

5 files changed

+52
-34
lines changed

5 files changed

+52
-34
lines changed

apps/roomote/Dockerfile.worker

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# docker compose build worker
2+
# Note: Requires $GH_TOKEN to be set as build argument.
23

34
FROM roomote-base AS base
45

@@ -25,7 +26,20 @@ RUN mkdir -p /roo/.vscode \
2526
&& code --no-sandbox --user-data-dir /roo/.vscode --install-extension csstools.postcss \
2627
&& code --no-sandbox --user-data-dir /roo/.vscode --install-extension RooVeterinaryInc.roo-cline
2728

29+
# Clone repo (requires $GH_TOKEN)
30+
ARG GH_TOKEN
31+
ENV GH_TOKEN=${GH_TOKEN}
32+
WORKDIR /roo/repos
33+
RUN git config --global user.email "[email protected]"
34+
RUN git config --global user.name "Roo Code"
35+
RUN git config --global credential.helper store
36+
RUN echo "https://oauth2:${GH_TOKEN}@github.com" > ~/.git-credentials
37+
RUN gh repo clone RooCodeInc/Roo-Code
38+
WORKDIR /roo/repos/Roo-Code
39+
RUN pnpm install
40+
2841
# Install dependencies
42+
WORKDIR /roo
2943
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
3044
COPY packages/config-eslint/package.json ./packages/config-eslint/
3145
COPY packages/config-typescript/package.json ./packages/config-typescript/
@@ -42,14 +56,6 @@ COPY packages/config-typescript ./packages/config-typescript/
4256
COPY packages/types ./packages/types/
4357
COPY packages/ipc ./packages/ipc/
4458

45-
# Clone repo (requires $GH_TOKEN)
46-
ARG GH_TOKEN
47-
ENV GH_TOKEN=${GH_TOKEN}
48-
WORKDIR /roo/repos
49-
RUN gh repo clone RooCodeInc/Roo-Code
50-
WORKDIR /roo/repos/Roo-Code
51-
RUN pnpm install
52-
5359
WORKDIR /roo/apps/roomote
5460
ENV NODE_ENV=production
5561
CMD ["pnpm", "worker"]

apps/roomote/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ services:
7878
env_file:
7979
- .env
8080
environment:
81+
- HOST_EXECUTION_METHOD=docker
8182
- DATABASE_URL=postgresql://postgres:password@db:5432/cloud_agents
8283
- REDIS_URL=redis://redis:6379
8384
- NODE_ENV=production
84-
- HOST_EXECUTION_METHOD=docker
8585
volumes:
8686
- /var/run/docker.sock:/var/run/docker.sock
8787
- /tmp/roomote:/var/log/roomote

apps/roomote/src/lib/controller.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,28 @@ export class WorkerController {
103103
stdio: ["ignore", "pipe", "pipe"],
104104
})
105105

106-
const logStream = fs.createWriteStream("/tmp/roomote-worker.log", { flags: "a" })
107-
108106
if (childProcess.stdout) {
109-
childProcess.stdout.pipe(logStream)
107+
childProcess.stdout.on("data", (data) => {
108+
console.log(data.toString())
109+
})
110110
}
111111

112112
if (childProcess.stderr) {
113-
childProcess.stderr.pipe(logStream)
113+
childProcess.stderr.on("data", (data) => {
114+
console.error(data.toString())
115+
})
114116
}
115117

116118
this.activeWorkers.add(workerId)
117119

118120
childProcess.on("exit", (code) => {
119121
console.log(`Worker ${workerId} exited with code ${code}`)
120122
this.activeWorkers.delete(workerId)
121-
logStream.end()
122123
})
123124

124125
childProcess.on("error", (error) => {
125126
console.error(`Worker ${workerId} error:`, error)
126127
this.activeWorkers.delete(workerId)
127-
logStream.end()
128128
})
129129

130130
// Detach the process so it can run independently.

apps/roomote/src/lib/jobs/fixGitHubIssue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ ${jobPayload.labels && jobPayload.labels.length > 0 ? `Labels: ${jobPayload.labe
2828
2929
Please analyze the issue, understand what needs to be fixed, and implement a solution.
3030
31-
If you're reasonably satisfied with the solution then create and submit a pull request using the "gh" command line tool:
31+
When you're finished, create a git branch to store your work and then submit a pull request using the "gh" command line tool:
3232
gh pr create --title "Fixes #${jobPayload.issue}\n\n[Your PR description here.]" --fill --template "pull_request_template.md"
3333
34-
You'll first need to create a new branch for the pull request.
34+
Your job isn't done until you've created a pull request. Try to solve any git issues that arise while creating your branch and submitting your pull request.
3535
`.trim()
3636

3737
const { repo, issue } = jobPayload

apps/roomote/src/lib/worker.ts

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@ import { Worker } from "bullmq"
33
import { redis } from "./redis"
44
import { processJob } from "./job"
55

6-
/**
7-
* docker compose build worker
8-
* docker run \
9-
* --name roomote-worker \
10-
* --rm \
11-
* --network roomote_default \
12-
* -e HOST_EXECUTION_METHOD=docker \
13-
* -v /var/run/docker.sock:/var/run/docker.sock \
14-
* -v /tmp/roomote:/var/log/roomote roomote-worker \
15-
* sh -c "pnpm worker"
16-
*/
6+
// docker compose build worker
7+
// docker run \
8+
// --name roomote-worker \
9+
// --rm \
10+
// --interactive \
11+
// --tty \
12+
// --network roomote_default \
13+
// -e HOST_EXECUTION_METHOD=docker \
14+
// -e GH_TOKEN=$GH_TOKEN \
15+
// -e DATABASE_URL=postgresql://postgres:password@db:5432/cloud_agents \
16+
// -e REDIS_URL=redis://redis:6379 \
17+
// -e NODE_ENV=production \
18+
// -v /var/run/docker.sock:/var/run/docker.sock \
19+
// -v /tmp/roomote:/var/log/roomote \
20+
// roomote-worker sh -c "bash"
1721

1822
async function processSingleJob() {
19-
const worker = new Worker("roomote", undefined, { autorun: false, connection: redis })
23+
const worker = new Worker("roomote", undefined, {
24+
autorun: false,
25+
connection: redis,
26+
lockDuration: 30 * 60 * 1_000, // 30 minutes
27+
})
28+
29+
const token = crypto.randomUUID()
2030

2131
try {
22-
console.log("Looking for a job to process...")
23-
const job = await worker.getNextJob("worker-token")
32+
const job = await worker.getNextJob(token)
2433

2534
if (!job) {
2635
console.log("No jobs available, exiting...")
@@ -32,10 +41,10 @@ async function processSingleJob() {
3241

3342
try {
3443
await processJob(job)
35-
await job.moveToCompleted(undefined, "worker-token")
44+
await job.moveToCompleted(undefined, token, false)
3645
console.log(`Job ${job.id} completed successfully`)
3746
} catch (error) {
38-
await job.moveToFailed(error as Error, "worker-token")
47+
await job.moveToFailed(error as Error, token, false)
3948
console.error(`Job ${job.id} failed:`, error)
4049
}
4150
} catch (error) {
@@ -56,5 +65,8 @@ process.on("SIGINT", async () => {
5665
process.exit(0)
5766
})
5867

59-
console.log("Single job worker started")
68+
if (!process.env.GH_TOKEN) {
69+
throw new Error("GH_TOKEN is not set")
70+
}
71+
6072
processSingleJob()

0 commit comments

Comments
 (0)