All jobs

Migrate From garyburd/redigo to gomodule/redigo

Yes. An agent moves a Go service from the archived garyburd/redigo import path to gomodule/redigo, including the test mock that still pulls in the old one.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

Redigo moved from github.com/garyburd/redigo to github.com/gomodule/redigo years ago. The old address now resolves on GitHub to an archived repository under another owner, and code that still imports it is frozen at whatever commit it pinned. The agent lists the imports and the pin. In a scheduler like ajvb/kala, go.mod holds a 2017 pseudo-version of the old module. job/storage/redis/redis.go uses redis.Conn, redis.Dial and redis.DialOption; cmd/serve.go imports the same package as redislib for DialPassword. The storage test builds its connection with redigomock.NewConn() from github.com/rafaeljusto/redigomock, also pinned in 2017.

The path change itself is two import lines and go get github.com/gomodule/redigo@latest. Everything compiles and the storage tests pass, and that is where a quick migration would stop. The agent runs go mod tidy and reads the result: the old module is still in go.mod, now marked // indirect. go mod why -m github.com/garyburd/redigo names the reason. The pinned mock imports the old package, and its connection type happens to satisfy the new redis.Conn interface method for method, so the compiler never complains while both copies of Redigo stay in the build.

So the mock moves too, to github.com/rafaeljusto/redigomock/v3, which is written against the new path. That is one more import line in job/storage/redis/redis_test.go. After another tidy the old module is gone from go.mod and has no line left in go.sum. The agent reports the other version go get raised along the way, testify from v1.7.0 to v1.8.4, and confirms the go 1.13 directive did not move.

Mocked tests say little about a client library, so the agent also talks to a real server. The sandbox has no Docker; it installs redis-server with apt and starts it on a spare port. It builds the binary before and after, starts each with serve --jobdb=redis --jobdb-address= pointing at that server, creates a job through POST /api/v1/job/ on each, and reads HLEN kala:jobs with redis-cli. The count goes to 1 and then 2, and the new binary's job list includes the job the old binary wrote, which shows the stored format is untouched.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "codex",
  "input": "Move this Go module from github.com/garyburd/redigo to github.com/gomodule/redigo. List every import of the old path, including aliased ones, and every test helper or mock that depends on Redigo. Run the tests first and record the result. Change the import paths and run go get github.com/gomodule/redigo@latest, then go mod tidy. If the old module is still in go.mod or go.sum, run go mod why -m github.com/garyburd/redigo and upgrade or replace whatever still imports it (for example move redigomock to its v3 module path) until it is gone. List every other module version that changed. Then test against a real server: install redis-server with apt (do not use Docker), start it on a spare port, build the binary from before and after the change, run each against that server, perform one write and one read through the application's own API or commands, and show with redis-cli that the keys and values are the same shape from both. Use the Go version the CI config pins when running tests. Run go vet and the full tests. Open a pull request with every command and its output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request with three one-line source edits (cmd/serve.go, job/storage/redis/redis.go, job/storage/redis/redis_test.go) plus go.mod and go.sum. The description shows the intermediate state on purpose: the tidy output where the old module survived as indirect, the go mod why chain through the mock, and the second tidy where it is gone. Below that are the round trip against the real server and the test results.

The reviewer checks that the client library moved forward by years, not just sideways. The pin was a 2017 commit and the new version is a current release, so behaviour the service relied on by accident could differ. The round trip covers the commands this service sends; for anything else the description lists the Redigo functions the code calls so the reviewer can compare them against the release notes. They also see which checks need other services. The repository's CircleCI job starts Consul, MongoDB and MySQL containers for the other storage backends, and the agent says those packages were left to CI.

Run it on every weekly dependency check

An import path that still downloads never fails a build, so this stays invisible until someone audits go.mod. Put the prompt above in an automation on the Project with a schedule trigger, every set to 1d or a weekly cron. A run that finds no import of the old path ends by saying so and opens no pull request.

When an inventory script finds the old path in a repository, it can call the automation's webhook trigger instead, with Authorization: Bearer and the trigger's secret. Send the trigger's URL an Idempotency-Key header per repository so a repeated call starts nothing new.

The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.

Why run it on Rush?

The interesting finding here, an archived module kept alive by a test mock, only appears if someone runs tidy and then asks why. An agent that is told to make the old module disappear keeps going until go.sum agrees, and the transcript records each step so the reviewer sees why the test file changed in a pull request about a client library.

The second half needs a Redis server that can be filled with test keys and thrown away. In the sandbox the agent installs one, runs two builds of the service against it, and reads the keys back. Nothing shared is touched, and the commands and their output are kept with the run.

Frequently asked questions

Is it only an import path change?

For the application code in this repository, yes: the four symbols it uses exist under the new path with the same signatures. The rest of the work is finding what else still imports the old path, which here was the mock used by the storage tests.

Why is garyburd/redigo still in go.mod after I changed my imports?

Because a dependency imports it. Run go mod why -m github.com/garyburd/redigo to see the chain. In this repository it runs through a 2017 pin of redigomock; moving to github.com/rafaeljusto/redigomock/v3 removes it.

Will existing data in Redis still be readable?

The client library does not define your key or value format, so it should be, and the agent checks instead of assuming. It writes with the old build, reads with the new one against the same server, and shows the job hash kala:jobs holding entries from both.

Does the module need a newer Go version?

Not in this case. The go directive stays at 1.13 after go get and go mod tidy, and the agent runs the tests with the Go release the CI image pins. The agent reports the directive before and after so a silent bump cannot slip in.

More jobs like this: Upgrade dependencies weekly

Keep reading