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
2 changes: 1 addition & 1 deletion .github/workflows/basic-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Run Client Unit Tests with Coverage
working-directory: frontend
run: npm run test:coverage
run: npm run test:unit-coverage

# Backend steps

Expand Down
140 changes: 123 additions & 17 deletions .github/workflows/complete-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,25 @@ jobs:
run:
working-directory: backend/pcmod

services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: pcmod
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 25
uses: actions/setup-java@v4
Expand All @@ -30,25 +46,45 @@ jobs:
distribution: 'temurin'
cache: 'maven'

- name: Server Unit Tests (Services + Mocks)
run: ./mvnw test -Dgroups="server-unit"

- name: Server Integration Tests (Services + Testcontainers)
run: ./mvnw test -Dgroups="server-integration"
- name: Server Tests (JUnit, Testcontainers, Rest Assured)
env:
DB_URL: jdbc:mysql://localhost:3306/pcmod
DB_USERNAME: root
DB_PASSWORD: password
run: ./mvnw verify '-Dtest=!es.codeurjcstudents.pcmod.e2e.ui.**'

- name: Server System Tests (API REST with Rest Assured)
run: ./mvnw test -Dgroups="server-system"
- name: Save JaCoCo Report
uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: backend/pcmod/target/site/jacoco/jacoco.xml

client-tests:
name: Frontend Unit Tests (Virtual DOM / Vitest)
name: Frontend Unit and Integration Tests (Virtual DOM / Vitest)
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: pcmod
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
Expand All @@ -60,17 +96,59 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Client Unit Tests (Components + Virtual DOM)
run: npm run test:unit
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
cache: 'maven'

- name: Run backend and Client Unit and Integration Tests (Virtual DOM / Vitest)
env:
HEADLESS_TESTS: "true"
NODE_TLS_REJECT_UNAUTHORIZED: "0"
DB_URL: jdbc:mysql://localhost:3306/pcmod
DB_USERNAME: root
DB_PASSWORD: password
run: |
cd ../backend/pcmod
./mvnw spring-boot:run > /dev/null 2>&1 < /dev/null &

npx wait-on https-get://localhost:8443/api/v1/components/

cd ../../frontend
npm run test:coverage

- name: Save LCOV Report
uses: actions/upload-artifact@v4
with:
name: lcov-report
path: frontend/coverage/lcov.info

client-server-integration-tests:
name: E2E & Integration (Chrome + Selenium)
client-server-tests:
name: E2E Client-Server Tests (Chrome + Selenium)
runs-on: ubuntu-latest
needs: [server-tests, client-tests]

services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: pcmod
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 25
uses: actions/setup-java@v4
Expand All @@ -86,22 +164,50 @@ jobs:
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install dependencies
run: npm ci
working-directory: frontend

- name: Set up Chrome for Selenium
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable

- name: Prepare and Launch Full Environment
- name: E2E Client-Server Tests (Selenium)
env:
HEADLESS_TESTS: "true"
NODE_TLS_REJECT_UNAUTHORIZED: "0"
DB_URL: jdbc:mysql://localhost:3306/pcmod
DB_USERNAME: root
DB_PASSWORD: password
run: |
cd frontend
npm run dev &
npm run dev > /dev/null 2>&1 < /dev/null &

cd ../backend/pcmod
./mvnw spring-boot:run &
./mvnw spring-boot:run > /dev/null 2>&1 < /dev/null &

npx wait-on http-get://localhost:5173 https-get://localhost:8443/
npx wait-on http-get://localhost:5173 https-get://localhost:8443/api/v1/components/

./mvnw test -Dgroups="client-server-integration,client-system"
./mvnw test -Dgroups="client-system"

# SonarCloud Analysis
- name: Download JaCoCo Report
uses: actions/download-artifact@v4
with:
name: jacoco-report
path: backend/pcmod/target/site/jacoco

- name: Download LCOV Report
uses: actions/download-artifact@v4
with:
name: lcov-report
path: frontend/coverage

- name: SonarCloud Analysis
uses: sonarsource/sonarcloud-github-action@v3.1.0
with:
projectBaseDir: .
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions backend/pcmod/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ server.ssl.key-store-password=password
server.ssl.key-password=secret
server.ssl.key-alias=selfsigned

spring.datasource.url=${DB_URL}
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}
spring.jpa.hibernate.ddl-auto=${DB_MODE}
spring.datasource.url=${DB_URL:jdbc:mysql://localhost:3306/pcmod}
spring.datasource.username=${DB_USERNAME:root}
spring.datasource.password=${DB_PASSWORD:password}
spring.jpa.hibernate.ddl-auto=${DB_MODE:create-drop}

spring.servlet.encoding.charset=UTF-8
spring.servlet.encoding.enabled=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

Expand All @@ -24,7 +25,15 @@ public class ComponentsSystemTests {

@BeforeEach
public void setupTest() {
driver = new ChromeDriver();
ChromeOptions options = new ChromeOptions();
options.addArguments("--incognito");
options.addArguments("--disable-notifications");
options.addArguments("--disable-features=PasswordLeakDetection");
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");

driver = new ChromeDriver(options);
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}

Expand Down
5 changes: 2 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"start": "react-router-serve ./build/server/index.js",
"typecheck": "react-router typegen && tsc",
"test": "vitest",
"test:unit": "vitest run tests/unit",
"test:integration": "vitest run tests/integration",
"test:coverage": "vitest run tests/unit --coverage"
"test:unit-coverage": "vitest run tests/unit --coverage",
"test:coverage": "vitest run tests/ --coverage"
},
"dependencies": {
"@react-router/node": "8.0.0",
Expand Down
Loading