Skip to content

remove duplicated run #8

remove duplicated run

remove duplicated run #8

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
TEST_DIR="/tests"
echo "Tests directory: $TEST_DIR"
# Copy only the tests folder to the container
docker cp tests test_container:$TEST_DIR
# Verify the directory structure
echo "Contents of tests directory:"
docker exec test_container ls -la $TEST_DIR
echo "Contents of tests/data directory:"
docker exec test_container ls -la $TEST_DIR/data
# Print content of a test file
echo "Content of a test file (first 20 lines):"
docker exec test_container head -n 20 $TEST_DIR/test_*.py | head -n 20
# Install pytest
docker exec test_container pip install pytest
# Run pytest
echo "Running pytest in the tests directory:"
docker exec -w $TEST_DIR test_container pytest -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."