All jobs

Migrate a Python Project from Travis CI to GitHub Actions

Yes. An agent ports .travis.yml to a GitHub Actions workflow, runs every step first to learn which ones pass today, and opens a pull request that says so.

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

What the agent does

The agent treats .travis.yml as a claim to be tested, not a file to be translated. In a project like ExpDev07/coronavirus-tracker-api it is fourteen lines: Python 3.6, 3.7 and 3.8, an install phase of pip install pipenv and pipenv install --dev --skip-lock, three script lines (make test, make lint, make check-fmt) and coveralls after success. The agent follows each line into the Makefile and tasks.py to the commands that really run, and reads the files that say which Python the project supports: the Pipfile requires 3.8, runtime.txt names python-3.8.13, and the README badge still points at api.travis-ci.com.

Before writing any workflow it runs the steps in its sandbox, twice. First with the versions in Pipfile.lock on Python 3.8: make test fails with 4 of 77 tests failing, make lint exits non-zero on four Pylint messages, three of them trailing whitespace, and make check-fmt passes. Then the way Travis installed, without the lock. Nearly every dependency in the Pipfile is "*", so that install now resolves FastAPI and Pydantic releases years newer than the code was written for, and pytest stops during collection with RuntimeError: The starlette.testclient module requires the httpx package to be installed. A faithful port of the install line would be red for a reason that has nothing to do with GitHub Actions.

It checks the matrix against what hosted runners can provide. The version manifest that actions/setup-python reads lists Python 3.6 builds only for Ubuntu 18.04 and 20.04, and 3.7 builds only up to 22.04, so on a 24.04 runner two of the three matrix entries fail before any project code runs. Both versions are also below what the Pipfile asks for. The agent keeps 3.8, drops the other two and explains the choice. It also examines the one step that passes. make check-fmt runs Black and isort joined by a single &, so the shell reports isort's exit status alone and the step cannot fail on formatting.

The workflow it writes is plain: checkout, actions/setup-python with pip caching, install from the lockfile with pipenv sync --dev in place of --skip-lock, then the three make targets as separate steps so each shows its own result. The Coveralls upload becomes coveralls --service=github with GITHUB_TOKEN in its environment, since nothing in Actions identifies itself as Travis. It sets permissions: contents: read, adds a concurrency group that cancels superseded runs on a branch, removes .travis.yml and replaces the badge. It does not fix the failing tests or the lint messages in the same pull request; it lists them, with output, as what the new workflow will report on its first run.

Start it with one API call

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

{
  "agent": "claude",
  "input": "Migrate this repository's CI from Travis to GitHub Actions. Read .travis.yml and follow every command it runs through the Makefile and any task runner down to the real shell commands. Read the files that state the supported Python version (Pipfile, pyproject.toml, runtime.txt, setup files) and note any disagreement with the Travis matrix. Before writing a workflow, run each CI step here and record its exit code and the last lines of output, twice: once with dependencies installed from the lockfile on the Python version the project declares, and once installed the way .travis.yml installs them. If the two differ, explain why. For each Python version in the matrix, check whether actions/setup-python can provide it on a current Ubuntu runner by reading the actions/python-versions manifest, and drop versions that cannot be set up or that the project does not support, saying which and why. For every step that passes, check that it is able to fail. Then write .github/workflows/ci.yml: least-privilege permissions, a concurrency group, dependency caching, an install that uses the lockfile, one step per check, and the coverage upload adapted for Actions with the secret it needs named in the description. Validate the file with actionlint. Delete .travis.yml and update the README badge. Do not fix failing tests or lint findings; list each one with its output as a known failure. Open a pull request whose description says, step by step, what the workflow is expected to report on its first run.",
  "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 that adds .github/workflows/ci.yml, deletes .travis.yml and edits the README badge. Its description is organised around a table with one row per CI step: the command, its result with locked dependencies, its result with the old install that skipped the lock, and what the workflow will show. A reviewer learns from that table that a red first run is expected, and which steps will be red.

Under the table are the decisions the port required. The matrix shrank from three Python versions to one, with the manifest lookup and the Pipfile requirement as the two reasons. The install changed from resolving fresh to syncing the lockfile, with the collection error as the reason. The coverage upload needs a token, and the description names the variable and where to set it. The formatting step is flagged as unable to fail, with the command string quoted.

The check on the pull request itself is the workflow's first real run, since the sandbox validates syntax and commands but is not a GitHub runner. The reviewer compares that run with the table. If they match, the port is faithful and the remaining red steps are the project's own backlog, which the description lists as follow-up work: three tests that call a function with the wrong number of arguments, one test that depends on a removed Pipenv flag, and the four Pylint messages.

Run it on every repository still on Travis CI

A CI migration is done once for each repository. Send the body to POST /o/{org}/sessions from a terminal or an MCP client, with a request_id that is a UUID made for the job. When the pull request's first workflow run finishes, a follow-up to POST /o/{org}/sessions/{id}/messages with that run's result wakes the same sandbox, and the agent reconciles it with its table or fixes what it predicted wrongly.

For an organisation with many dormant repositories, a script sends one request per repository, each with a request_id that is a UUID v5 of the repository's full name. Runs beyond the key's concurrency limit are created queued and start in order as slots free. Each returns its own pull request, and a webhook_url on the key receives run.completed for every run that key started, so the script's owner can collect the session URLs without polling.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A repository that has sat on Travis for years has usually not had a CI run in years either, so nobody knows whether its build passes. Translating the YAML answers a different question. The agent answers the real one by running every step in its own sandbox, on the Python the project declares, with both install methods, and it keeps the output in the transcript at GET /o/{org}/sessions/{id}/messages. The pull request then separates what the migration changed from what was already broken.

That separation is what makes the change mergeable. Without it, a red first run on the new workflow looks like a failed migration and the pull request stalls. With a table that predicted each red step and its cause, the same run confirms the port. Producing that table by hand means building two environments and reading three tool outputs for a chore nobody wants, which is why it is rarely done.

Frequently asked questions

Why not keep the same Python matrix as Travis?

Because hosted runners may not be able to install it. actions/setup-python downloads prebuilt interpreters listed in a manifest, and old versions have builds only for old Ubuntu images. The agent reads the manifest for each version in the matrix and keeps those that exist on a current runner and that the project's own files say it supports.

Will the agent make the new workflow pass?

Not by changing your code. The request limits it to the port, and failures that exist with or without the migration are listed as known. If you want them fixed, send a follow-up to the same session naming which ones; the sandbox still has both environments, so the fix can be tested against the same baseline.

Does the coverage upload keep working?

It needs one change. On Travis the coveralls command detected the service and repository by itself. In Actions the command is told the service and given a token through the environment. The agent writes the step and names the token; it cannot confirm the upload from its sandbox, so the first workflow run is where that step is verified.

Can the agent run GitHub Actions inside its sandbox?

It runs the commands each step executes and validates the workflow file with actionlint, which catches syntax and expression errors. It does not emulate a hosted runner. The description is explicit about that boundary: command results come from the sandbox, runner behaviour such as interpreter setup comes from the manifest, and the pull request's own check is the confirmation.

The same job on other stacks

More jobs like this: Hand off a long task

Keep reading