Skip to content

Test/d4 unittest

Test/d4 unittest #506

Workflow file for this run

name: CI workflow
on:
push:
branches: ['**']
pull_request:
branches: ['**']
types: [opened, synchronize, reopened]
jobs:
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: getactive
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize database
run: |
mysql -h127.0.0.1 -P3306 -uroot -ppassword getactive < ./code/database/01-init.sql
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run backend tests
working-directory: ./code/backend/getactivecore
run: |
./gradlew test
# env:
# SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/getactive
# SPRING_DATASOURCE_USERNAME: root
# SPRING_DATASOURCE_PASSWORD: password
- name: Upload Problems Report
uses: actions/upload-artifact@v4
if: always()
with:
name: problems-report
path: code/backend/getactivecore/build/reports/tests/test/
- name: Build and start backend service
working-directory: ./code/backend/getactivecore
run: |
./gradlew build -x test
nohup java -jar build/libs/getactivecore-0.0.1-SNAPSHOT.jar \
> backend.log 2>&1 &
echo "Waiting for backend service to start..."
for i in {1..30}; do
if curl -s http://localhost:3232/v1/health | grep -q "UP"; then
echo "Backend service is up!"
break
fi
if [ $i -eq 30 ]; then
echo "Backend service failed to start within timeout"
cat backend.log
exit 1
fi
echo "Waiting... ($i/30)"
sleep 2
done
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: './code/frontend/package-lock.json'
- name: Install frontend dependencies
working-directory: ./code/frontend/
run: npm ci
- name: Lint frontend code
working-directory: ./code/frontend/
run: npm run lint
- name: Run frontend unit tests
working-directory: ./code/frontend/
run: npm run test
- name: Run Cypress E2E tests
uses: cypress-io/github-action@v6
with:
working-directory: ./code/frontend
start: npm run dev
wait-on: 'http://localhost:5173'
wait-on-timeout: 120
browser: chrome
- name: Upload Cypress Test Artifacts (Videos & Screenshots)
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-e2e-artifacts
path: |
./code/frontend/cypress/videos
./code/frontend/cypress/screenshots
./code/frontend/cypress/reports/junit.xml
- name: Upload Frontend JUnit Report
uses: actions/upload-artifact@v4
if: always()
with:
name: frontend-junit-report
path: code/frontend/test-results/junit.xml
# - name: Upload Frontend Coverage Report
# uses: actions/upload-artifact@v4
# if: always()
# with:
# name: frontend-coverage-report
# path: code/frontend/coverage/