# Move a Koa Project from Travis CI to GitHub Actions

Yes. An agent replaces a Koa project's .travis.yml with a GitHub Actions workflow that runs the same lint and mocha commands on a Node matrix, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/migrate-travis-to-github-actions/koa/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads what Travis ran before it writes a workflow, because the goal is the same checks on a service that still runs them. In a repository like koajs/examples, `.travis.yml` is six lines: `language: node_js`, two versions, `stable` and `8`, and a `script` of `npm run lint` then `npm test`. `package.json` defines those scripts: `lint` is `eslint .`, and `test` is `NODE_ENV=test mocha --harmony --reporter spec --require should */test.js`, which picks up the seventeen `test.js` files in example directories such as `blog`, `errors`, `csrf`, `vhost` and `stream-view`. The dependencies are `koa` at `^2.2.0`, `@koa/router`, `koa-body`, `koa-session`, `koa-views` with `ejs` and `swig-templates`, and the dev tools are `mocha` at `^5.0.0`, `supertest` at `^3.0.0`, `should` at `^3.3.2` and `eslint` at `^3.8.1` with `eslint-config-koa`; `engines` says `node >= 7.6`. There is no lockfile, no `.nvmrc` and no `.github/` directory.

Each example ends with `if (!module.parent) app.listen(3000)` and each test calls `app.listen()` on an ephemeral port through `supertest`, so the suite needs no services and no ports; that is the whole environment the workflow has to provide. The agent runs `npm install`, `npm run lint` and `npm test` in its sandbox on the current Node LTS and on the next line before choosing the matrix, because a dependency this old can break on a new runtime, and a workflow that is red on day one is worse than none. Whatever fails is reported in the pull request with the version and the error, not papered over by pinning the matrix to the one version that passes.

Then it writes `.github/workflows/ci.yml`: triggers on `push` and `pull_request`, one job with `actions/checkout` and `actions/setup-node`, a `node-version` matrix built from the versions that passed, `npm install` because there is no lockfile for `npm ci` to use, then `npm run lint` and `npm test` as separate steps so a failure names the stage. The `cache: npm` option of `setup-node` needs a lockfile to key on, so the agent leaves it out and notes that committing `package-lock.json` would enable it; that is a one-line follow-up, not something it adds to this change. `.travis.yml` is deleted in the same pull request, and the agent checks `Readme.md` for a Travis badge to swap; this one has none.

The agent leaves the test command alone. The `--harmony` flag has nothing left to enable on a current Node and `module.parent` is deprecated there, but both still work, and the task is to move the checks, not to modernise the examples. The description lists them as candidates for a follow-up, with the files that would change, so a reviewer can decide.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Replace Travis CI with GitHub Actions in this repository. Read .travis.yml, package.json, the test script and the test files first, and keep exactly the checks Travis ran: the lint script and the test script. Run them in the sandbox on the current Node LTS and the next release line, record what passes and what fails with the error, and build the node-version matrix from the versions that pass. Write .github/workflows/ci.yml triggered on push and pull_request, with lint and test as separate steps; use npm install if there is no lockfile and say why caching is left out. Delete .travis.yml and update any badge in the README. Do not change the test command or the examples; list modernisation candidates in the pull request description instead. Include the commands you ran and their output. Open a pull request.",
  "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

What comes back is a pull request that adds `.github/workflows/ci.yml` and deletes `.travis.yml`. The workflow has one job, a `node-version` matrix of the versions the agent verified, `actions/checkout`, `actions/setup-node`, `npm install`, `npm run lint` and `npm test` as separate steps, and runs on `push` and `pull_request`.

The description quotes the lint and mocha output from the sandbox per Node version, names any version where the suite failed and why, and lists follow-ups: a `package-lock.json` to enable `npm ci` and dependency caching, and the `--harmony` and `module.parent` leftovers. The commands and full output are in the transcript at `GET /o/{org}/sessions/{id}/messages`. The new workflow runs on the pull request itself, so its first result is visible before merge.

Before merging, a reviewer compares the matrix with the Node versions the project promises in `engines`, checks the workflow is green on the pull request, and switches any required status check from Travis to the new job name.

## Run it on every repository still carrying a .travis.yml

An organisation that finds Travis files across many repositories starts one run per repository with one `POST /o/{org}/sessions` each, the repository in `resources` and this prompt as `input`. Each run reads its own Travis file and scripts, so a repository with a lockfile gets `npm ci` and caching while one without gets `npm install` and the note, and each gets a matrix verified against its own dependencies.

Send a `request_id`, a UUID v5 of the repository's full name, so a retried call returns the run it already started. The key's `webhook_url` reports when each run the key starts finishes, with the run's final answer in `result`.

## Why run it on Rush?

Translating a CI file is easy; knowing the translated commands pass on the versions you name is the slow part, because it means installing a years-old dependency tree on several Node releases and reading the failures. The agent does that in a sandbox of its own, keeps every command and its output, and builds the matrix from what actually passed.

Many repositories can be moved at once, each in its own sandbox with its own pull request and its own verified matrix. A reviewer reads the quoted output and the follow-up list instead of pushing a guessed workflow and waiting for the first red run.

## Frequently asked questions

### Will the agent change my test command?

No. The workflow runs `npm run lint` and `npm test` exactly as Travis did, with the same `--harmony` and `--require should` flags. Leftovers that a current Node no longer needs are listed in the description as candidates for a separate change.

### Why npm install instead of npm ci?

`npm ci` requires a lockfile and this repository has none, so the workflow uses `npm install`. The `cache: npm` option of `setup-node` also keys on a lockfile. Committing `package-lock.json` enables both; the agent names that as a one-line follow-up rather than adding a lockfile to a CI change.

### How does it pick the Node versions?

Travis ran `stable` and `8`. The agent runs the suite on the current LTS and the next release line in its sandbox, and the matrix lists what passed. If an old dependency fails on a newer runtime, the pull request shows the error and the version instead of a matrix that quietly excludes it.

### Does it work with yarn or pnpm projects?

Yes. The agent reads the lockfile that is present and uses the matching install command and `setup-node` cache setting. The structure of the workflow and the verification in the sandbox are the same.

## More Koa jobs

- [Write Supertest Tests for a Koa App](https://getrush.ai/run/write-supertest-tests/koa/)
- [Write the Missing Jest Tests for a Koa API](https://getrush.ai/run/write-unit-tests/koa/)
- [Add API Key Authentication to a Koa API](https://getrush.ai/run/add-api-key-auth/koa/)

## The same job on other stacks

- [Move a Mongoose API from Travis CI to GitHub Actions](https://getrush.ai/run/migrate-travis-to-github-actions/mongoose/)
- [Migrate a Python Project from Travis CI to GitHub Actions](https://getrush.ai/run/migrate-travis-to-github-actions/travis-ci/)

## More jobs like this: Hand off a long task

- [Replace ts-node With tsx in an Express and TypeDI API](https://getrush.ai/run/migrate-ts-node-to-tsx/ts-node/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
