From 8d7e730d285f42998290e209f5c8886f4bf9214b Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:45:48 -0400 Subject: [PATCH] readjusting to makesure no similar container names --- .github/workflows/ms5.yaml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index cd68f58..a7ad5e0 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -12,8 +12,8 @@ jobs: python-version: ["3.8", "3.9", "3.10"] steps: - # Checkout code - - uses: actions/checkout@v2 # Updated to correct version + #Checkout code + - uses: actions/checkout@v2 # Updated to correct version #Set up Python - name: Set up Python ${{ matrix.python-version }} @@ -27,28 +27,34 @@ jobs: python -m pip install --upgrade pip pip install pylint flask flask_cors flasgger pytest - #Run pylint on all Python files - - name: Analyze code with pylint + #Run pylint on all Python files + - name: Analyze code with pylint, excluding main.py run: | pylint $(git ls-files '*.py') #Build Docker Image for API - name: Build API Docker Image run: | - docker build -t api-image -f ./Backend/dockerfile . + docker build -t api-image -f Backend/dockerfile . - #Start Container + # Stop and Remove Existing Container (if any). this was the error + - name: Stop and Remove Existing API Container + run: | + docker stop api-container || true # Stop if running, ignore if not + docker rm api-container || true # Remove if exists, ignore if not + + #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --name api-container api-image + docker run -d -p 5000:5000 --name api-container api-image # Start container on port 5000 - #Start the API Service & Run All Tests + #Run all Python tests in the directory - name: Run all Python tests in directory run: | - docker exec api-container pytest $(find . -name 'test_*.py') + docker exec api-container pytest $(find . -name 'test_*.py') # Execute tests in Docker - #End the testing + #Stop and Remove API Container after tests - name: Stop and Remove API Container run: | - docker stop api-container - docker rm api-container + docker stop api-container # Stop container after tests + docker rm api-container # Remove container after tests