GitHub
In this example, you have a GitHub repository which contains the application you would like to test.
Note that you will need a ReSim project. You can create a project with the ReSim CLI.
This example uses our GitHub action.
Prerequisites
Referring to GitHub's documentation about setting repository secrets as required, navigate to your repository's Settings and go to the "Secrets and variables" page in the Security section.
Add the following secrets:
AWS_ACCESS_KEY_ID
- set the value of this to the access key generated when you set up your ECR repository for use with ReSimAWS_SECRET_ACCESS_KEY
- set the value of this to the secret access key generated when you set up your ECR repository for use with ReSim
Also add one of these sets of secrets. Your ReSim contact will provide you with either a client ID and secret, or a username and password:
RESIM_CLIENT_ID
andRESIM_CLIENT_SECRET
, orRESIM_USERNAME
andRESIM_PASSWORD
Add a variable containing your ECR registry URL:
ECR_REGISTRY_URL
- for example123456789.dkr.ecr.us-east-1.amazonaws.com
Workflow
Now you need to create a GitHub workflow by adding a file to .github/workflows/
in your repository.
Below is an example of a workflow that builds a Docker image, pushes it to an ECR repository and launches a batch in ReSim to test it.
If you use this example, make sure to replace the following placeholder values:
<your build command>
- any commands that need to run before the Docker build, e.g.bazel build
<your image name>
- replace with the name of the ECR repository, e.g. the name of the image/application<your project name>
- replace with the name of your ReSim project<your experience names>
- the experience(s) you want to test against (see Adding Experiences), comma-separated
name: build-and-test
on:
pull_request:
push:
branches:
- "main"
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: <your build command>
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ECR
uses: docker/login-action@v2
with:
registry: ${{ vars.ECR_REGISTRY_URL }}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Prepare Docker metadata
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.ECR_REGISTRY_URL }}/<your image name>
tags: |
type=sha
- name: Build and push image
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
- name: Launch Batch in ReSim
uses: resim-ai/action@v1
with:
# Provide one of client ID and client secret...
client_id: ${{ secrets.RESIM_CLIENT_ID }}
client_secret: ${{ secrets.RESIM_CLIENT_SECRET }}
# ... or username and password
resim_username: ${{ secrets.RESIM_USERNAME }}
resim_password: ${{ secrets.RESIM_PASSWORD }}
project: <your project name>
system: <your system name>
image: ${{ steps.docker_meta.outputs.tags }}
experiences: <your experience names>
## Note that you can also use experience tags:
# experience_tags: <your experience tags>
metrics-build-id: <your metrics build id>
## If you would like the action to post a link to the results on PRs:
comment_on_pr: true
github_token: ${{ secrets.GITHUB_TOKEN }}