diff --git a/.github/workflows/ci-build.yaml b/.github/workflows/ci-build.yaml new file mode 100644 index 0000000..b81d4f2 --- /dev/null +++ b/.github/workflows/ci-build.yaml @@ -0,0 +1,44 @@ +name: CI Build +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + container: python:3.9-slim + + services: + postgres: + image: postgres:alpine + ports: + - 5432:5432 + env: + POSTGRES_PASSWORD: pgs3cr3t + POSTGRES_DB: testdb + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r requirements.txt + - name: Lint with flake8 + run: | + flake8 service --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 service --count --max-complexity=10 --max-line-length=127 --statistics + + - name: Run unit tests with nose + run: nosetests + env: + DATABASE_URI: "postgresql://postgres:pgs3cr3t@postgres:5432/testdb" diff --git a/README.md b/README.md index 0121774..52581c7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # DevOps Capstone Template - +![Build Status](https://github.com/Krysed/devops-capstone-project/actions/workflows/ci-build.yaml/badge.svg) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Python 3.9](https://img.shields.io/badge/Python-3.9-green.svg)](https://shields.io/) diff --git a/service/routes.py b/service/routes.py index 9130819..c568252 100644 --- a/service/routes.py +++ b/service/routes.py @@ -38,6 +38,8 @@ def index(): ###################################################################### # CREATE A NEW ACCOUNT ###################################################################### + + @app.route("/accounts", methods=["POST"]) def create_accounts(): """ @@ -60,6 +62,8 @@ def create_accounts(): ###################################################################### # LIST ALL ACCOUNTS ###################################################################### + + @app.route("/accounts", methods=["GET"]) def list_accounts(): """ @@ -77,6 +81,8 @@ def list_accounts(): ###################################################################### # READ AN ACCOUNT ###################################################################### + + @app.route("/accounts/", methods=["GET"]) def get_accounts(account_id): """ @@ -95,6 +101,7 @@ def get_accounts(account_id): # UPDATE AN EXISTING ACCOUNT ###################################################################### + @app.route("/accounts/", methods=["PUT"]) def update_accounts(account_id): """ @@ -114,6 +121,7 @@ def update_accounts(account_id): # DELETE AN ACCOUNT ###################################################################### + @app.route("/accounts/", methods=["DELETE"]) def delete_accounts(account_id): """