Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9f5de9f
Bench 152 write unit tests for LineItemSerializer, CategorySerializer…
JoeCSykes Dec 7, 2022
16d1fd7
BENCH-246: Write unit tests for product serializers (#47)
MichaelOSullivanAnswer Dec 12, 2022
783daf4
Bump certifi from 2022.9.24 to 2022.12.7 (#48)
dependabot[bot] Dec 12, 2022
55471ee
Bump django from 4.1.3 to 4.1.4 (#49)
dependabot[bot] Dec 13, 2022
c7fe9f7
created docker file and updated docker-compose
Nov 29, 2022
63a3b0d
minor changed, added some information to the ReadMe
Nov 30, 2022
190d7f1
fixed port error
Nov 30, 2022
fc27449
removed not used args from DockerFile
Dec 1, 2022
a7f5a3f
added branch argument in docker file
Dec 1, 2022
b728fe2
removed file .env from docker compose and added explicit environtment
Dec 1, 2022
4d4f6f6
added publish workflow
Dec 1, 2022
f9b94ef
moved entrypoint in DockerFile
Dec 2, 2022
81bbed8
updated README
Dec 2, 2022
93530a4
test package workflow
Dec 5, 2022
adac8ea
added workflow dispatch
Dec 5, 2022
92eb4c2
renamed workflow file
Dec 5, 2022
e73866a
added workflow on_pull_request
Dec 5, 2022
09facd1
trigger workflows
Dec 5, 2022
627e705
added dockerfile name
Dec 5, 2022
82acbd0
added image field
Dec 5, 2022
7b1b101
added migrations and timezone dependencies
Dec 6, 2022
eed198f
condensed DockerFile
JoeCSykes Dec 7, 2022
e56fdee
testing docker workflow
JoeCSykes Dec 8, 2022
b8843ac
trigger on pull request
JoeCSykes Dec 8, 2022
e4f9558
changed name of docker file
JoeCSykes Dec 8, 2022
7255ab3
added wait func to ensure db is up before running app
JoeCSykes Dec 13, 2022
92c09fa
corrected so can send requests + updated ReadMe details
JoeCSykes Dec 14, 2022
2413e90
run make prepare + changed git ignore to ignore any file starting wit…
JoeCSykes Dec 14, 2022
e6235e5
Delete .env.production
JoeCSykes Dec 14, 2022
b3f7861
supplied database engine value to env variables
JoeCSykes Dec 14, 2022
7864a58
Update test.yml
JoeCSykes Dec 14, 2022
7cec4d3
Bench 89 add integration test step to workflow (#55)
JoeCSykes Dec 15, 2022
b4583f7
Bench 89 add integration test step to workflow (#56)
JoeCSykes Dec 15, 2022
2b2f0eb
merged linting workflow and unit test / sonar cloud workflow together…
JoeCSykes Dec 19, 2022
7cdb08d
Bench 105 create docker image (#44)
PietroConvalleAD Dec 19, 2022
43e58ee
BENCH-271: Write unit tests for utils (#54)
MichaelOSullivanAnswer Dec 21, 2022
e1b2b41
Bench 258 unit tests for order serializer (#52)
NogaAD Dec 21, 2022
c630449
Bump django from 4.1.4 to 4.1.5 (#59)
dependabot[bot] Jan 4, 2023
723429d
Bump pytz from 2022.6 to 2022.7 (#58)
dependabot[bot] Jan 4, 2023
753119f
BENCH-267-return-204-for-all-delete-methods
NogaAD Jan 6, 2023
ccdf393
BENCH-285-configure-sonarcloud (#61)
JoeCSykes Jan 10, 2023
61da46f
update "unit test and sonarcloud job to use V3 of checkout action (#64)
JoeCSykes Jan 11, 2023
dc78c5a
BENCH-186: Add OpenAPI documentation (#63)
MichaelOSullivanAnswer Jan 12, 2023
60e0b2d
Bump pytz from 2022.7 to 2022.7.1 (#66)
dependabot[bot] Jan 16, 2023
946332e
Merge branch 'release-test' into develop
JoeCSykes Jan 18, 2023
fc74120
Bump python-dotenv from 0.21.0 to 0.21.1 (#68)
dependabot[bot] Jan 25, 2023
b07fc14
Bump pyright from 1.1.288 to 1.1.290 (#69)
dependabot[bot] Jan 25, 2023
511cc24
Bump pyright from 1.1.290 to 1.1.291 (#71)
dependabot[bot] Jan 31, 2023
8bac69b
BENCH-297: Terraform AWS infrastructure (#70)
MichaelOSullivanAnswer Feb 1, 2023
ffadc19
Bench 349: Products set to have one category (#73)
NogaAD Feb 1, 2023
0df6741
Bench 276 sort integration tests for products and categories (#72)
JoeCSykes Feb 2, 2023
580a010
Bench-371: GitHub action to deploy (#74)
MichaelOSullivanAnswer Feb 3, 2023
80d0c37
Bench 338 implement tags endpoint (#76)
JoeCSykes Feb 3, 2023
56a3119
Bump pyright from 1.1.291 to 1.1.292 (#78)
dependabot[bot] Feb 6, 2023
342b283
Bump django from 4.1.5 to 4.1.6 (#77)
dependabot[bot] Feb 6, 2023
478c3a4
added ignore slashs middleware (#81)
PietroConvalleAD Feb 7, 2023
6f1e2da
Bench 343 create integration test for tags (#80)
JoeCSykes Feb 7, 2023
10517c8
Bench-378 and bench-381 retire (#79)
PietroConvalleAD Feb 7, 2023
4cdc2d8
Bench-372: Add load balancer and attach elastic ip & domain name (#75)
MichaelOSullivanAnswer Feb 8, 2023
87d1334
Update README.md
JoeCSykes Feb 10, 2023
7c33515
Update README.md
JoeCSykes Feb 10, 2023
1ef8d64
Bench 369 orders integration tests (#82)
NogaAD Feb 10, 2023
69d558b
Bump drf-yasg from 1.21.4 to 1.21.5 (#83)
dependabot[bot] Feb 14, 2023
d6f8ffb
Bench 421 fix id assignment bug (#85)
NogaAD Feb 15, 2023
23a9b6a
Bump django from 4.1.6 to 4.1.7 (#86)
dependabot[bot] Feb 16, 2023
fcce194
Bench-424 order fix (#87)
PietroConvalleAD Feb 17, 2023
02f19bc
Bench 435 add range ip ban (#88)
JoeCSykes Feb 23, 2023
3802a0b
fix bugs in swagger generation (#89)
JoeCSykes Feb 24, 2023
dabb595
HTTPS-420 changed connection to https only (#91)
PietroConvalleAD Feb 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/CodeAnalysisCI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Static_code_analysis

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
workflow_dispatch:
permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results


jobs:
black_test:
name: Black Test
runs-on: ubuntu-latest
steps:
- uses : actions/checkout@v3
- uses: ./.github/actions/dependencies
- name: Run Black Test
run: poetry run black . --line-length=79 --check
pycodestyle_test:
name: Pycodestyle Test
runs-on: ubuntu-latest
steps:
- uses : actions/checkout@v3
- uses: ./.github/actions/dependencies
- name: Run Pycodestyle Test
run: poetry run pycodestyle . --ignore=E501
pyright_test:
name: Pyright Test
runs-on: ubuntu-latest
steps:
- uses : actions/checkout@v3
- uses: ./.github/actions/dependencies
- name: Run Pyright Test
run: poetry run pyright .
unit_test_and_sonar_cloud_report:
name: Unit Test and SonarCloud Test
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DATABASE_PASS }}
MYSQL_DATABASE: answerking_app
ports: [ '3306:3306' ]
env:
DATABASE_NAME: answerking_app
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASS: ${{ secrets.DATABASE_PASS }}
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: 3306
DATABASE_ENGINE: django.db.backends.mysql
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DJANGO_SETTINGS_MODULE: answerking.settings.development
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/dependencies
- name: Run Migrations
run: poetry run python manage.py migrate
- name: Run Unit Tests
run: poetry run python manage.py test answerking_app.tests.test_unit
- name: generate coverage tests
run: poetry run coverage run manage.py test --noinput
- name: generate report
run: poetry run coverage xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
args: >
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.exclusions=answerking_app/tests/**
35 changes: 35 additions & 0 deletions .github/workflows/IntegrationCI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Integration Test

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
workflow_dispatch:

jobs:
integration_tests:
name: Integration Test
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DATABASE_PASS }}
MYSQL_DATABASE: answerking_app
ports: [ '3306:3306' ]
env:
DATABASE_NAME: answerking_app
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASS: ${{ secrets.DATABASE_PASS }}
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: 3306
DATABASE_ENGINE: django.db.backends.mysql
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DJANGO_SETTINGS_MODULE: answerking.settings.development
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/dependencies
- name: Run Integration Tests
run: poetry run python manage.py test answerking_app.tests.test_integration
71 changes: 71 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and deploy

on:
push:
branches: [ "release-*"]

env:
AWS_REGION: eu-west-2
ECS_SERVICE: ak-python-ecs-service
ECS_CLUSTER: ak-python-ecs-cluster
ECS_TASK_DEFINITION: task-definition.json
CONTAINER_NAME: ak-python-container



jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.PYTHON_TEST_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.PYTHON_TEST_SECRET_KEY }}
aws-region: eu-west-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.PYTHON_REPO_NAME }}
IMAGE_TAG: latest
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition ak-python-task --query taskDefinition > ${{ env.ECS_TASK_DEFINITION }}

- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
43 changes: 43 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker

on:
push:
branches: ['release-*']
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@master
with:
image: AnswerConsulting/AnswerKing-Python
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
32 changes: 0 additions & 32 deletions .github/workflows/linting.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/test.yml

This file was deleted.

11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ celerybeat-schedule.*
*.sage.py

# Environments
.env
.env*
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
variables_env.tf

# mkdocs documentation
/site
Expand Down Expand Up @@ -143,3 +144,11 @@ GitHub.sublime-settings

.idea/*
*.sqlite3

# Terraform
.terraform/
.terraform.lock.hcl
terraform.tfstate
terraform.tfstate.*
terraform.tfstate.backup
.terraform.tfstate.lock.info
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# syntax=docker/dockerfile:1

FROM python:3.10.8-buster
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

COPY . /AnswerKing-Python
WORKDIR /AnswerKing-Python

RUN pip install poetry
RUN poetry install --only main
RUN pip install make

CMD [ "/usr/bin/make", "dockerRunserver"]
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ clean:

lint:
poetry run black . --line-length=79
poetry run pycodestyle --ignore=E501 .
poetry run pycodestyle . --max-line-length=100 --exclude=**/snapshots/**
poetry run pyright

test: clean
poetry run coverage run --omit=*/migrations/*,*answerking/* manage.py test --noinput
poetry run coverage run --omit=*/migrations/*,*answerking/*,*/tests/*,*manage.py manage.py test --noinput
poetry run coverage report
poetry run coverage html

migrate:
poetry run python manage.py makemigrations
poetry run python manage.py migrate

dockerRunserver:
poetry run python manage.py waitForDB
poetry run python manage.py migrate
poetry run gunicorn -b 0.0.0.0\:8000 answerking.wsgi\:application

prepare: lint test
Loading