Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 63 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Backend CI

on:
push:
branches:
- main
paths:
- 'backend/**'
- '.github/workflows/backend-ci.yml'
pull_request:
branches:
- main
paths:
- 'backend/**'
workflow_dispatch:

jobs:
lint-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install common dependencies
run: |
cd backend/cab_common
pip install -r requirements.txt
pip install pytest pytest-cov flake8 black

- name: Run linting
run: |
flake8 backend --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 backend --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Run tests with coverage
run: |
cd backend
pytest --cov=. --cov-report=xml --cov-report=html -v

- name: Upload coverage reports
uses: codecov/codecov-action@v3
with:
files: ./backend/coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
60 changes: 60 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Code Quality

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'

- name: Upload Trivy results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'

dependency-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install safety
run: pip install safety

- name: Check Python dependencies for vulnerabilities
run: |
for req_file in $(find . -name "requirements.txt"); do
echo "Checking $req_file..."
safety check --file "$req_file" || true
done

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Run npm audit
working-directory: frontend
run: npm audit --audit-level=moderate || true
76 changes: 76 additions & 0 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and Push Docker Images

on:
push:
tags:
- 'v*'
workflow_dispatch:

env:
DOCKERHUB_ORGANIZATION: irtsystemx
REGISTRY: docker.io

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

strategy:
matrix:
include:
- service: cab-capitalization
dockerfile: backend/Capitalization-Service-Dockerfile
context: backend
- service: cab-context
dockerfile: backend/Context-Service-Dockerfile
context: backend
- service: cab-event
dockerfile: backend/Event-Service-Dockerfile
context: backend
- service: cab-historic
dockerfile: backend/Historic-Service-Dockerfile
context: backend
- service: cab-recommendation
dockerfile: backend/Recommendation-Service-Dockerfile
context: backend
- service: cab-common
dockerfile: backend/cab_common/Dockerfile
context: backend/cab_common
- service: cab-standalone-frontend
dockerfile: frontend/Dockerfile
context: frontend

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.DOCKERHUB_ORGANIZATION }}/interactiveai-${{ matrix.service }}
tags: |
type=semver,pattern={{version}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
48 changes: 48 additions & 0 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Frontend CI

on:
push:
branches:
- main
paths:
- 'frontend/**'
- '.github/workflows/frontend-ci.yml'
pull_request:
branches:
- main
paths:
- 'frontend/**'
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run linting
run: npm run lint --if-present

- name: Build project
run: npm run build

- name: Run tests
run: npm run test:unit --if-present

- name: Run E2E tests
run: npm run test:e2e --if-present
Loading
Loading