Skip to content

Commit

Permalink
ci: add test pipeline for GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyes64 committed Jul 28, 2024
1 parent d3e2250 commit a473f5a
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 3 deletions.
136 changes: 136 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Test Pipeline

on: [push, pull_request]

jobs:
test-cab_common:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: |
cd backend/cab_common
export PYTHONPATH=.
pip install -r requirements.txt
- name: Run tests
run: |
cd backend/cab_common
pytest tests --cov --cov-report term --cov-report html --cov-report xml:coverage.xml --junitxml=report.xml
env:
COV_CONTEXT: "backend/cab_common"

test-event-service:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install backend/cab_common
cd backend/event-service
pip install -r requirements.txt
- name: Run tests
run: |
cd backend/event-service
export PYTHONPATH=.
export FLASK_APP=web
pytest tests --cov --cov-report term --cov-report html --cov-report xml:coverage.xml --junitxml=report.xml
env:
COV_CONTEXT: "backend/event-service"

test-context-service:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install backend/cab_common
cd backend/context-service
pip install -r requirements.txt
pip install pytest-cov==4.1.0 pytest-mock==3.12.0 pytest-runner==6.0.1
- name: Run tests
run: |
cd backend/context-service
export PYTHONPATH=.
export FLASK_APP=web
pytest tests --cov --cov-report term --cov-report html --cov-report xml:coverage.xml --junitxml=report.xml
env:
COV_CONTEXT: "backend/context-service"

test-recommendation-service:
runs-on: ubuntu-latest
container: python:3.11.6-slim
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up dependencies
run: |
mkdir -p /usr/share/man/man1
apt update && apt install -y --no-install-recommends default-jre
pip install backend/cab_common
- name: Set up recommendation service
run: |
cd backend/recommendation-service
pip install -r requirements.txt
pip install pytest-cov==4.1.0 pytest-mock==3.12.0 pytest-runner==6.0.1
- name: Run tests
run: |
cd backend/recommendation-service
export PYTHONPATH=.
export FLASK_APP=web
pytest tests --cov --cov-report term --cov-report html --cov-report xml:coverage.xml --junitxml=report.xml
env:
COV_CONTEXT: "backend/recommendation-service"

test-frontend-service:
runs-on: ubuntu-latest
container: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install dependencies
run: |
cd frontend
npm ci
- name: Lint code
run: |
cd frontend
npm run lint
- name: Type-check code
run: |
cd frontend
npm run type-check
- name: Build project
run: |
cd frontend
npm run build-only
- name: Run tests
run: |
cd frontend
npm run test:coverage
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v3
with:
name: frontend-coverage
path: frontend/coverage
env:
COV_CONTEXT: "frontend"
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"type": "module",
"scripts": {
"dev": "vite",
"dev:": "vite --mode",
"dev:mode": "vite --mode",
"build": "run-p type-check \"build-only {@}\" --",
"build:": "vite build --mode",
"build:mode": "vite build --mode",
"preview": "vite preview",
"test": "run-p 'test:unit -- run' test:e2e",
"test:coverage": "run-p test:unit:coverage test:e2e:coverage",
"test:unit": "vitest",
"test:unit:coverage": "vitest run --coverage",
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e' --timeout 1000000",
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
"test:e2e:coverage": "npm run test:e2e && nyc report --reporter=text-summary --lines 0",
"build-only": "vite build",
Expand Down

0 comments on commit a473f5a

Please sign in to comment.