From 904e421d19a70c9ab7ee73cbfbfa993ca8e1965b Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 14:05:45 +0530 Subject: [PATCH 1/9] Tests and coverage --- .github/workflows/{ci.yml => pr-build.yml} | 114 ++++----- .github/workflows/publish.yml | 143 +++++++++++ deploy/docker/.env | 2 +- .../crAPI.postman_environment.json | 2 +- services/community/Dockerfile | 4 +- services/docker-database.yml | 50 ++++ services/workshop/.gitignore | 2 + services/workshop/Dockerfile | 8 +- services/workshop/core/__init__.py | 0 services/workshop/core/management/__init__.py | 0 .../core/management/commands/seed_database.py | 226 ++++++++++++++++++ services/workshop/crapi/apps.py | 36 +-- services/workshop/crapi/mechanic/models.py | 4 +- services/workshop/crapi/user/models.py | 1 + services/workshop/crapi_site/settings.py | 6 +- services/workshop/requirements.txt | 4 +- services/workshop/runner.sh | 16 +- services/workshop/utils/messages.py | 1 + 18 files changed, 514 insertions(+), 105 deletions(-) rename .github/workflows/{ci.yml => pr-build.yml} (64%) create mode 100644 .github/workflows/publish.yml create mode 100644 services/docker-database.yml create mode 100644 services/workshop/core/__init__.py create mode 100644 services/workshop/core/management/__init__.py create mode 100644 services/workshop/core/management/commands/seed_database.py diff --git a/.github/workflows/ci.yml b/.github/workflows/pr-build.yml similarity index 64% rename from .github/workflows/ci.yml rename to .github/workflows/pr-build.yml index 0c4fddbc..28fbb989 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/pr-build.yml @@ -1,4 +1,4 @@ -name: Docker Image CI +name: PR Build on: push: @@ -23,8 +23,6 @@ on: jobs: build-context: runs-on: ubuntu-latest - outputs: - push_image: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) || (github.event_name == 'release' && github.event.action == 'published') }} steps: - name: Dump GitHub context env: @@ -84,13 +82,6 @@ jobs: id: qemu uses: docker/setup-qemu-action@v2 - - name: Login to DockerHub - if: needs.build-context.outputs.push_image == 'true' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build crapi-identity image uses: docker/build-push-action@v2 with: @@ -185,68 +176,61 @@ jobs: - name: Run Postman Collection run: (newman run "./postman_collections/crAPI.postman_collection.json" -e ./postman_collections/crAPI.postman_environment.json --verbose) || true - - name: Build crapi-identity all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 - with: - context: ./services/identity - tags: crapi/crapi-identity:${{ env.TAG_LATEST }},crapi/crapi-identity:${{ env.TAG_NAME }} - push: ${{ needs.build-context.outputs.push_image }} - platforms: ${{ env.PLATFORMS }} - cache-from: type=gha,scope=identity-service - cache-to: type=gha,mode=max,scope=identity-service + - name: Dump docker logs on failure + if: failure() + uses: jwalton/gh-docker-logs@v2 - - name: Build crapi-workshop all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 - with: - context: ./services/workshop - tags: crapi/crapi-workshop:${{ env.TAG_LATEST }},crapi/crapi-workshop:${{ env.TAG_NAME }} - push: ${{ needs.build-context.outputs.push_image }} - platforms: ${{ env.PLATFORMS }} - cache-from: type=gha,scope=workshop-service - cache-to: type=gha,mode=max,scope=workshop-service + - name: Run crAPI using built images + run: docker-compose -f deploy/docker/docker-compose.yml down --volumes --remove-orphans - - name: Build crapi-community all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 - with: - context: ./services/community - tags: crapi/crapi-community:${{ env.TAG_LATEST }},crapi/crapi-community:${{ env.TAG_NAME }} - push: ${{ needs.build-context.outputs.push_image }} - platforms: ${{ env.PLATFORMS }} - cache-from: type=gha,scope=community-service - cache-to: type=gha,mode=max,scope=community-service - - name: Build crapi-web all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 + tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 with: - context: ./services/web - tags: crapi/crapi-web:${{ env.TAG_LATEST }},crapi/crapi-web:${{ env.TAG_NAME }} - push: ${{ needs.build-context.outputs.push_image }} - platforms: ${{ env.PLATFORMS }} - cache-from: type=gha,scope=web-service - cache-to: type=gha,mode=max,scope=web-service + python-version: '3.10' - - name: Build gateway-service all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 + - name: Setup Java + uses: actions/setup-java@v4 with: - context: ./services/gateway-service - tags: crapi/gateway-service:${{ env.TAG_LATEST }},crapi/gateway-service:${{ env.TAG_NAME }} - push: ${{ needs.build-context.outputs.push_image }} - platforms: ${{ env.PLATFORMS }} - cache-from: type=gha,scope=gateway-service - cache-to: type=gha,mode=max,scope=gateway-service + distribution: 'adopt' + java-version: '11' - - name: Build mailhog all platforms and conditionally push to Docker Hub - if: steps.check_mailhog_exists.outputs.files_exists == 'true' - uses: docker/build-push-action@v2 + - name: Setup Go + uses: actions/setup-go@v5 with: - context: ./services/mailhog - tags: crapi/mailhog:${{ env.TAG_LATEST }},crapi/mailhog:${{ env.TAG_NAME }} - push: ${{ needs.build-context.outputs.push_image }} - platforms: ${{ env.PLATFORMS }} - cache-from: type=gha,scope=mailhog-service - cache-to: type=gha,mode=max,scope=mailhog-service + go-version: '1.21' - - name: Dump docker logs on failure - if: failure() - uses: jwalton/gh-docker-logs@v2 + - name: Start the database + run: docker-compose -f services/docker-database.yml up -d + - name: Run identity tests + run: | + cd services/identity + ./gradlew test + + - name: Run community tests + run: | + cd services/community + go test -v ./... + + - name: Run workshop tests + run: | + cd services/workshop + virtualenv venv + source venv/bin/activate + pip install -r requirements.txt + IS_TESTING=True python3 manage.py test --no-input + + - name: Run workshop coverage + run: | + cd services/workshop + source venv/bin/activate + coverage run ./manage.py test crapi + coverage report + coverage xml -o coverage.xml \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..d3dd4be7 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,143 @@ +name: Publish Images + +on: + push: + branches: + - 'develop' + - 'main' + tags: + - 'v*.*.*' + paths: + - 'services/**' + - 'postman_collections/**' + - 'deploy/**' + - '.github/workflows/**' + workflow_dispatch: + +jobs: + build-context: + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + build: + needs: build-context + runs-on: ubuntu-latest + env: + PLATFORMS: "linux/amd64,linux/arm64" + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Env seen prerun + run: env + + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v5.2 + + - name: Current branch name + run: | + echo "Current Branch: ${{ steps.branch-name.outputs.current_branch }}" + echo "Target Branch: ${{ steps.branch-name.outputs.base_ref_branch }}" + echo "Tag if exist: ${{ steps.branch-name.outputs.tag }}" + + - name: Running on a tag. + if: steps.branch-name.outputs.is_tag == 'true' + run: | + echo "TAG_NAME=${{ steps.branch-name.outputs.tag }}" >> ${GITHUB_ENV} + echo "TAG_LATEST=latest" >> ${GITHUB_ENV} + + - name: Running on a branch and merge. + if: steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch != 'main' + run: | + echo "TAG_NAME=${{ steps.branch-name.outputs.current_branch }}" >> ${GITHUB_ENV} + echo "TAG_LATEST=${{ steps.branch-name.outputs.current_branch }}" >> ${GITHUB_ENV} + + - name: Running on main branch. + if: steps.branch-name.outputs.is_tag != 'true' && github.event_name == 'push' && steps.branch-name.outputs.current_branch == 'main' + run: | + echo "TAG_NAME=${{ steps.branch-name.outputs.current_branch }}" >> ${GITHUB_ENV} + echo "TAG_LATEST=latest" >> ${GITHUB_ENV} + + - name: Running on a branch and pull req. + if: steps.branch-name.outputs.is_tag != 'true' && github.event_name != 'push' + run: | + echo "TAG_NAME=${{ steps.branch-name.outputs.base_ref_branch }}" >> ${GITHUB_ENV} + echo "TAG_LATEST=${{ steps.branch-name.outputs.base_ref_branch }}" >> ${GITHUB_ENV} + + # setup Docker build action + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build crapi-identity all platforms and conditionally push to Docker Hub + uses: docker/build-push-action@v2 + with: + context: ./services/identity + tags: crapi/crapi-identity:${{ env.TAG_LATEST }},crapi/crapi-identity:${{ env.TAG_NAME }} + platforms: ${{ env.PLATFORMS }} + cache-from: type=gha,scope=identity-service + cache-to: type=gha,mode=max,scope=identity-service + + - name: Build crapi-workshop all platforms and conditionally push to Docker Hub + uses: docker/build-push-action@v2 + with: + context: ./services/workshop + tags: crapi/crapi-workshop:${{ env.TAG_LATEST }},crapi/crapi-workshop:${{ env.TAG_NAME }} + platforms: ${{ env.PLATFORMS }} + cache-from: type=gha,scope=workshop-service + cache-to: type=gha,mode=max,scope=workshop-service + + - name: Build crapi-community all platforms and conditionally push to Docker Hub + uses: docker/build-push-action@v2 + with: + context: ./services/community + tags: crapi/crapi-community:${{ env.TAG_LATEST }},crapi/crapi-community:${{ env.TAG_NAME }} + platforms: ${{ env.PLATFORMS }} + cache-from: type=gha,scope=community-service + cache-to: type=gha,mode=max,scope=community-service + + - name: Build crapi-web all platforms and conditionally push to Docker Hub + uses: docker/build-push-action@v2 + with: + context: ./services/web + tags: crapi/crapi-web:${{ env.TAG_LATEST }},crapi/crapi-web:${{ env.TAG_NAME }} + platforms: ${{ env.PLATFORMS }} + cache-from: type=gha,scope=web-service + cache-to: type=gha,mode=max,scope=web-service + + - name: Build gateway-service all platforms and conditionally push to Docker Hub + uses: docker/build-push-action@v2 + with: + context: ./services/gateway-service + tags: crapi/gateway-service:${{ env.TAG_LATEST }},crapi/gateway-service:${{ env.TAG_NAME }} + platforms: ${{ env.PLATFORMS }} + cache-from: type=gha,scope=gateway-service + cache-to: type=gha,mode=max,scope=gateway-service + + - name: Build mailhog all platforms and conditionally push to Docker Hub + if: steps.check_mailhog_exists.outputs.files_exists == 'true' + uses: docker/build-push-action@v2 + with: + context: ./services/mailhog + tags: crapi/mailhog:${{ env.TAG_LATEST }},crapi/mailhog:${{ env.TAG_NAME }} + platforms: ${{ env.PLATFORMS }} + cache-from: type=gha,scope=mailhog-service + cache-to: type=gha,mode=max,scope=mailhog-service + + - name: Dump docker logs on failure + if: failure() + uses: jwalton/gh-docker-logs@v2 + diff --git a/deploy/docker/.env b/deploy/docker/.env index d263946e..602468f0 100644 --- a/deploy/docker/.env +++ b/deploy/docker/.env @@ -4,5 +4,5 @@ WORKSHOP_SERVER_PORT=8000 ENABLE_SHELL_INJECTION=false ENABLE_LOG4J=false LISTEN_IP="127.0.0.1" -TLS_ENABLED=false +TLS_ENABLED=true VERSION=latest diff --git a/postman_collections/crAPI.postman_environment.json b/postman_collections/crAPI.postman_environment.json index 617c9922..4b6be445 100644 --- a/postman_collections/crAPI.postman_environment.json +++ b/postman_collections/crAPI.postman_environment.json @@ -3,7 +3,7 @@ "name": "Crapi", "values": [{ "key": "url", - "value": "http://127.0.0.1:8888", + "value": "http://127.0.0.1:8889", "enabled": true }, { diff --git a/services/community/Dockerfile b/services/community/Dockerfile index 89b85f8f..d7b6cf8e 100644 --- a/services/community/Dockerfile +++ b/services/community/Dockerfile @@ -12,7 +12,7 @@ # GoLang Build -FROM golang:alpine AS builder +FROM golang:1.21-alpine AS builder ENV GO111MODULE=on \ CGO_ENABLED=0 WORKDIR /build @@ -39,6 +39,6 @@ COPY certs /app/certs COPY health.sh /app/health.sh RUN ls -al /app -ARG SERVER_PORT +ARG SERVER_PORT EXPOSE ${SERVER_PORT} CMD /app/main diff --git a/services/docker-database.yml b/services/docker-database.yml new file mode 100644 index 00000000..8a2cf61e --- /dev/null +++ b/services/docker-database.yml @@ -0,0 +1,50 @@ +# Licensed under the Apache License, Version 2.0 (the “License”); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +services: + + postgresdb: + container_name: postgresdb + image: 'postgres:14' + command: ["postgres", "-c", "max_connections=500"] + environment: + POSTGRES_USER: admin + POSTGRES_PASSWORD: crapisecretpassword + POSTGRES_DB: crapi + ports: + - "127.0.0.1:5432:5432" + healthcheck: + test: [ "CMD-SHELL", "pg_isready" ] + interval: 15s + timeout: 15s + retries: 15 + + mongodb: + container_name: mongodb + image: 'mongo:4.4' + environment: + MONGO_INITDB_ROOT_USERNAME: admin + MONGO_INITDB_ROOT_PASSWORD: crapisecretpassword + ports: + - "127.0.0.1:27017:27017" + healthcheck: + test: echo 'db.runCommand("ping").ok' | mongo mongodb:27017/test --quiet + interval: 15s + timeout: 15s + retries: 15 + start_period: 20s + + + + + + diff --git a/services/workshop/.gitignore b/services/workshop/.gitignore index ff7f2033..f8505c86 100644 --- a/services/workshop/.gitignore +++ b/services/workshop/.gitignore @@ -1,3 +1,5 @@ __pycache__/ *.pyc *.log +.coverage +*.xml diff --git a/services/workshop/Dockerfile b/services/workshop/Dockerfile index fd29593f..3bc59630 100644 --- a/services/workshop/Dockerfile +++ b/services/workshop/Dockerfile @@ -12,11 +12,11 @@ # limitations under the License. -FROM python:3.8-alpine3.15 as build +FROM python:3.8-alpine as build # Not using alpine based on suggestion # https://pythonspeed.com/articles/alpine-docker-python/ -# Python +# Python ENV PYTHONUNBUFFERED=1 RUN apk add --update --no-cache gettext curl py3-pip postgresql-dev RUN apk add --update --no-cache --virtual .build-deps \ @@ -26,7 +26,7 @@ RUN apk add --update --no-cache --virtual .build-deps \ libressl-dev \ musl-dev \ libffi-dev - + ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 RUN mkdir /app @@ -34,7 +34,7 @@ WORKDIR /app COPY ./ /app RUN pip install wheel && pip wheel . --wheel-dir /app/wheels -FROM python:3.8-alpine3.15 +FROM python:3.10-alpine COPY --from=build /app /app WORKDIR /app RUN apk update && apk add --no-cache postgresql-libs curl diff --git a/services/workshop/core/__init__.py b/services/workshop/core/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/services/workshop/core/management/__init__.py b/services/workshop/core/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/services/workshop/core/management/commands/seed_database.py b/services/workshop/core/management/commands/seed_database.py new file mode 100644 index 00000000..597650c1 --- /dev/null +++ b/services/workshop/core/management/commands/seed_database.py @@ -0,0 +1,226 @@ +# +# Licensed under the Apache License, Version 2.0 (the “License”); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +""" +Configuration for crapi application +""" +import django +import sys +from django.apps import AppConfig +import bcrypt +from django.utils import timezone +from django.db import models +from django.db import connection, transaction +import logging +import traceback +from django.core.management.base import BaseCommand +from django.utils import timezone + +logger = logging.getLogger() + + +def create_products(): + from crapi.shop.models import Product + product_details_all = [ + { + 'name': 'Seat', + 'price': 10, + 'image_url': 'images/seat.svg' + }, + { + 'name': 'Wheel', + 'price': 10, + 'image_url': 'images/wheel.svg' + } + ] + for product_details in product_details_all: + if Product.objects.filter(name=product_details['name']).exists(): + logger.info("Product already exists. Skipping: "+ product_details['name']) + continue + product = Product.objects.create( + name=product_details['name'], + price=float(product_details['price']), + image_url=product_details['image_url'] + ) + product.save() + logger.info("Created Product: "+str(product.__dict__)) + +def create_mechanics(): + from crapi.user.models import User, UserDetails + from crapi.mechanic.models import Mechanic + mechanic_details_all = [ + { + 'name': 'Jhon', + 'email': 'jhon@example.com', + 'number': '', + 'password': 'Admin1@#', + 'mechanic_code': 'TRAC_JHN' + }, + { + 'name': 'James', + 'email': 'james@example.com', + 'number': '', + 'password': 'Admin1@#', + 'mechanic_code': 'TRAC_JME' + }, + ] + for mechanic_details in mechanic_details_all: + uset = User.objects.filter(email=mechanic_details['email']) + if not uset.exists(): + try: + cursor = connection.cursor() + cursor.execute("select nextval('user_login_id_seq')") + result = cursor.fetchone() + user_id = result[0] + except Exception as e: + logger.error("Failed to fetch user_login_id_seq"+str(e)) + user_id = 1 + + user = User.objects.create( + id=user_id, + email=mechanic_details['email'], + number=mechanic_details['number'], + password=bcrypt.hashpw( + mechanic_details['password'].encode('utf-8'), + bcrypt.gensalt() + ).decode(), + role=User.ROLE_CHOICES.MECH, + created_on=timezone.now() + ) + user.save() + logger.info("Created User: "+str(user.__dict__)) + else: + user = uset.first() + + if Mechanic.objects.filter(mechanic_code=mechanic_details['mechanic_code']): + logger.info("Mechanic already exists. Skipping: " + + mechanic_details['mechanic_code'] + + " " + mechanic_details['name'] + " " + + mechanic_details['email']) + continue + mechanic = Mechanic.objects.create( + mechanic_code=mechanic_details['mechanic_code'], + user=user + ) + mechanic.save() + try: + cursor = connection.cursor() + cursor.execute("select nextval('user_details_id_seq')") + result = cursor.fetchone() + user_details_id = result[0] + except Exception as e: + logger.error("Failed to fetch user_details_id_seq"+str(e)) + user_details_id = 1 + userdetails = UserDetails.objects.create( + id=user_details_id, + available_credit=0, + name=mechanic_details['name'], + status='ACTIVE', + user=user + ) + userdetails.save() + +def create_reports(): + import random + import sys + import textwrap + from crapi.user.models import User, UserDetails, Vehicle + from crapi.mechanic.models import Mechanic, ServiceRequest + from django.utils import timezone + count = ServiceRequest.objects.all().count() + if (count >= 5): + return + logger.info("Creating Reports") + mechanics = Mechanic.objects.all() + vehicles = Vehicle.objects.all() + for i in range(5): + try: + mechanic = random.choice(mechanics) + vehicle = random.choice(vehicles) + status = random.choice(ServiceRequest.STATUS_CHOICES)[0] + vehicle_model = vehicle.vehicle_model + vehicle_company = vehicle_model.vehiclecompany + user = vehicle.owner + user_detail = UserDetails.objects.filter(user=user).first() + service_request = ServiceRequest.objects.create( + vehicle=vehicle, + mechanic=mechanic, + problem_details=textwrap.dedent("""\ + My car {} - {} is having issues. + Can you give me a call on my mobile {}, + Or send me an email at {} + Thanks, + {}. + """.format( + vehicle_company.name, + vehicle_model.model, + user.number, + user.email, + user_detail.name) + ), + status=status, + created_on=timezone.now() + ) + service_request.save() + logger.info("Created Service Request for User %s: %s", user.email, service_request.__dict__) + except Exception as e: + print(sys.exc_info()[0]) + logger.error("Failed to create report: "+str(e)) + +def create_orders(): + import uuid + from crapi.user.models import User, UserDetails + from crapi.shop.models import Product + from crapi.shop.models import Order + if Order.objects.all().count() >= 1: + return + users = User.objects.filter(role=User.ROLE_CHOICES.PREDEFINED).order_by('id') + for user in users: + product = Product.objects.filter(name='Seat').first() + order = Order.objects.create( + user=user, + product=product, + quantity=2, + created_on=timezone.now(), + transaction_id=uuid.uuid4(), + ) + order.save() + logger.info("Created Order for User %s: %s", user.email, order.__dict__) + + +class Command(BaseCommand): + help = 'Seed the database with initial data.' + + def handle(self, *args, **kwargs): + """ + Pre-populate mechanic model and product model + :return: None + """ + logger.info("Pre Populating Model Data") + try: + create_products() + except Exception as e: + logger.error("Cannot Pre Populate Products: "+str(e)) + try: + create_mechanics() + except Exception as e: + logger.error("Cannot Pre Populate Mechanics: "+str(e)) + try: + create_reports() + except Exception as e: + logger.error("Cannot Pre Populate Reports: "+str(e)) + try: + create_orders() + except Exception as e: + logger.error("Cannot Pre Populate Orders: "+str(e)) diff --git a/services/workshop/crapi/apps.py b/services/workshop/crapi/apps.py index f0534e7b..59b3913f 100644 --- a/services/workshop/crapi/apps.py +++ b/services/workshop/crapi/apps.py @@ -147,8 +147,6 @@ def create_reports(): mechanic = random.choice(mechanics) vehicle = random.choice(vehicles) status = random.choice(ServiceRequest.STATUS_CHOICES)[0] - logger.info(vehicle.__dict__) - logger.info(status) vehicle_model = vehicle.vehicle_model vehicle_company = vehicle_model.vehiclecompany user = vehicle.owner @@ -173,7 +171,7 @@ def create_reports(): created_on=timezone.now() ) service_request.save() - logger.info(service_request.__dict__) + logger.info("Created Service Request for User %s: %s", user.email, service_request.__dict__) except Exception as e: print(sys.exc_info()[0]) logger.error("Failed to create report: "+str(e)) @@ -185,26 +183,18 @@ def create_orders(): from crapi.shop.models import Order if Order.objects.all().count() >= 1: return - user = User.objects.filter(email='test@example.com').first() - product = Product.objects.filter(name='Seat').first() - order1 = Order.objects.create( - user=user, - product=product, - quantity=2, - created_on=timezone.now(), - transaction_id=uuid.uuid4(), - ) - order1.save() - logger.info("Created Order:1: "+str(order1.__dict__)) - order2 = Order.objects.create( - user=user, - product=product, - quantity=2, - created_on=timezone.now(), - transaction_id=uuid.uuid4(), - ) - order2.save() - logger.info("Created Order:2: "+str(order2.__dict__)) + users = User.objects.filter(role=User.ROLE_CHOICES.PREDEFINED).order_by('id') + for user in users: + product = Product.objects.filter(name='Seat').first() + order = Order.objects.create( + user=user, + product=product, + quantity=2, + created_on=timezone.now(), + transaction_id=uuid.uuid4(), + ) + order.save() + logger.info("Created Order for User %s: %s", user.email, order.__dict__) diff --git a/services/workshop/crapi/mechanic/models.py b/services/workshop/crapi/mechanic/models.py index 7d6bf721..09b7bf26 100644 --- a/services/workshop/crapi/mechanic/models.py +++ b/services/workshop/crapi/mechanic/models.py @@ -53,8 +53,8 @@ class ServiceRequest(models.Model): updated_on = models.DateTimeField(null=True) STATUS_CHOICES = Choices( - ('PEN', "Pending", "Pending"), - ('FIN', "Finished", "Finished") + ('PEN', "pending", "Pending"), + ('FIN', "finished", "Finished") ) status = models.CharField(max_length=10, choices=STATUS_CHOICES, default=STATUS_CHOICES.PEN) diff --git a/services/workshop/crapi/user/models.py b/services/workshop/crapi/user/models.py index a903b0aa..c248f4c2 100644 --- a/services/workshop/crapi/user/models.py +++ b/services/workshop/crapi/user/models.py @@ -36,6 +36,7 @@ class User(models.Model): password = models.CharField(max_length=255) ROLE_CHOICES = Choices( + ('PREDEFINED', 0, 'Predefined'), ('USER', 1, 'User'), ('MECH', 2, 'Mechanic'), ('ADMIN', 3, 'Admin'), diff --git a/services/workshop/crapi_site/settings.py b/services/workshop/crapi_site/settings.py index 85026849..627ba7b6 100644 --- a/services/workshop/crapi_site/settings.py +++ b/services/workshop/crapi_site/settings.py @@ -73,8 +73,10 @@ def get_env_value(env_variable): 'corsheaders', 'health_check', 'health_check.db', - 'crapi.apps.CRAPIConfig', - #'user.apps.UserConfig', + 'core', + 'crapi', + # 'crapi.apps.CRAPIConfig', + # 'user.apps.UserConfig', "django_extensions", ] diff --git a/services/workshop/requirements.txt b/services/workshop/requirements.txt index 6662beb2..d4cbb49a 100644 --- a/services/workshop/requirements.txt +++ b/services/workshop/requirements.txt @@ -17,4 +17,6 @@ pymongo==3.13.0 pyOpenSSL==23.1.1 requests==2.30.0 Werkzeug==2.0.3 -Faker==22.1.0 \ No newline at end of file +Faker==22.1.0 +gunicorn==21.2.0 +coverage==7.4.1 \ No newline at end of file diff --git a/services/workshop/runner.sh b/services/workshop/runner.sh index 5725079b..3dc4b9ab 100755 --- a/services/workshop/runner.sh +++ b/services/workshop/runner.sh @@ -24,7 +24,14 @@ python3 manage.py check &&\ python3 manage.py health_check ## Uncomment the following line if you wish to run tests -IS_TESTING=True python3 manage.py test --no-input +if [ "$RUN_TESTS" = "true" ] || [ "$RUN_TESTS" = "1" ]; then + echo "Running tests" + IS_TESTING=True python3 manage.py test --no-input + echo "Tests finished" +fi + +echo "Seeding the database" +python3 manage.py seed_database echo "Starting Django server" if [ "$TLS_ENABLED" = "true" ] || [ "$TLS_ENABLED" = "1" ]; then @@ -38,9 +45,10 @@ if [ "$TLS_ENABLED" = "true" ] || [ "$TLS_ENABLED" = "1" ]; then fi echo "TLS_CERTIFICATE: $TLS_CERTIFICATE" echo "TLS_KEY: $TLS_KEY" - python3 manage.py runserver_plus --cert-file $TLS_CERTIFICATE --key-file $TLS_KEY --noreload 0.0.0.0:${SERVER_PORT} + # python3 manage.py runserver_plus --cert-file $TLS_CERTIFICATE --key-file $TLS_KEY --noreload 0.0.0.0:${SERVER_PORT} + gunicorn --workers=2 --threads=10 --timeout 60 --bind 0.0.0.0:${SERVER_PORT} --certfile $TLS_CERTIFICATE --keyfile $TLS_KEY --log-level=debug crapi_site.wsgi else echo "TLS is DISABLED" - python3 manage.py runserver 0.0.0.0:${SERVER_PORT} --noreload + # python3 manage.py runserver 0.0.0.0:${SERVER_PORT} --noreload + gunicorn --workers=2 --threads=10 --timeout 60 --bind 0.0.0.0:${SERVER_PORT} --log-level=debug crapi_site.wsgi fi -exec "$@" diff --git a/services/workshop/utils/messages.py b/services/workshop/utils/messages.py index 3b3d83fd..6393f961 100644 --- a/services/workshop/utils/messages.py +++ b/services/workshop/utils/messages.py @@ -37,6 +37,7 @@ COUPON_NOT_FOUND = "Coupon not found" RESTRICTED = "You are not allowed to access this resource!" INVALID_STATUS = "The value of 'status' has to be 'delivered','return pending' or 'returned'" +INVALID_SERVICE_REQUEST_STATUS = "The value of 'status' has to be 'Pending' or 'Finished'" REPORT_ID_MISSING = "Please enter the report_id value." INVALID_REPORT_ID = "Please enter a valid report_id value." REPORT_DOES_NOT_EXIST = "The Report does not exist for given report_id." From 6055f127f2d667ed5d6d63d1879841d76b8b2380 Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 14:33:32 +0530 Subject: [PATCH 2/9] Fix tests --- .github/workflows/pr-build.yml | 23 ++++++++++++++++++++--- services/community/.gitignore | 1 + services/identity/.gitignore | 1 + services/workshop/.gitignore | 1 + services/workshop/crapi_site/settings.py | 4 ++++ services/workshop/requirements.txt | 3 ++- 6 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 services/community/.gitignore diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 28fbb989..88dfc877 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -185,6 +185,7 @@ jobs: tests: + needs: build-context runs-on: ubuntu-latest steps: - name: Checkout code @@ -222,10 +223,12 @@ jobs: - name: Run workshop tests run: | cd services/workshop + pip3 install virtualenv virtualenv venv source venv/bin/activate - pip install -r requirements.txt - IS_TESTING=True python3 manage.py test --no-input + pip3 install -r requirements.txt + mkdir -p test-results + IS_TESTING=True python3 manage.py test --no-input --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --output-dir test-results - name: Run workshop coverage run: | @@ -233,4 +236,18 @@ jobs: source venv/bin/activate coverage run ./manage.py test crapi coverage report - coverage xml -o coverage.xml \ No newline at end of file + coverage xml -o coverage.xml + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: | + **/test-results/**/*.xml + + - name: Publish Coverage Report + if: always() + uses: aGallea/tests-coverage-report@v1 + with: + min-coverage-percentage: '50' + fail-under-coverage-percentage: 'false' \ No newline at end of file diff --git a/services/community/.gitignore b/services/community/.gitignore new file mode 100644 index 00000000..51511d1f --- /dev/null +++ b/services/community/.gitignore @@ -0,0 +1 @@ +test-results/ diff --git a/services/identity/.gitignore b/services/identity/.gitignore index 87b17ba0..23090a4e 100644 --- a/services/identity/.gitignore +++ b/services/identity/.gitignore @@ -21,3 +21,4 @@ gradle-app.setting # JDT-specific (Eclipse Java Development Tools) .classpath bin/ +test-results/ diff --git a/services/workshop/.gitignore b/services/workshop/.gitignore index f8505c86..5fa7cefa 100644 --- a/services/workshop/.gitignore +++ b/services/workshop/.gitignore @@ -3,3 +3,4 @@ __pycache__/ *.log .coverage *.xml +test-results/ diff --git a/services/workshop/crapi_site/settings.py b/services/workshop/crapi_site/settings.py index 627ba7b6..d81d19fe 100644 --- a/services/workshop/crapi_site/settings.py +++ b/services/workshop/crapi_site/settings.py @@ -97,6 +97,10 @@ def get_env_value(env_variable): ROOT_URLCONF = 'crapi_site.urls' +TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' + +TEST_OUTPUT_DIR = os.path.join(BASE_DIR, 'test-reports') + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', diff --git a/services/workshop/requirements.txt b/services/workshop/requirements.txt index d4cbb49a..d8b2d67b 100644 --- a/services/workshop/requirements.txt +++ b/services/workshop/requirements.txt @@ -19,4 +19,5 @@ requests==2.30.0 Werkzeug==2.0.3 Faker==22.1.0 gunicorn==21.2.0 -coverage==7.4.1 \ No newline at end of file +coverage==7.4.1 +unittest-xml-reporting==3.2.0 \ No newline at end of file From 611bb750a4f659bcbbb07956a321cb23f285bb0b Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 14:49:41 +0530 Subject: [PATCH 3/9] Fix tests --- .github/workflows/pr-build.yml | 11 +++++++---- services/workshop/runner.sh | 7 ------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 88dfc877..407335fd 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -35,14 +35,14 @@ jobs: PLATFORMS: "linux/amd64,linux/arm64" steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Env seen prerun run: env - name: Get branch name id: branch-name - uses: tj-actions/branch-names@v5.2 + uses: tj-actions/branch-names@@v8 - name: Current branch name run: | @@ -219,6 +219,8 @@ jobs: run: | cd services/community go test -v ./... + mkdir test-results + go test -json > test-results/TestResults.json - name: Run workshop tests run: | @@ -228,13 +230,13 @@ jobs: source venv/bin/activate pip3 install -r requirements.txt mkdir -p test-results - IS_TESTING=True python3 manage.py test --no-input --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --output-dir test-results + IS_TESTING=True python3 manage.py test --no-input --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner - name: Run workshop coverage run: | cd services/workshop source venv/bin/activate - coverage run ./manage.py test crapi + IS_TESTING=True coverage run ./manage.py test --no-input crapi coverage report coverage xml -o coverage.xml @@ -244,6 +246,7 @@ jobs: with: files: | **/test-results/**/*.xml + **/test-results/**/*.json - name: Publish Coverage Report if: always() diff --git a/services/workshop/runner.sh b/services/workshop/runner.sh index 3dc4b9ab..27b85160 100755 --- a/services/workshop/runner.sh +++ b/services/workshop/runner.sh @@ -23,13 +23,6 @@ python3 manage.py migrate python3 manage.py check &&\ python3 manage.py health_check -## Uncomment the following line if you wish to run tests -if [ "$RUN_TESTS" = "true" ] || [ "$RUN_TESTS" = "1" ]; then - echo "Running tests" - IS_TESTING=True python3 manage.py test --no-input - echo "Tests finished" -fi - echo "Seeding the database" python3 manage.py seed_database From 5f292c137e61dabe072e6420936f4376d7f297fa Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 14:51:42 +0530 Subject: [PATCH 4/9] Syntax fix --- .github/workflows/pr-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 407335fd..001048b8 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -42,7 +42,7 @@ jobs: - name: Get branch name id: branch-name - uses: tj-actions/branch-names@@v8 + uses: tj-actions/branch-names@v8 - name: Current branch name run: | From 21b4535cc2dfd5686480a8b727b5ccfcdce7f75a Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 15:14:29 +0530 Subject: [PATCH 5/9] Fix env --- .github/workflows/pr-build.yml | 2 +- .gitignore | 1 + postman_collections/crAPI.postman_environment.json | 2 +- services/workshop/Dockerfile | 3 +-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 001048b8..dd9f069a 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -220,7 +220,7 @@ jobs: cd services/community go test -v ./... mkdir test-results - go test -json > test-results/TestResults.json + go run gotest.tools/gotestsum@latest --format testname --junitfile test-results/unit-tests.xml - name: Run workshop tests run: | diff --git a/.gitignore b/.gitignore index 8552476c..dbc12474 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ deploy/vagrant/*.log deploy/vagrant/.vagrant .secrets .vscode/ +*.local diff --git a/postman_collections/crAPI.postman_environment.json b/postman_collections/crAPI.postman_environment.json index 4b6be445..617c9922 100644 --- a/postman_collections/crAPI.postman_environment.json +++ b/postman_collections/crAPI.postman_environment.json @@ -3,7 +3,7 @@ "name": "Crapi", "values": [{ "key": "url", - "value": "http://127.0.0.1:8889", + "value": "http://127.0.0.1:8888", "enabled": true }, { diff --git a/services/workshop/Dockerfile b/services/workshop/Dockerfile index 3bc59630..17481fc3 100644 --- a/services/workshop/Dockerfile +++ b/services/workshop/Dockerfile @@ -12,7 +12,7 @@ # limitations under the License. -FROM python:3.8-alpine as build +FROM python:3.10-alpine as build # Not using alpine based on suggestion # https://pythonspeed.com/articles/alpine-docker-python/ @@ -23,7 +23,6 @@ RUN apk add --update --no-cache --virtual .build-deps \ python3-dev openssl-dev \ libffi-dev gcc py3-pip \ python3-dev \ - libressl-dev \ musl-dev \ libffi-dev From ff7670f14401f8848658ee11d5fbbc22131cc35e Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 15:18:04 +0530 Subject: [PATCH 6/9] Fix test --- .github/workflows/pr-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index dd9f069a..745233f9 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -230,6 +230,7 @@ jobs: source venv/bin/activate pip3 install -r requirements.txt mkdir -p test-results + source .env IS_TESTING=True python3 manage.py test --no-input --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner - name: Run workshop coverage From d8e35b3f3c0b0e83da83df329e9cc6cdf756fb0a Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 15:23:23 +0530 Subject: [PATCH 7/9] Fix test --- .github/workflows/pr-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 745233f9..d47e60b7 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -237,6 +237,7 @@ jobs: run: | cd services/workshop source venv/bin/activate + source .env IS_TESTING=True coverage run ./manage.py test --no-input crapi coverage report coverage xml -o coverage.xml From 22cb49d9e7377caaeb67d65dff0c8cbe6416bed8 Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 15:50:50 +0530 Subject: [PATCH 8/9] Fix coverage --- .github/workflows/pr-build.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index d47e60b7..b775df38 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -233,6 +233,14 @@ jobs: source .env IS_TESTING=True python3 manage.py test --no-input --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: | + **/test-results/**/*.xml + **/test-results/**/*.json + - name: Run workshop coverage run: | cd services/workshop @@ -242,17 +250,8 @@ jobs: coverage report coverage xml -o coverage.xml - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - files: | - **/test-results/**/*.xml - **/test-results/**/*.json - - - name: Publish Coverage Report - if: always() - uses: aGallea/tests-coverage-report@v1 + - name: Publish Coverage for workshop + uses: orgoro/coverage@v3.1 with: - min-coverage-percentage: '50' - fail-under-coverage-percentage: 'false' \ No newline at end of file + coverageFile: services/workshop/coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From c6f3f8a73c9f66da303de28a38ff4fed672a2720 Mon Sep 17 00:00:00 2001 From: Roshan Piyush Date: Tue, 6 Feb 2024 16:27:02 +0530 Subject: [PATCH 9/9] Fix tests --- .github/workflows/pr-build.yml | 26 +++++++++----------------- .github/workflows/publish.yml | 23 +++++++++++------------ 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index b775df38..c85332fe 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -77,13 +77,13 @@ jobs: # setup Docker build action - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Set up QEMU id: qemu - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Build crapi-identity image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/identity tags: crapi/crapi-identity:${{ env.TAG_LATEST }},crapi/crapi-identity:${{ env.TAG_NAME }} @@ -94,7 +94,7 @@ jobs: cache-to: type=gha,mode=max,scope=identity-service - name: Build crapi-workshop image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/workshop tags: crapi/crapi-workshop:${{ env.TAG_LATEST }},crapi/crapi-workshop:${{ env.TAG_NAME }} @@ -105,7 +105,7 @@ jobs: cache-to: type=gha,mode=max,scope=workshop-service - name: Build crapi-community image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/community tags: crapi/crapi-community:${{ env.TAG_LATEST }},crapi/crapi-community:${{ env.TAG_NAME }} @@ -116,7 +116,7 @@ jobs: cache-to: type=gha,mode=max,scope=community-service - name: Build crapi-web image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/web tags: crapi/crapi-web:${{ env.TAG_LATEST }},crapi/crapi-web:${{ env.TAG_NAME }} @@ -127,7 +127,7 @@ jobs: cache-to: type=gha,mode=max,scope=web-service - name: Build gateway-service image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/gateway-service tags: crapi/gateway-service:${{ env.TAG_LATEST }},crapi/gateway-service:${{ env.TAG_NAME }} @@ -137,16 +137,8 @@ jobs: cache-from: type=gha,scope=gateway-service cache-to: type=gha,mode=max,scope=gateway-service - - - name: Check Mailhog existence - id: check_mailhog_exists - uses: andstor/file-existence-action@v1 - with: - files: "./services/mailhog" - - name: Build mailhog image - if: steps.check_mailhog_exists.outputs.files_exists == 'true' - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/mailhog tags: crapi/mailhog:${{ env.TAG_LATEST }},crapi/mailhog:${{ env.TAG_NAME }} @@ -168,7 +160,7 @@ jobs: - name: Install Node uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 20 - name: Install newman run: npm install -g newman diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d3dd4be7..2f6a266b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,14 +29,14 @@ jobs: PLATFORMS: "linux/amd64,linux/arm64" steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Env seen prerun run: env - name: Get branch name id: branch-name - uses: tj-actions/branch-names@v5.2 + uses: tj-actions/branch-names@v8 - name: Current branch name run: | @@ -71,19 +71,19 @@ jobs: # setup Docker build action - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Set up QEMU id: qemu - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build crapi-identity all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/identity tags: crapi/crapi-identity:${{ env.TAG_LATEST }},crapi/crapi-identity:${{ env.TAG_NAME }} @@ -92,7 +92,7 @@ jobs: cache-to: type=gha,mode=max,scope=identity-service - name: Build crapi-workshop all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/workshop tags: crapi/crapi-workshop:${{ env.TAG_LATEST }},crapi/crapi-workshop:${{ env.TAG_NAME }} @@ -101,7 +101,7 @@ jobs: cache-to: type=gha,mode=max,scope=workshop-service - name: Build crapi-community all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/community tags: crapi/crapi-community:${{ env.TAG_LATEST }},crapi/crapi-community:${{ env.TAG_NAME }} @@ -110,7 +110,7 @@ jobs: cache-to: type=gha,mode=max,scope=community-service - name: Build crapi-web all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/web tags: crapi/crapi-web:${{ env.TAG_LATEST }},crapi/crapi-web:${{ env.TAG_NAME }} @@ -119,7 +119,7 @@ jobs: cache-to: type=gha,mode=max,scope=web-service - name: Build gateway-service all platforms and conditionally push to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/gateway-service tags: crapi/gateway-service:${{ env.TAG_LATEST }},crapi/gateway-service:${{ env.TAG_NAME }} @@ -128,8 +128,7 @@ jobs: cache-to: type=gha,mode=max,scope=gateway-service - name: Build mailhog all platforms and conditionally push to Docker Hub - if: steps.check_mailhog_exists.outputs.files_exists == 'true' - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./services/mailhog tags: crapi/mailhog:${{ env.TAG_LATEST }},crapi/mailhog:${{ env.TAG_NAME }}