Skip to content

Commit

Permalink
try to fix work dire
Browse files Browse the repository at this point in the history
  • Loading branch information
gcroci2 committed Sep 5, 2024
1 parent f61f7c1 commit 243721a
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions .github/workflows/test-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,38 @@ jobs:
docker run --name test_container -d ghcr.io/$REPO_LOWERCASE:latest tail -f /dev/null
WORK_DIR="/"
echo "Using working directory: $WORK_DIR"
# Copy entire project directory to the container
docker cp . test_container:$WORK_DIR
# Verify the tests were copied correctly
echo "Contents of $WORK_DIR/tests:"
docker exec test_container ls -la $WORK_DIR/tests
echo "Contents of $WORK_DIR/tests/data:"
docker exec test_container ls -la $WORK_DIR/tests/data
# Verify the directory structure
echo "Contents of root directory:"
docker exec test_container ls -la $WORK_DIR
echo "Contents of tests directory (if it exists):"
docker exec test_container ls -la $WORK_DIR/tests || echo "No tests directory found"
echo "Contents of data directory (if it exists):"
docker exec test_container ls -la $WORK_DIR/data || echo "No data directory found"
# Print debugging information
echo "Current working directory:"
docker exec -w $WORK_DIR test_container pwd
echo "Full path of test directory:"
docker exec test_container readlink -f $WORK_DIR/tests
# Print content of a test file
echo "Content of a test file that accesses data (first 20 lines):"
docker exec test_container head -n 20 $WORK_DIR/tests/test_*.py
# Find and print content of a test file
echo "Content of a test file (first 20 lines):"
docker exec test_container find $WORK_DIR -name "test_*.py" -type f | head -n 1 | xargs -I {} docker exec test_container head -n 20 {}
# Install pytest
docker exec test_container pip install pytest
# Run pytest from the working directory
echo "Running pytest from the working directory:"
docker exec -w $WORK_DIR test_container pytest tests -v
# Find the directory containing test files and run pytest
TEST_DIR=$(docker exec test_container find $WORK_DIR -name "test_*.py" -type f | head -n 1 | xargs dirname)
if [ -n "$TEST_DIR" ]; then
echo "Running pytest in directory: $TEST_DIR"
docker exec -w $TEST_DIR test_container pytest -v
else
echo "No test files found"
fi
# Clean up
docker stop test_container
Expand Down

0 comments on commit 243721a

Please sign in to comment.