From b1b38c06cb71e35e7eb047c1253be09bb5817a16 Mon Sep 17 00:00:00 2001 From: Krrish Sehgal <133865424+krrish-sehgal@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:58:19 +0530 Subject: [PATCH] test-4 --- .github/workflows/ci-cd.yml | 33 +++++++++++++++------------------ Dockerfile | 2 +- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index eb64469ce..b5d5e9e1c 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -154,32 +154,29 @@ jobs: run: poetry run xvfb-run --auto-servernum python manage.py test -v 3 --failfast docker-test: - name: Run Tests (Docker) - needs: code-ql runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Set up Docker run: | - sudo apt-get update - sudo apt-get install apt-transport-https ca-certificates curl software-properties-common - - # Add Docker's official GPG key - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - - # Set up the Docker stable repository - echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - - # Update apt package list and install Docker - sudo apt-get update - sudo apt-get install docker-ce docker-ce-cli containerd.io + docker --version + docker-compose --version - name: Build Docker image run: | - docker build -t my-docker-image . + docker build -t my-app . + + - name: Run Docker container + run: | + docker run -d --name my-container my-app + + - name: Run tests inside Docker container + run: | + docker exec my-container poetry run python manage.py test -v 3 --failfast - - name: Run tests inside Docker + - name: Clean up run: | - docker run --rm my-docker-image poetry run python manage.py test -v 3 --failfast \ No newline at end of file + docker stop my-container + docker rm my-container \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ff3bf9bb2..8b9ab1016 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,7 @@ RUN apt-get update && \ COPY . /blt # Convert line endings and set permissions -RUN dos2unix .env Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py +RUN dos2unix Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py RUN chmod +x /blt/entrypoint.sh ENTRYPOINT ["/blt/entrypoint.sh"]