Skip to content

Inline test runner#1

Merged
rohitpaulk merged 13 commits into
mainfrom
inline-test-runner
Nov 17, 2025
Merged

Inline test runner#1
rohitpaulk merged 13 commits into
mainfrom
inline-test-runner

Conversation

@rohitpaulk

@rohitpaulk rohitpaulk commented Nov 17, 2025

Copy link
Copy Markdown
Member

Note

Introduces a Go-based test-runner builder, updates Dockerfile to build/use it and download test-runner v0.3.71, and adds a CI workflow plus a Ruby-based local test harness.

  • Builder (Go):
    • Adds builder/ module with command BuildImageCommand to build/push images via Depot, stream logs, finalize builds, and handle errors.
    • Implements backend client (/services/test_runner/*), build log processor, repo commit switching, buildpack detection, globals, and Sentry init.
    • Provides TestRunnerBuild logging (Logstream + file) and main entrypoint.
  • Docker:
    • Installs Go and Depot; builds /var/opt/test-runner-builder from builder/ and verifies --version.
    • Downloads test runner v0.3.71 and verifies binary.
  • CI:
    • Adds .github/workflows/test.yml to run fixtures setup and tests on PRs and main.
  • Testing Harness (Ruby):
    • Adds Gemfile, docker-compose (git-api, git-daemon, Redis), Makefile targets, and extensive tests for image builds/log streaming.
    • Includes fake server, models/schema, test runner actions, tester downloader, fixtures, and helpers.

Written by Cursor Bugbot for commit d015d37. This will update automatically on new commits. Configure here.

Comment thread Dockerfile
RUN apt-get update && apt-get install -y curl wget jq tar git docker.io

# Install Go
RUN wget https://go.dev/dl/go1.25.0.linux-amd64.tar.gz -O /tmp/go.tar.gz && \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Go Version Format Breaks Docker Builds

The Dockerfile attempts to download go1.25.0.linux-amd64.tar.gz, but Go releases don't use .0 for the initial minor version release. The correct URL should be go1.25.linux-amd64.tar.gz (without the .0). This will cause the download to fail with a 404 error during the Docker build.

Fix in Cursor Fix in Web

Comment thread builder/.env.example

# A depot project & token
DEPOT_PROJECT="jlmt2zdb5m" # test-runner-ci
DEPOT_TOKEN="depot_project_e252ea64749beae1c983d2f95c952c892cb211c3a0e4aff1fe9ceb5bd14fc0a5"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Sensitive Data in Example Environment

The .env.example file contains what appear to be real credentials including FLY_ACCESS_TOKEN and DEPOT_TOKEN with actual token values. Example environment files should contain placeholder values, not real secrets. These credentials should be removed and replaced with dummy placeholders like "your-token-here".

Fix in Cursor Fix in Web

prefixedWriter.Write([]byte("\033[31mBuild failed. Check the logs above for the reason.\033[0m\n"))
prefixedWriter.Write([]byte("\033[31mIf you think this is a CodeCrafters error, please contact us at hello@codecrafters.io.\033[0m\n"))
userLogsSink.Write([]byte("\n"))
return exitError.ExitCode() == 0, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Always False Exit Code Condition

The condition exitError.ExitCode() == 0 will always be false because ExitError is only returned when a command exits with a non-zero status. The check is redundant and confusing - the code should just return false, nil directly instead of checking an exit code that will never be zero in this context.

Fix in Cursor Fix in Web

- name: Install logstream
run: |
curl -L https://github.com/codecrafters-io/logstream/releases/download/v0.2.2/v0.2.2_linux_amd64 -o /usr/local/bin/logstream
chmod +x /usr/local/bin/logstream

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Install Fails: System Write Permission Denied

The logstream installation writes to /usr/local/bin/logstream without sudo, which will fail with a permission denied error on GitHub Actions runners. The runner doesn't have write permissions to /usr/local/bin without elevated privileges.

Fix in Cursor Fix in Web

Comment thread .github/workflows/test.yml Outdated
@rohitpaulk rohitpaulk merged commit a5de815 into main Nov 17, 2025
2 checks passed
}

func (b *TestRunnerBuild) ReadLogsFromFile() ([]byte, error) {
b.logsFile.Seek(0, 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Data Integrity Compromised by Ignored Errors

The Seek method returns an error that's being ignored. If seeking to the beginning of the logs file fails, ReadLogsFromFile will read from the current file position instead of the start, potentially returning incomplete or incorrect logs that get sent to the backend.

Fix in Cursor Fix in Web

// Create a context with timeout
ctx, cancel := context.WithTimeout(context.Background(), command.timeout)
defer cancel()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Context Leaks from Deferred Loop Cancellations

The defer cancel() is called inside a loop, causing all cancel functions to accumulate and only execute when the function returns rather than after each iteration. This creates context leaks where contexts remain active longer than necessary, potentially holding resources until all commands complete instead of releasing them after each command finishes.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant