diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 8716a092e..053921f69 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -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: @@ -29,6 +32,7 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- + # Build Docker image from the root directory - name: Build Docker image id: build_image run: | @@ -36,18 +40,21 @@ jobs: 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" diff --git a/tests/Dockerfile b/tests/Dockerfile index 4a8a3d3f8..80d2fbb89 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -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