Skip to content

Commit

Permalink
fix to build and run ci/cd, 14th attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbdevaney committed Jan 2, 2025
1 parent c732c13 commit 42b1e02
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,26 @@ on:
push:
branches:
- main
- master
- master # Added to include the master branch as well
pull_request:
branches:
- main
- master
- master # Added to include pull requests targeting the main/master branch

jobs:
test:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2

# Set up Docker Buildx (optional, for multi-platform support)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Cache Docker layers to speed up builds (optional)
- name: Cache Docker layers
uses: actions/cache@v2
with:
Expand All @@ -29,25 +32,29 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
# Build Docker image from the root directory
- name: Build Docker image
id: build_image
run: |
IMAGE_TAG="test-runner:swarm-testing-${GITHUB_SHA}"
docker build -t $IMAGE_TAG .
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Ensure logs directory exists and has correct permissions
# Ensure logs directory exists and has correct permissions
- name: Ensure logs directory exists
run: |
mkdir -p ${{ github.workspace }}/logs
chmod -R 777 ${{ github.workspace }}/logs
chmod -R 777 ${{ github.workspace }}/logs # Ensure permissions are set to allow writing
- name: Run Docker container with OpenAI API Key securely and capture test logs
# Run Docker container with OpenAI API Key securely and capture test logs
- name: Run Docker container with OpenAI API Key
run: |
docker run -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
-v ${{ github.workspace }}/logs:/usr/src/app/logs \
${{ env.IMAGE_TAG }} \
bash -c "pytest /usr/src/app/tests --continue-on-collection-errors --tb=short --disable-warnings 2>&1 | tee /usr/src/app/logs/test_logs.txt"
bash -c "pytest /usr/src/app/tests --continue-on-collection-errors --tb=short --disable-warnings | tee /usr/src/app/logs/test_logs.txt"
# Print the test logs to the console
- name: Print test logs
run: |
cat ${{ github.workspace }}/logs/test_logs.txt || echo "No test logs found"
13 changes: 11 additions & 2 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ RUN poetry config virtualenvs.create false && poetry install --no-interaction --
# Install additional dependencies outside Poetry (e.g., swarms, pytest)
RUN pip install swarms pytest

# Ensure the logs directory has correct permissions
# Ensure pytest is installed and available
RUN pytest --version

# Ensure the logs directory has correct permissions (in case of permission issues with mounted volumes)
RUN mkdir -p /usr/src/app/logs && chmod -R 777 /usr/src/app/logs

# Ensure that the PATH includes the directory where pytest is installed
ENV PATH="/usr/local/bin:$PATH"

# Set the working directory to the tests directory inside the container
WORKDIR /usr/src/app/tests

# Default command to run tests located in the /tests directory
CMD pytest /usr/src/app/tests --continue-on-collection-errors --tb=short --disable-warnings 2>&1 | tee /usr/src/app/logs/test_logs.txt
CMD pytest /usr/src/app/tests --continue-on-collection-errors --tb=short --disable-warnings | tee /usr/src/app/logs/test_logs.txt

0 comments on commit 42b1e02

Please sign in to comment.