Skip to content

Commit

Permalink
Merge pull request #30 from ahmedyoussefg/devel
Browse files Browse the repository at this point in the history
Merge Milestone 1 Features into Main
  • Loading branch information
MoustafaAmer12 authored Dec 17, 2024
2 parents d531f7e + d0f7dc6 commit 1845473
Show file tree
Hide file tree
Showing 146 changed files with 22,756 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: PR Quality Check
# This workflow is responsible for checking the quality of PRs for the backend.
# It runs tests, ensures code coverage, and uploads a report for review.

on:
pull_request:
branches:
- '*'

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
POSTGRES_USER: ${{ secrets.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }}
POSTGRES_DB: knowtopia_dev

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

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Wait for PostgreSQL
run: |
for i in {1..10}; do
if pg_isready -h localhost -p 5432 -U ${{ secrets.DB_USERNAME }}; then
echo "PostgreSQL is ready!"
break
fi
echo "Waiting for PostgreSQL to be ready..."
sleep 5
done
- name: Run tests
env:
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: mvn clean verify
working-directory: backend

- name: Upload Report
uses: 'actions/upload-artifact@v4'
with:
name: jacoco-report
path: ${{ github.workspace }}/backend/target/site/jacoco/*

- name: Add coverage to PR
if: github.event_name == 'pull_request'
id: jacoco
uses: madrapps/[email protected]
with:
paths: ${{ github.workspace }}/backend/target/site/jacoco/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 60
min-coverage-changed-files: 60
title: Code Coverage Summary
update-comment: true

- name: Fail PR if overall coverage is less than 60%
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const coverage = parseFloat('${{ steps.jacoco.outputs.coverage-overall }}');
console.log('Overall coverage is:', coverage);
if (coverage < 60.0) {
core.setFailed('Overall coverage is less than 60%!');
}
78 changes: 78 additions & 0 deletions .github/workflows/push-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Push Quality Check

on:
push:
branches:
- main
- devel
workflow_dispatch: # This allows the workflow to be triggered manually too

jobs:
build-jar:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
POSTGRES_USER: ${{ secrets.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }}
POSTGRES_DB: knowtopia_dev

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

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Wait for PostgreSQL
run: |
for i in {1..10}; do
if pg_isready -h localhost -p 5432 -U ${{ secrets.DB_USERNAME }}; then
echo "PostgreSQL is ready!"
break
fi
echo "Waiting for PostgreSQL to be ready..."
sleep 5
done
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
env:
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: mvn clean install
working-directory: backend

- name: Build JAR (skip tests)
env:
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: mvn clean package -DskipTests
working-directory: backend

- name: Upload JAR
uses: actions/upload-artifact@v4
with:
name: built-jar
path: target/*.jar
working-directory: backend
54 changes: 54 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.DS_Store
frontend/node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?


######## JAVA ########

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

env.properties
backend/target
Loading

0 comments on commit 1845473

Please sign in to comment.