From 8cc9deb79701cd6bae0e1218ef413afe3f63ce21 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Wed, 30 Oct 2024 20:10:44 -0400 Subject: [PATCH] Whoops forgot the docker image. updated the yaml too --- .github/workflows/ms5.yaml | 52 ++++++++++++++++++-------------------- docker/dockerfile | 30 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 docker/dockerfile diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index b96d2e3..8acca7e 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -1,56 +1,54 @@ -name: ms5API Testing +name: Pylint and API Testing on: - push: #we want only the milstone5 - branches: [Milestone-5_feature_branch] - pull_request: + push: branches: [Milestone-5_feature_branch] jobs: - api-testing: - runs-on: ubuntu-latest + test-and-lint: + runs-on: self-hosted # or ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] steps: - - name: Checkout code - uses: actions/checkout@v2 + + uses: actions/checkout@v2 # Updated to correct version - - name: Set up Python 3 + #Set up Python + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: '3.8' + python-version: ${{ matrix.python-version }} + #Install everything - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flask flask_cors flasgger pylint pytest + pip install pylint flask flask_cors flasgger pytest - # Run pylint - - name: Run pylint + #Run pylint on all Python files + - name: Analyze code with pylint run: | - pylint ./backend/*.py - continue-on-error: false # Set to true to see warnings + pylint $(git ls-files '*.py') - #docker image build + #Build Docker Image for API - name: Build API Docker Image run: | - docker build -t api-image -f Dockerfile . + docker build -t api-image -f ./docker/dockerfile . + - #run docker container + #tart Container - name: Start API Container run: | docker run -d -p 5000:5000 --name api-container api-image - #running main.py - - name: Start API Service - run: | - docker exec api-container python main.py - - #test_main.py - - name: Run test_main.py + #Start the API Service & Run All Tests + - name: Run all Python tests in directory run: | - docker exec api-container pytest test_main.py --maxfail=1 --disable-warnings + docker exec api-container pytest $(find . -name 'test_*.py') - #cut the docker + #End the testing - name: Stop and Remove API Container run: | docker stop api-container diff --git a/docker/dockerfile b/docker/dockerfile new file mode 100644 index 0000000..b329730 --- /dev/null +++ b/docker/dockerfile @@ -0,0 +1,30 @@ +# For more information, please refer to https://aka.ms/vscode-docker-python +#just so yk this dockerfile is the template docker gave me lol +# + +FROM ubuntu:latest +FROM python:3.8-slim-buster +#install pip & python3 +RUN apt-get update && apt-get install -y python3 python3-pip +# Keeps Python from generating .pyc files in the container +ENV PYTHONDONTWRITEBYTECODE=1 + +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED=1 + +# Install pip requirements +COPY requirements.txt . +#just use python3 +RUN python3 -m pip install -r requirements.txt + +COPY main.py /main.py +ENV PORT=5000 +EXPOSE 5000 + +# Creates a non-root user with an explicit UID and adds permission to access the /app folder +# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers +#RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app +#USER appuser + +# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug +CMD ["python3", "main.py"] \ No newline at end of file