# Set Up CircleCI to Run Testery Tests

Testery integrates with CircleCI via the [Testery CLI](https://docs.testery.io/integrations/testery-cli-docs).

You'll need to define a GitHub Actions workflow. This is done by creating a yml file in the `.github/workflows` folder in your repository.

**Step 1. Retrieve your Testery API Token.** To retrieve your token, click **Settings → Integrations → Show API Token** and copy the token that is displayed. Keep this token secure as it allows access to Testery on your behalf.

**Step 2. Store your Testery API Token as a** [**secret environment variable in CircleCI**](https://circleci.com/docs/2.0/env-vars/#section=projects)**.**&#x20;

**Step 3.** **Add steps to your CircleCI job to install the** [**Testery CLI**](https://docs.testery.io/integrations/testery-cli-docs) **and create the test run.**

Here is a sample `.circleci/config.yml`

```yaml
version: 2 # use CircleCI 2.0
jobs: # A basic unit of work in a run
  build: # runs not using Workflows must have a `build` job as entry point
    working_directory: ~/circleci-demo-python-django
    docker: # run the steps with Docker
      - image: circleci/python:3.6.4
    steps: # steps that comprise the `build` job
      - checkout # check out source code to working directory
      - run: sudo chown -R circleci:circleci /usr/local/bin
      - run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
      - restore_cache:
      # Read about caching dependencies: https://circleci.com/docs/2.0/caching/
          key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
      - run:
          command: |
            pip install testery --upgrade
            testery create-test-run --token "${TESTERY_TOKEN}"  --git-ref "$CIRCLE_SHA1" --build-id "$CIRCLE_BUILD_NUM" --environment "<your-tetsery-environment>" --project "<your-project-key>" --wait-for-results
```
