Skip to content

Commit

Permalink
Merge pull request #29 from xenosf/testing-ci
Browse files Browse the repository at this point in the history
Add CI workflows (testing & linting)
  • Loading branch information
xenosf authored Nov 6, 2024
2 parents c8763f8 + 10bcf03 commit f9364c5
Show file tree
Hide file tree
Showing 41 changed files with 25,919 additions and 2,063 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/client-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Automated Testing (Client)

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
client:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./client
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_REACT_APP_API_BASE_URL: http://localhost
directory: .
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Install Client Dependencies
run: npm ci
- name: Run Tests
run: npm run test
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Static Analysis

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Client Dependencies
run: |
cd client
npm ci
cd ..
- name: Install Server Dependencies
run: |
cd server
npm ci
cd ..
- name: Install Outer Folder Dependencies
run: |
npm ci
- name: Run Lint Checks (eslint)
run: npx eslint .
159 changes: 159 additions & 0 deletions .github/workflows/server-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Automated Testing (Server)

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
matching-service:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./server/matching-service
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_ENV: PROD
envkey_PORT_MATCHING: 3003
directory: .
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Install Matching Service Dependencies
run: npm ci
- name: Run Tests
run: npm run test
question-service:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./server/question-service
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_ENV: PROD
envkey_PORT_QUESTION: 3002
envkey_DB_URI_QUESTION: mongodb://localhost:27017/question
directory: .
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Install Question Service Dependencies
run: npm ci
- name: Run Tests
run: npm run test
user-service:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./server/user-service
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_ENV: PROD
envkey_PORT_USER: 3001
envkey_DB_URI_USER: mongodb://localhost:27017/user
envkey_JWT_SECRET: secret
directory: .
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Install User Service Dependencies
run: npm ci
- name: Run Tests
run: npm run test
collaboration-service:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./server/collaboration-service
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_ENV: PROD
envkey_PORT_COLLABORATION: 3004
directory: .
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Install Collaboration Service Dependencies
run: npm ci
- name: Run Tests
run: npm run test
ai-service:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./server/ai-service
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_ENV: PROD
envkey_PORT_AI: 3005
envkey_GEMINI_API_KEY: ''
directory: .
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Install AI Service Dependencies
run: npm ci
- name: Run Tests
run: npm run test
72 changes: 72 additions & 0 deletions .github/workflows/system-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: System Testing

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
system:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
browser: [firefox, chrome]
runs-on: ${{ matrix.os }}
env:
BROWSER: ${{ matrix.browser }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Outer Folder Dependencies
run: |
npm ci
- name: Make client envfile
uses: SpicyPizza/[email protected]
with:
envkey_REACT_APP_API_BASE_URL: http://localhost
directory: client
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Make server envfile
uses: SpicyPizza/[email protected]
with:
envkey_ENV: PROD
envkey_PORT_USER: 3001
envkey_PORT_QUESTION: 3002
envkey_PORT_MATCHING: 3003
envkey_PORT_COLLABORATION: 3004
envkey_PORT_AI: 3005
envkey_GEMINI_API_KEY: ''
envkey_DB_URI_QUESTION: mongodb://localhost:27017/question
envkey_DB_URI_USER: mongodb://localhost:27017/user
envkey_JWT_SECRET: secret
directory: server
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: latest
- name: Setup & run server
run: |
cd server
docker compose -f docker-compose.local.yml build
docker compose -f docker-compose.local.yml up -d
- name: Setup & run client
run: |
cd client
npm ci
npm run start &
- name: Run Tests
run: |
sleep 60
xvfb-run --server-args="-screen 0 1024x768x24" npm run test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ node_modules
**/.env
**/.DS_Store
server/matching-service/dump.rdb
server/matching-service/dist
**/dist
2 changes: 1 addition & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Container } from "@mui/material";
import React from "react";
// import React from "react";
import { Outlet } from "react-router-dom";
import "./App.css";
import Header from "./components/Header/Header";
Expand Down
17 changes: 11 additions & 6 deletions client/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { render, screen } from '@testing-library/react';
import App from './App';
import { render, screen } from "@testing-library/react";
import App from "./App";
import { BrowserRouter } from "react-router-dom";

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
test('renders "PeerPrep" text (in toolbar)', () => {
render(
<BrowserRouter>
<App />
</BrowserRouter>
);
const peerprep = screen.getByText(/PeerPrep/i);
expect(peerprep).toBeInTheDocument();
});
4 changes: 2 additions & 2 deletions client/src/components/AddQuestion/AddQuestionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Typography,
} from "@mui/material";
import axios from "axios";
import React, { useState } from "react";
import { useState } from "react";
import { SVC_ENDPOINTS } from "../../consts/api";

function AddQuestionForm(props) {
Expand Down Expand Up @@ -80,7 +80,7 @@ function AddQuestionForm(props) {
{newQuestion ? (
<div>
<Typography align="center" color="secondary">
Successfully submitted question "{newQuestion.title}".
Successfully submitted question &ldquo;{newQuestion.title}&rdquo;.
</Typography>
</div>
) : (
Expand Down
1 change: 0 additions & 1 deletion client/src/components/HomePage/BasicCard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
Expand Down
1 change: 0 additions & 1 deletion client/src/components/HomePage/CircularWithValueLabel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import CircularProgress from '@mui/material/CircularProgress';
import Typography from '@mui/material/Typography';
Expand Down
1 change: 0 additions & 1 deletion client/src/components/LandingPage/LandingPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// LandingPage.js
import React from "react";
import { Button, Container, Typography } from "@mui/material";
import { motion } from "framer-motion";
import { Link } from "react-router-dom";
Expand Down
1 change: 0 additions & 1 deletion client/src/components/Login/LoginWrapper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Box, Stack, styled, TextField } from "@mui/material";
import React from "react";
import { ReactComponent as Background } from "../../assets/background.svg";
import { ReactComponent as Logo } from "../../assets/logo.svg";

Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Login/components/Login.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Button, Link, Stack, Typography } from "@mui/material";
import Alert from "@mui/material/Alert";
import axios from "axios";
import React, { useState } from "react";
import { useState } from "react";
import { Link as RouterLink, useNavigate } from "react-router-dom";
import Cookies from "universal-cookie";
import { SVC_ENDPOINTS } from "../../../consts/api";
Expand Down Expand Up @@ -93,7 +93,7 @@ function Login() {
</Button>
</RouterLink>
<Stack alignItems={"center"} marginTop={"10px"}>
<Typography variant="body2">Don't have an account?</Typography>
<Typography variant="body2">Don&apos;t have an account?</Typography>
<Typography variant="body2">
Sign up{" "}
<Link component={RouterLink} to="/signup">
Expand Down
Loading

0 comments on commit f9364c5

Please sign in to comment.