Skip to content

Commit

Permalink
Create release 0.2.0 (#175)
Browse files Browse the repository at this point in the history
Co-authored-by: Ong Jun Xiong <[email protected]>
Co-authored-by: Charisma Kausar <[email protected]>
Co-authored-by: Charisma Kausar <[email protected]>
Co-authored-by: Gabriel Goh <[email protected]>
Co-authored-by: chunweii <[email protected]>
  • Loading branch information
6 people authored Oct 24, 2023
1 parent b4335e7 commit ce041dd
Show file tree
Hide file tree
Showing 64 changed files with 2,133 additions and 625 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
PRISMA_DATABASE_URL: ${{ secrets.SYSTEMTEST_DATABASE_URL }}
PRISMA_DATABASE_PASSWORD: ${{ secrets.SYSTEMTEST_DATABASE_PASSWORD }}
NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG: ${{ secrets.FRONTEND_FIREBASE_CONFIG_DEV }}

jobs:
mainbuild:
Expand Down Expand Up @@ -55,3 +56,13 @@ jobs:
run: |
yarn workspace user-service systemtest:ci
yarn workspace admin-service systemtest:ci
- name: Simulate production build
run: |
yarn workspace admin-service build
yarn workspace collaboration-service build
yarn workspace gateway build
yarn workspace matching-service build
yarn workspace question-service build
yarn workspace user-service build
yarn workspace frontend build
15 changes: 15 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ env:
PRISMA_DATABASE_URL: ${{ secrets.PRISMA_DATABASE_URL_PROD }}
MONGO_ATLAS_URL: ${{ secrets.MONGO_ATLAS_URL_PROD }}
NEXT_PUBLIC_FRONTEND_FIREBASE_CONFIG: ${{ secrets.FRONTEND_FIREBASE_CONFIG_PROD }}
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }}
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }}

jobs:
setup-build-publish-deploy:
Expand Down Expand Up @@ -81,6 +84,18 @@ jobs:
--ignore-not-found
kubectl create secret generic frontend-firebase-config \
--from-file=frontend-firebase-config=./next_public_frontend_firebase_config.json
kubectl delete secret twilio-account-sid \
--ignore-not-found
kubectl create secret generic twilio-account-sid \
--from-literal=twilio-account-sid=$TWILIO_ACCOUNT_SID
kubectl delete secret twilio-api-key \
--ignore-not-found
kubectl create secret generic twilio-api-key \
--from-literal=twilio-api-key=$TWILIO_API_KEY
kubectl delete secret twilio-api-secret \
--ignore-not-found
kubectl create secret generic twilio-api-secret \
--from-literal=twilio-api-secret=$TWILIO_API_SECRET
# Remove the JSON files
- name: Delete JSON files
Expand Down
18 changes: 18 additions & 0 deletions deployment/gke-prod-manifests/admin-service-autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: admin-service-autoscaling
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: admin-service
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: admin-service
namespace: default
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
io.kompose.service: admin-service
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: collaboration-service-autoscaling
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: collaboration-service
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: collaboration-service
namespace: default
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
io.kompose.service: collaboration-service
Expand All @@ -26,6 +26,21 @@ spec:
key: prisma-database-url
- name: PORT
value: "5003"
- name: TWILIO_ACCOUNT_SID
valueFrom:
secretKeyRef:
name: twilio-account-sid
key: twilio-account-sid
- name: TWILIO_API_KEY
valueFrom:
secretKeyRef:
name: twilio-api-key
key: twilio-api-key
- name: TWILIO_API_SECRET
valueFrom:
secretKeyRef:
name: twilio-api-secret
key: twilio-api-secret
image: asia-southeast1-docker.pkg.dev/peerprep-group11-prod/codeparty-prod-images/collaboration-service:latest
name: collaboration-service
ports:
Expand Down
18 changes: 18 additions & 0 deletions deployment/gke-prod-manifests/frontend-autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: frontend-autoscaling
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: frontend
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
2 changes: 1 addition & 1 deletion deployment/gke-prod-manifests/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: frontend
namespace: default
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
io.kompose.service: frontend
Expand Down
18 changes: 18 additions & 0 deletions deployment/gke-prod-manifests/gateway-autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: gateway-autoscaling
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: gateway
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
2 changes: 1 addition & 1 deletion deployment/gke-prod-manifests/gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: gateway
namespace: default
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
io.kompose.service: gateway
Expand Down
18 changes: 18 additions & 0 deletions deployment/gke-prod-manifests/matching-service-autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: matching-service-autoscaling
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: matching-service
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: matching-service
namespace: default
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
io.kompose.service: matching-service
Expand Down
18 changes: 18 additions & 0 deletions deployment/gke-prod-manifests/question-service-autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: question-service-autoscaling
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: question-service
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: question-service
namespace: default
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
io.kompose.service: question-service
Expand Down
18 changes: 18 additions & 0 deletions deployment/gke-prod-manifests/user-service-autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: user-service-autoscaling
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: user-service
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
2 changes: 1 addition & 1 deletion deployment/gke-prod-manifests/user-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: user-service
namespace: default
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
io.kompose.service: user-service
Expand Down
5 changes: 5 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
"start:local": "dotenv -e ../.env -- next start -H 0.0.0.0"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@hookform/resolvers": "^3.3.1",
"@monaco-editor/react": "^4.5.2",
"@mui/material": "^5.14.14",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
Expand All @@ -25,6 +28,7 @@
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@tanstack/react-query": "^5.0.0",
"@tanstack/react-table": "^8.10.4",
"autoprefixer": "10.4.15",
"class-variance-authority": "^0.7.0",
Expand All @@ -39,6 +43,7 @@
"ot-text-unicode": "^4.0.0",
"postcss": "8.4.29",
"react": "18.2.0",
"react-activity-calendar": "^2.0.2",
"react-dom": "18.2.0",
"react-hook-form": "^7.47.0",
"react-icons": "^4.11.0",
Expand Down
37 changes: 23 additions & 14 deletions frontend/providers/MatchmakingProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import React, {
import { io, Socket } from "socket.io-client";
import { Match } from "@prisma/client";
import { AuthContext } from "@/contexts/AuthContext";
import {matchSocketAddress} from "@/gateway-address/gateway-address";

const SERVER_URL = "http://localhost:5002";
const SERVER_URL = matchSocketAddress;

interface MatchmakingContextValue {
socket: Socket | null;
Expand Down Expand Up @@ -48,19 +49,27 @@ export const MatchmakingProvider: React.FC<MatchmakingProviderProps> = ({
// Initialize socket connection
useEffect(() => {
if (currentUser) {
const newSocket = io(SERVER_URL, {
autoConnect: false,
// query: { username: currentUser?.email },
query: { username: generateRandomNumber() },
});
setSocket(newSocket);
newSocket.connect();

console.log("Socket connected");

return () => {
newSocket.close();
};
currentUser.getIdToken(true).then(
(token) => {
const newSocket = io(SERVER_URL, {
autoConnect: false,
// query: { username: currentUser?.email },
query: { username: generateRandomNumber() },
extraHeaders: {
"User-Id-Token": token
},
path: "/match/socket.io"
});
setSocket(newSocket);
newSocket.connect();

console.log("Socket connected");

return () => {
newSocket.close();
};
}
)
}
}, [currentUser]);

Expand Down
12 changes: 8 additions & 4 deletions frontend/src/components/common/difficulty-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ type Difficulty = 'easy' | 'medium' | 'hard' | 'any';
interface DifficultySelectorProps {
onChange: (value: Difficulty) => void;
showAny: boolean;
defaultValue: Difficulty;
value: Difficulty;
}

export default function DifficultySelector({ onChange, showAny, defaultValue }: DifficultySelectorProps) {
export default function DifficultySelector({ onChange, showAny, value }: DifficultySelectorProps) {

const difficulties = [
{ label: "Easy", value: "easy" },
Expand All @@ -27,9 +27,13 @@ export default function DifficultySelector({ onChange, showAny, defaultValue }:
<Button
key={difficulty.value}
className="w-32"
variant={defaultValue == difficulty.value ? "outline" : "secondary"}
variant={value == difficulty.value ? "outline" : "secondary"}
value={difficulty.value}
onClick={(e) => onChange(e.currentTarget.value as Difficulty)}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
onChange(e.currentTarget.value as Difficulty);
}}
>
{difficulty.label}
</Button>
Expand Down
Loading

0 comments on commit ce041dd

Please sign in to comment.