Skip to content

Commit 51a7c7e

Browse files
[CLEANUP]
1 parent 875a4d6 commit 51a7c7e

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

.github/workflows/docker-test.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ jobs:
4646
-e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
4747
-v ${{ github.workspace }}/logs:/usr/src/app/logs \
4848
${{ env.IMAGE_TAG }} \
49-
/usr/src/app/tests | tee ${{ github.workspace }}/logs/test_logs.txt
49+
/usr/src/app/tests --continue-on-collection-errors --tb=short --disable-warnings | tee ${{ github.workspace }}/logs/test_logs.txt
5050
5151
- name: Print test logs
52-
run: cat ${{ github.workspace }}/logs/test_logs.txt || echo "No test logs found"
52+
run: cat ${{ github.workspace }}/logs/test_logs.txt || echo "No test logs found"
53+
54+
# Optional: Add debug step if needed
55+
- name: Debug Docker container
56+
if: failure()
57+
run: |
58+
docker run --rm ${{ env.IMAGE_TAG }} --version
59+
docker run --rm -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} ${{ env.IMAGE_TAG }} -h

tests/Dockerfile

+28-19
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,44 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
88
PIP_DISABLE_PIP_VERSION_CHECK=1 \
99
PIP_DEFAULT_TIMEOUT=100
1010

11-
# Set the working directory to the root of the project (relative to pyproject.toml)
11+
# Set the working directory
1212
WORKDIR /usr/src/app
1313

1414
# Copy the entire project into the container
1515
COPY . .
1616

17-
# Install Poetry
18-
RUN pip install poetry
17+
# Install system dependencies and clean up
18+
RUN apt-get update && \
19+
apt-get install -y --no-install-recommends \
20+
git \
21+
&& rm -rf /var/lib/apt/lists/*
1922

20-
# Configure Poetry to avoid virtual environments and install dependencies
21-
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi
23+
# Install Poetry and pytest
24+
RUN pip install --no-cache-dir poetry pytest
2225

23-
# Install pytest explicitly
24-
RUN pip install pytest
26+
# Configure Poetry and install project dependencies
27+
RUN poetry config virtualenvs.create false && \
28+
poetry install --no-interaction --no-ansi
2529

26-
# Check if pytest is installed successfully
27-
RUN pytest --version || echo "pytest not found"
28-
29-
# Ensure the logs directory has correct permissions
30+
# Create logs directory with proper permissions
3031
RUN mkdir -p /usr/src/app/logs && chmod -R 777 /usr/src/app/logs
3132

32-
# Ensure that the PATH includes the directory where pytest is installed
33-
ENV PATH="/usr/local/bin:$PATH"
33+
# Add pytest to PATH and verify installation
34+
ENV PATH="/usr/local/bin:/root/.local/bin:$PATH"
35+
36+
# Verify pytest installation
37+
RUN python -m pytest --version
38+
39+
# Create a shell script to run tests
40+
COPY <<EOF /usr/local/bin/run-tests.sh
41+
#!/bin/bash
42+
python -m pytest "\$@"
43+
EOF
3444

35-
# List files in /usr/src/app to check if pytest is installed correctly
36-
RUN ls -l /usr/src/app
45+
RUN chmod +x /usr/local/bin/run-tests.sh
3746

38-
# Set the working directory to the tests directory inside the container
39-
WORKDIR /usr/src/app/tests
47+
# Set the ENTRYPOINT to use the shell script
48+
ENTRYPOINT ["/usr/local/bin/run-tests.sh"]
4049

41-
# Default command to run tests located in the /tests directory
42-
CMD pytest /usr/src/app/tests --continue-on-collection-errors --tb=short --disable-warnings | tee /usr/src/app/logs/test_logs.txt
50+
# Set default pytest arguments
51+
CMD ["--continue-on-collection-errors", "--tb=short", "--disable-warnings"]

0 commit comments

Comments
 (0)