Skip to content

try to copy the whole repo #5

try to copy the whole repo

try to copy the whole repo #5

name: test latest docker image (dev) # TODO: change
on:
push:
branches:
- 529_add_docker_testing_action_gcroci2 # TODO: change
jobs:
test_latest_docker_image:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull latest Docker image
run: |
REPO_LOWERCASE=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
docker pull ghcr.io/$REPO_LOWERCASE:latest
- name: Run tests in Docker container
run: |
REPO_LOWERCASE=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
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
# 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
# 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
# Clean up
docker stop test_container
docker rm test_container
- name: Output test results
if: failure()
run: |
echo "Tests failed. Please check the test output above for more details."