From 77f8fe5f775a0df7354fbd98877ff147c62ea094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 16:55:41 +0100 Subject: [PATCH 01/10] Create python-app.yml --- .github/workflows/python-app.yml | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..951ff9a --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,37 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python application + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install dependencies + run: | + cd backend + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with unittest + run: | + python test.py -- 2.49.1 From 833091a54be6ad62e3cf0c804091446b0cc76b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 16:57:02 +0100 Subject: [PATCH 02/10] Update python-app.yml --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 951ff9a..c0a836c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -34,4 +34,4 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with unittest run: | - python test.py + python backend/test.py -- 2.49.1 From f7bafbf6f3252e7da6a90073ea808c20c083bc90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 17:53:23 +0100 Subject: [PATCH 03/10] Create docker-image.yml --- .github/workflows/docker-image.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..4d69753 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,16 @@ +name: Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: Run Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run tests + run: docker-compose run test -- 2.49.1 From bb94900021dcaec0f3f948882ed92ffe957406bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 17:53:33 +0100 Subject: [PATCH 04/10] Delete python-app.yml --- .github/workflows/python-app.yml | 37 -------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index c0a836c..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python application - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install dependencies - run: | - cd backend - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with unittest - run: | - python backend/test.py -- 2.49.1 From 807145d9e1156e479e23557665181452d54ede95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 17:55:36 +0100 Subject: [PATCH 05/10] Update docker-image.yml --- .github/workflows/docker-image.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4d69753..5b7c3cb 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,6 +11,9 @@ jobs: name: Run Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 + - name: Build docker images + run: docker-compose build - name: Run tests run: docker-compose run test -- 2.49.1 From ad6c6fbd761f1e86c721967fe4a615d459058e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 17:59:00 +0100 Subject: [PATCH 06/10] Update: Docker test --- backend/Dockerfile | 3 +-- backend/fictive_users.py | 33 ++++++++++++++------------------- docker-compose.yml | 26 ++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 7d9dfa6..2987276 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -3,5 +3,4 @@ WORKDIR /data/backend COPY requirements.txt requirements.txt RUN pip install --upgrade pip RUN pip install -r requirements.txt -COPY . . -CMD [ "python", "-m" , "flask", "run", "--host=0.0.0.0"] \ No newline at end of file +COPY . . \ No newline at end of file diff --git a/backend/fictive_users.py b/backend/fictive_users.py index 6d587a7..6f97529 100644 --- a/backend/fictive_users.py +++ b/backend/fictive_users.py @@ -1,25 +1,21 @@ import os -import sys -sys.path.append("../application") from application.users_model import Users from application.api_functions import hash_password - - TAB_USER_WITH_PASSWORD = [ { - "id": 1, - "email": "riri@gmail.com", - "nickname": "Riri", - "password": "ririPass", - "is_admin": False + "id": 1, + "email": "riri@gmail.com", + "nickname": "Riri", + "password": "ririPass", + "is_admin": False }, { "id": 2, "email": "fifi@gmail.com", "nickname": "Fifi", "password": "fifiPass", - "is_admin": False + "is_admin": False }, { "id": 3, @@ -27,26 +23,25 @@ TAB_USER_WITH_PASSWORD = [ "nickname": "Donald", "password": "donaldPass", "is_admin": False - }, + }, { "id": 4, "email": "daisy@gmail.com", "nickname": "Daisy", "password": "daisyPass", "is_admin": True - }, + }, ] - # Convert user with passord (uwp) to user def uwp_to_user(uwp): salt0 = os.urandom(32) hash_pass0 = hash_password(salt0, uwp["password"]) return Users( - email = uwp["email"], - nickname = uwp["nickname"], - hash_pass = hash_pass0, - salt = salt0, - is_admin = uwp["is_admin"] - ) \ No newline at end of file + email=uwp["email"], + nickname=uwp["nickname"], + hash_pass=hash_pass0, + salt=salt0, + is_admin=uwp["is_admin"] + ) diff --git a/docker-compose.yml b/docker-compose.yml index 53b6112..f5519be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,7 @@ services: backend: container_name: backend build: ./backend + command: python -m flask run --host=0.0.0.0 ports: - "5000:5000" volumes: @@ -58,14 +59,35 @@ services: container_name: frontend build: ./frontend command: npm start + ports: + - "4200:4200" volumes: - ./frontend:/data/frontend - ./frontend/node_modules:/data/frontend/node_modules - ports: - - "4200:4200" depends_on: - backend links: - backend environment: - NODE_ENV=development + + test: + container_name: test + build: ./backend + command: python test.py + volumes: + - ./backend:/data/backend + depends_on: + - flaskaled-srv1 + - flaskaled-srv2 + links: + - flaskaled-srv1 + - flaskaled-srv2 + environment: + - FLASK_APP=app.py + - FLASK_ENV=test + - FLASK_DEBUG=0 + - PYTHONUNBUFFERED=1 + - DATABASE_URL_USERS=postgresql://flaskaled1:aled1@flaskaled-srv1/flaskaledDb1 + - DATABASE_URL_LOGS=postgresql://flaskaled2:aled2@flaskaled-srv2/flaskaledDb2 + - SECRET_KEY=default_secret_key -- 2.49.1 From 9681222b9db3227de73a21af414088119dca8809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 17:59:35 +0100 Subject: [PATCH 07/10] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5b7c3cb..930661c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -13,7 +13,5 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build docker images - run: docker-compose build - name: Run tests run: docker-compose run test -- 2.49.1 From 21dd75bf0e5413be479ca9e9e316c12b55a3f73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 18:01:19 +0100 Subject: [PATCH 08/10] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 930661c..78edd4b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -13,5 +13,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + - name: Build docker images + run: docker-compose build test - name: Run tests run: docker-compose run test -- 2.49.1 From df7bcf9ad2285803573186baa019731183703785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 18:01:53 +0100 Subject: [PATCH 09/10] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 78edd4b..5b7c3cb 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -14,6 +14,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Build docker images - run: docker-compose build test + run: docker-compose build - name: Run tests run: docker-compose run test -- 2.49.1 From f4ed6ce04040ba24f9a83925e48a85264cc2bd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 18:04:47 +0100 Subject: [PATCH 10/10] Update: Docker test --- frontend/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 70a19c6..007013d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,6 +1,7 @@ FROM node:current-slim WORKDIR /data/frontend COPY ["package.json", "package-lock.json*", "./"] +RUN npm install -g npm RUN npm install --NODE_ENV RUN npm install -g @angular/cli COPY . . -- 2.49.1