-
Notifications
You must be signed in to change notification settings - Fork 3
116 lines (99 loc) · 3.07 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Integration Test
on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]
workflow_dispatch:
permissions:
contents: read
jobs:
# Backend (Spring Boot using Gradle) Tests
backend-test:
name: Backend (Spring Boot) Test
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
env:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: NLP_db
MYSQL_USER: NLP_user
MYSQL_PASSWORD: NLP_password
steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v3
# Set permissions for the Gradle wrapper
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
# Set up Java (for Spring Boot)
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
# Cache Gradle dependencies to speed up builds
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle
# Run Spring Boot tests using Gradle
- name: Run Spring Boot tests
working-directory: ./ # Set the correct project directory if needed
env:
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/NLP_db
SPRING_DATASOURCE_USERNAME: NLP_user
SPRING_DATASOURCE_PASSWORD: NLP_password
run: ./gradlew test
# Frontend (Next.js) Tests and Build
frontend-test:
name: Frontend (Next.js) Test
runs-on: ubuntu-latest
steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v3
# Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
# Cache yarn dependencies
- name: Cache yarn dependencies
uses: actions/cache@v3
with:
path: src/main/frontend/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('src/main/frontend/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
# Install frontend dependencies
- name: Install dependencies
working-directory: src/main/frontend
run: yarn install
# Build Next.js project
- name: Build Next.js project
working-directory: src/main/frontend
run: yarn build
# Run ESLint lint checks
- name: Run ESLint linter
working-directory: src/main/frontend
run: yarn lint
# Combine the results
combine-results:
name: Combine Backend and Frontend Results
runs-on: ubuntu-latest
needs: [ backend-test, frontend-test ]
steps:
- name: Check backend and frontend test results
run: echo "Both backend and frontend tests passed successfully!"