# Run simulators in CI

Run simulators in your CI job to test your agent against the same company on every run. You need a Linux runner with Docker and a working test suite. To try a simulator first, see [Run a simulator](https://console.era.eon.io/docs/run-a-simulator.md). To test against a company you've built in the console instead, see [Run an integration test in CI](https://console.era.eon.io/docs/run-an-integration-test-in-ci.md).

## Use the Era action

The action starts the requested simulators and creates an isolated company for your tests. It removes the containers when the job ends, including after a failed test. Access to the action repository is required. Public distribution is pending.

To connect your tests to the simulators:

1. Add the action before your test step, using the workflow below.
2. Read `ERA_SLACK_URL`, `ERA_SALESFORCE_URL` and `ERA_TENANT` in your tests.
3. Send `X-Sim-Tenant: $ERA_TENANT` with credentials shaped like the system's own tokens. See [Connect your agent via the API](https://console.era.eon.io/docs/connect-your-agent-via-the-api.md).

```
steps:
  - uses: actions/checkout@v7
  - uses: eon-io/ultimate-design-partner/integrations/github-action@main
    with:
      connectors: slack, salesforce
      tag: latest
      scale: '25'
  - run: npm ci && npm test
```

The action defaults to open authentication and refuses client writes. Set `writes: 'true'` for tests that change records.

`latest` moves. Replace it with an immutable published image tag to pin the images. Pin the action reference to a commit too. The action defaults to seed `42`, date `2026-01-31`, state `day1` and fidelity `high`. Set `state: ${{ matrix.state }}` to test several states in a matrix. Each invocation gets its own tenant and ports.

## Use Testcontainers

To manage simulators from your test code, install the Python, Node or Java module from `integrations/testcontainers/` in the repository. Each module's README has an install-from-path command and a lifecycle example. Start an `EraContainer("slack")`, call `tenant()` to create an isolated company, then send the returned headers with your system's test credentials. Reset the company between cases and delete it when the test ends. Each module defaults to the same settings as the action. Registry publishing is pending.

## Pin the test settings

- Pin the image tag, `SIMCORE_SEED`, `SIMCORE_TODAY`, `SIMCORE_STATE` and `SIMCORE_FIDELITY`. See [Simulator settings](https://console.era.eon.io/docs/simulator-settings.md).
- Start only the simulators your suite uses.
- Wait for the image's healthcheck instead of sleeping.
- Leave `REDIS_URL` unset and `AUTH_MODE=open` unless the test is about authentication.
- Give each test its own isolated company and reset it between tests, instead of starting a container per test.
- Don't assert on generated prose. Assert on counts, ids, relationships, and your own agent's behaviour.

## Run one simulator as a service container

To run one simulator, add it to your job as a service container:

```
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      slack:
        image: erabyeon/slack:latest
        ports: ["8115:8080"]
        env:
          SIMCORE_SEED: "42"
          SIMCORE_TODAY: "2026-01-31"
          SIMCORE_STATE: day1
          SIMCORE_FIDELITY: high
          AUTH_MODE: open
          # SIMCORE_ALLOW_CLIENT_WRITES left unset, so the suite can't change data
    # The image declares a HEALTHCHECK, so Actions runs no step until the
    # simulator reports healthy.
    steps:
      - uses: actions/checkout@v7
      - run: npm ci && npm test
        env:
          SLACK_BASE_URL: http://localhost:8115
```

## Run several simulators with Compose

To run several simulators with shared settings:

1. Save the following configuration as `docker-compose.udp.yml`.
2. Start the services with `docker compose -f docker-compose.udp.yml up -d --wait`.
3. Run your tests against the mapped URLs.
4. Remove the containers with `docker compose -f docker-compose.udp.yml down -v`.

```
# docker-compose.udp.yml: every simulator holds the same company
x-fleet: &fleet
  SIMCORE_SEED: "${SIMCORE_SEED:-42}"
  SIMCORE_TODAY: "${SIMCORE_TODAY:-2026-01-31}"
  SIMCORE_STATE: "${SIMCORE_STATE:-day1}"
  SIMCORE_FIDELITY: high
  AUTH_MODE: open

services:
  slack:
    image: ${UDP_IMAGE_PREFIX:-erabyeon/}slack:${UDP_IMAGE_TAG:-latest}
    ports: ["8115:8080"]
    environment: *fleet
  salesforce:
    image: ${UDP_IMAGE_PREFIX:-erabyeon/}salesforce:${UDP_IMAGE_TAG:-latest}
    ports: ["8116:8080"]
    environment: *fleet
```

Every service gets the image's healthcheck, so one wait covers every simulator. To test each point in time, set the state from a matrix instead of writing a second file:

```
strategy:
  matrix:
    state: [day1, day2]
steps:
  - run: docker compose -f docker-compose.udp.yml up -d --wait
    env:
      SIMCORE_STATE: ${{ matrix.state }}
```

`UDP_IMAGE_PREFIX` pulls every image from a mirror or a private copy instead. `UDP_IMAGE_TAG` defaults to `latest`, which moves. Set it to an immutable published image tag to pin the images.
