Skip to content

Commit 6ad0d09

Browse files
Merge pull request #45 from AET-DevOps25/feature/add-cicd-to-build-and-push-docker-images-via-github-actions
Feature/add cicd to build and push docker images via GitHub actions
2 parents 3d72a4e + f229d02 commit 6ad0d09

30 files changed

+1546
-193
lines changed

.env.example

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1+
# ==================================
2+
# 🌐 Docker Container configurations
3+
# ==================================
4+
5+
MONGODB_CONTAINER_NAME=skill-forge-mongo-db-test
6+
CLIENT_CONTAINER_NAME=skill-forge-client-test
7+
SERVER_CONTAINER_NAME=skill-forge-server-test
8+
GENAI_CONTAINER_NAME=skill-forge-genai-test
9+
WEAVIATE_CONTAINER_NAME=skill-forge-weaviate-test
10+
11+
112
# ===============================
2-
# 🛢 MongoDB Configuration
13+
# 🌐 Server Configuration
314
# ===============================
15+
SPRING_PROFILE_ACTIVES=docker
16+
17+
# Gateway
18+
SERVER_PORT_GATEWAY=8080
19+
20+
# User Service
21+
SERVER_PORT_USER=8081
422
MONGODB_EXPOSED_PORT=27018
5-
MONGODB_DATABASE=skill_forge
23+
MONGODB_DATABASE=skill_forge-test
624
MONGODB_USERNAME=skill_forge_admin
7-
MONGODB_PASSWORD=12345azerty123
8-
# ===============================
9-
# 🌐 Server Configuration
10-
# ===============================
11-
SERVER_APP_NAME=skill-forge-server
12-
SPRING_PROFILES_ACTIVE=prod
13-
SERVER_PORT=8080
14-
JWT_SECRET=<GENERATE_YOUR_OWN_SECRET>
15-
JWT_EXPIRATION_MS=864000000
25+
MONGODB_PASSWORD=password123!
1626

17-
# ==================================
18-
# 🌐 Docker Container configurations
19-
# ==================================
20-
MONGODB_CONTAINER_NAME=skill-forge-mongo-db
21-
CLIENT_CONTAINER_NAME=skill-forge-client
22-
SERVER_CONTAINER_NAME=skill-forge-server
23-
GENAI_CONTAINER_NAME=skill-forge-genai
27+
# Course Service
28+
SERVER_PORT_COURSES=8082
29+
30+
# JWT Configuration
31+
JWT_SECRET=<your_jwt_secret_here>
32+
JWT_EXPIRATION_MS=864000000
2433

2534
# ===============================
2635
# ☕️ Client Configuration
@@ -30,17 +39,17 @@ VITE_APP_NAME=SkillForge.ai
3039
VITE_APP_VERSION=1.0-alpha
3140
VITE_API_BASE_URL=/api/
3241
VITE_API_VERSION=v1
33-
BUILD_MODE=production
42+
BUILD_MODE=test
3443

3544
# ===============================
3645
# 🐘 Weaviate Configuration
3746
# ===============================
38-
WEAVIATE_HOST=weaviate-db
47+
WEAVIATE_HOST=weaviate-db-test
3948
WEAVIATE_EXPOSED_HTTP_PORT=1234
4049
WEAVIATE_EXPOSED_GRPC_PORT=50051
4150

4251
# ===============================
4352
# 🧠 GenAi Configuration
4453
# ===============================
45-
GEMAI_APP_NAME=skill-forge-genai
46-
GEMAI_PORT=8081
54+
GEMAI_APP_NAME=skill-forge-genai-test
55+
GEMAI_PORT=8088
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build and Test Client
2+
3+
on:
4+
push:
5+
paths:
6+
- 'client/**'
7+
pull_request:
8+
branches: [main]
9+
paths:
10+
- 'client/**'
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build-and-test-client:
18+
name: Build & Test Client
19+
runs-on: ubuntu-latest
20+
21+
defaults:
22+
run:
23+
working-directory: client
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '22'
32+
33+
- name: Cache node_modules
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.npm
37+
key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
38+
restore-keys: |
39+
npm-${{ runner.os }}-
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
44+
- name: Lint code
45+
run: npm run lint
46+
continue-on-error: true
47+
48+
- name: Run tests if test files exist (.test.* or in __tests__ directories)
49+
run: |
50+
# Only look in directories that exist to avoid find errors
51+
paths=""
52+
[ -d src ] && paths="$paths src"
53+
[ -d test ] && paths="$paths test"
54+
55+
if [ -n "$paths" ]; then
56+
test_files=$(find $paths -type f \( -name "*.test.js" -o -name "*.test.jsx" -o -name "*.test.ts" -o -name "*.test.tsx" -o -path "*/__tests__/*" \) 2>/dev/null)
57+
if [ -n "$test_files" ]; then
58+
echo "Test files found:"
59+
echo "$test_files"
60+
npm run test
61+
else
62+
echo "No test files found (no *.test.* or __tests__/*). Skipping tests."
63+
fi
64+
else
65+
echo "No test or src directories found, skipping tests."
66+
fi
67+
68+
- name: Build client
69+
run: npm run build
70+
env:
71+
VITE_APP_NAME: SkillForge.ai
72+
VITE_APP_VERSION: 1.0-test
73+
VITE_API_BASE_URL: /api/
74+
VITE_API_VERSION: v1
75+
BUILD_MODE: production
76+
DOCKERIZED: 1
77+
78+
- name: Verify build output
79+
run: |
80+
if [ -d "dist" ] && [ "$(ls -A dist)" ]; then
81+
echo "Build output found - Build and Test Client workflow completed successfully."
82+
else
83+
echo "No build output found - Build and Test Client workflow failed."
84+
exit 1
85+
fi
86+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build, Lint & Test the GenAI Service
2+
3+
on:
4+
push:
5+
paths:
6+
- 'genai/**'
7+
pull_request:
8+
paths:
9+
- 'genai/**'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build-lint-test-genai:
17+
name: Build, Lint & Test GenAI Service
18+
runs-on: ubuntu-latest
19+
20+
defaults:
21+
run:
22+
working-directory: .
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.12'
32+
33+
- name: Cache pip
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.cache/pip
37+
key: ${{ runner.os }}-pip-${{ hashFiles('genai/requirements.txt') }}
38+
restore-keys: |
39+
${{ runner.os }}-pip-
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install -r genai/requirements.txt
45+
46+
- name: Lint code with flake8
47+
run: |
48+
pip install flake8
49+
flake8 genai/src --count --select=E9,F63,F7,F82 --show-source --statistics
50+
continue-on-error: true
51+
52+
- name: Run tests if test files exist
53+
run: |
54+
if ls genai/tests/*.py 1> /dev/null 2>&1; then
55+
echo "Found test files. Running tests..."
56+
pip install pytest
57+
pytest genai/tests
58+
else
59+
echo "No test files found. Skipping tests."
60+
fi
61+
62+
- name: Verify main entrypoint exists
63+
run: |
64+
if [ -f "genai/src/main.py" ]; then
65+
echo "main.py exists."
66+
else
67+
echo "genai/src/main.py does not exist! Build failed."
68+
exit 1
69+
fi
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build and Test Server
2+
3+
on:
4+
push:
5+
paths:
6+
- 'server/skillforge-gateway/**'
7+
- 'server/skillforge-user/**'
8+
pull_request:
9+
branches: [main]
10+
paths:
11+
- 'server/skillforge-gateway/**'
12+
- 'server/skillforge-user/**'
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
test-gateway:
20+
name: Build & Test Gateway
21+
runs-on: ubuntu-latest
22+
defaults:
23+
run:
24+
working-directory: server/skillforge-gateway
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Set up JDK 21
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: '21'
31+
distribution: 'temurin'
32+
cache: 'gradle'
33+
- name: Build and test
34+
run: ./gradlew build --no-daemon
35+
36+
test-user-service:
37+
name: Build & Test User Service
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: server/skillforge-user
42+
steps:
43+
- uses: actions/checkout@v4
44+
- name: Set up JDK 21
45+
uses: actions/setup-java@v4
46+
with:
47+
java-version: '21'
48+
distribution: 'temurin'
49+
cache: 'gradle'
50+
- name: Build and test
51+
run: ./gradlew build --no-daemon

0 commit comments

Comments
 (0)