Skip to content

Commit

Permalink
Merge pull request #68 from Game-as-a-Service/dev
Browse files Browse the repository at this point in the history
v0.1.1 Release
  • Loading branch information
ping-yee authored Oct 21, 2023
2 parents e0718ae + 85b47ed commit 7a89308
Show file tree
Hide file tree
Showing 88 changed files with 13,285 additions and 3,051 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/react-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Vite React CI/CD

on:
push:
paths:
- Frontend/**
pull_request:
paths:
- Frontend/**

jobs:
build:
runs-on: ubuntu-latest
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
working-directory: ./Frontend/the-message
run: npm install

- name: Build Vite app
working-directory: ./Frontend/the-message
run: npm run build

- name: Run Unit Tests
working-directory: ./Frontend/the-message
run: npm test

97 changes: 97 additions & 0 deletions .github/workflows/test-go-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: ⚙️ Backend CI

on:
push:
paths:
- Backend/**
- .github/workflows/test-go-unit.yml
pull_request:
paths:
- Backend/**
- .github/workflows/test-go-unit.yml

env:
GO_VERSION: 1.21

jobs:
build:

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Env handle
working-directory: ./Backend
run: cp env .env

- name: Build
working-directory: ./Backend
run: go build -v ./...

unit_test:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: 🧪 Test
working-directory: ./Backend
run: go test $(go list ./... | grep -v /tests/) -count=1 -v -coverprofile=unit_test_coverage.out

- name: Upload unit test coverage report as artifact
uses: actions/upload-artifact@v2
with:
name: unit-test-coverage-report
path: ./Backend/unit_test_coverage.out

acceptance_test:
needs: unit_test
if: github.event_name == 'push'

services:
mysql:
image: mysql:8.1.0
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
MYSQL_DATABASE: test
MYSQL_USER: user
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
ports:
- "3306:3306"

runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Env handle
working-directory: ./Backend
run: cp env .env

- name: Migration
working-directory: ./Backend
run: go run ./cmd/migrate/migrate.go
- name: 🎯 Acceptance test
working-directory: ./Backend
run: go test ./... -v -count=1 -coverprofile=coverage.out

- name: Upload acceptance test coverage report as artifact
uses: actions/upload-artifact@v2
with:
name: acceptance-test-coverage-report
path: ./Backend/coverage.out
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Backend

Backend/.env
/.idea/*
52 changes: 52 additions & 0 deletions Backend/The-Message.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"info": {
"_postman_id": "ae98b73f-44dc-4aa3-8288-1c9e7ece3b0a",
"name": "The-Message",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "11538572"
},
"item": [
{
"name": "InitialGame",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {\r",
" pm.response.to.have.status(200);\r",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"players\": [{\n \"id\": \"6497f6f226b40d440b9a90cc\",\n \"name\": \"A\"\n }, {\n \"id\": \"6498112b26b40d440b9a90ce\",\n \"name\": \"B\"\n }, {\n \"id\": \"6499df157fed0c21a4fd0425\",\n \"name\": \"C\"\n }]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:8080/api/v1/games",
"host": [
"localhost"
],
"port": "8080",
"path": [
"api",
"v1",
"games"
]
}
},
"response": []
}
]
}
5 changes: 0 additions & 5 deletions Backend/app/delivery/game/game.go

This file was deleted.

1 change: 0 additions & 1 deletion Backend/app/entities/game.go

This file was deleted.

1 change: 0 additions & 1 deletion Backend/app/models/game_models.go

This file was deleted.

58 changes: 0 additions & 58 deletions Backend/app/models/user_models.go

This file was deleted.

81 changes: 0 additions & 81 deletions Backend/app/models/user_models_test.go

This file was deleted.

1 change: 0 additions & 1 deletion Backend/app/repositories/memory/game.go

This file was deleted.

18 changes: 14 additions & 4 deletions Backend/cmd/app/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package main

import (
"github.com/Game-as-a-Service/The-Message/config"
"github.com/gin-gonic/gin"
"github.com/Game-as-a-Service/The-Message/app/delivery/game"

http "github.com/Game-as-a-Service/The-Message/service/delivery/http/v1"
mysqlRepo "github.com/Game-as-a-Service/The-Message/service/repository/mysql"
_ "github.com/joho/godotenv/autoload"
)

func main() {
router := gin.Default()
router.GET("/gameInit", game.GameInit)
db := config.InitDB()

engine := gin.Default()

gameRepo := mysqlRepo.NewGameRepository(db)
playerRepo := mysqlRepo.NewPlayerRepository(db)

http.NewGameHandler(engine, gameRepo, playerRepo)

router.Run("0.0.0.0:8080")
engine.Run(":8080")
}
Loading

0 comments on commit 7a89308

Please sign in to comment.