Skip to content

Commit 1e377de

Browse files
committed
feat: use docker-compose to run codspeed in the CI
1 parent 4bc77ee commit 1e377de

3 files changed

Lines changed: 36 additions & 8 deletions

File tree

.github/workflows/benchmarks.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
14-
- uses: actions/setup-python@v3
15-
with:
16-
python-version: '3.10'
17-
- run: pip install -r requirements.txt
14+
- name: Launch app in docker compose
15+
run: |
16+
docker compose up -d app
17+
- name: Run CodSpeed inside docker compose
18+
run: |
19+
# create .env file with the content of the `env` command
20+
env > .env
1821
19-
- uses: CodSpeedHQ/action@feat/tokenless-upload
20-
with:
21-
upload_url: https://api.staging.preview.codspeed.io/upload
22-
run: pytest tests/ --codspeed
22+
# pass the .env file to the docker compose exec command and run the benchmarks
23+
docker compose --env-file .env exec app sh -c "codspeed run pytest tests/ --codspeed"

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Use the official Python image from the Docker Hub
2+
FROM python:3.12
3+
4+
# Set the working directory in the container
5+
WORKDIR /app
6+
7+
# Copy the requirements file into the container
8+
COPY requirements.txt .
9+
10+
# Install the dependencies
11+
RUN pip install -r requirements.txt
12+
13+
# Copy the rest of the application code into the container
14+
COPY . .
15+
16+
# Set the RUNNER_VERSION environment variable
17+
ENV RUNNER_VERSION=3.2.1
18+
19+
# Install the CodSpeed runner
20+
RUN curl -fsSL https://github.com/CodSpeedHQ/runner/releases/download/v$RUNNER_VERSION/codspeed-runner-installer.sh | sh -s && \
21+
. $HOME/.cargo/env

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
app:
3+
build: .
4+
volumes:
5+
- .:/app
6+
command: "tail -f /dev/null"

0 commit comments

Comments
 (0)