Skip to content

Commit

Permalink
Whoops forgot the docker image. updated the yaml too
Browse files Browse the repository at this point in the history
  • Loading branch information
kek20009 committed Oct 31, 2024
1 parent 49dff66 commit 8cc9deb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 27 deletions.
52 changes: 25 additions & 27 deletions .github/workflows/ms5.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
30 changes: 30 additions & 0 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 8cc9deb

Please sign in to comment.