Skip to content

Commit bf884f0

Browse files
authored
Merge pull request #186 from ccd-course/Release/2.0.0
Release/2.0.0
2 parents fb95171 + 68113b0 commit bf884f0

File tree

67 files changed

+2549
-1392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2549
-1392
lines changed

.github/workflows/maven.yml

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,56 @@ jobs:
3131
- name: Compile with Maven
3232
run: mvn compile
3333

34+
Sonarcloud:
35+
name: Sonarcloud
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v2
39+
with:
40+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
41+
- name: Set up JDK 17
42+
uses: actions/setup-java@v1
43+
with:
44+
java-version: 17
45+
- name: Cache SonarCloud packages
46+
uses: actions/cache@v1
47+
with:
48+
path: ~/.sonar/cache
49+
key: ${{ runner.os }}-sonar
50+
restore-keys: ${{ runner.os }}-sonar
51+
- name: Cache Maven packages
52+
uses: actions/cache@v1
53+
with:
54+
path: ~/.m2
55+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
56+
restore-keys: ${{ runner.os }}-m2
57+
- name: Build and analyze
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
60+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
61+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ccd-course_chess_backend
62+
63+
PMD:
64+
name: Run code analyzer PMD
65+
needs: [ Compile ]
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v2
70+
- name: Set up JDK 17
71+
uses: actions/setup-java@v2
72+
with:
73+
java-version: '17'
74+
distribution: 'adopt'
75+
cache: maven
76+
- name: Run PMD command
77+
run: mvn pmd:pmd
78+
- name: Generate CMD Artifact
79+
uses: actions/upload-artifact@v1
80+
with:
81+
name: PMDResult
82+
path: target/site/pmd.html
83+
3484
Tests:
3585
needs: [ Compile ]
3686
runs-on: ubuntu-latest
@@ -51,6 +101,12 @@ jobs:
51101
name: Test Reports
52102
path: target/surefire-reports/*.xml
53103
reporter: java-junit
104+
- name: Generate Test Coverage Artifact
105+
uses: actions/upload-artifact@v1
106+
if: success() || failure()
107+
with:
108+
name: TestCoverage
109+
path: target/jacoco-report
54110

55111
JavaDoc:
56112
needs: [ Compile ]
@@ -110,7 +166,7 @@ jobs:
110166
run: dir target/
111167

112168
- name: Copy generated jar to ./staging
113-
run: mkdir staging && cp target/backend-0.0.1-SNAPSHOT.jar staging
169+
run: mkdir staging && cp target/backend-2.0.0.jar staging
114170

115171
- name: Upload artifacts
116172
uses: actions/upload-artifact@v1
@@ -235,7 +291,7 @@ jobs:
235291
if: ${{ github.ref_name == 'main' }}
236292
with:
237293
# relative path to the place where source code with Dockerfile is located
238-
context: .
294+
context: ./docs
239295
# Note: tags has to be all lower-case
240296
tags: |
241297
valentinriess/chess_backend_docs:latest
@@ -264,4 +320,4 @@ jobs:
264320
# The data sent to the webhook
265321
body: ""
266322
# Enables calling to known self-signed or invalid SSL certificates
267-
insecure: False
323+
insecure: False

Readme.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Chess backend
1+
# Circular Chess backend
22
[![Java CI with Maven](https://github.com/ccd-course/chess_backend/actions/workflows/maven.yml/badge.svg)](https://github.com/ccd-course/chess_backend/actions/workflows/maven.yml)
33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44

55

6-
This is the backend part of the Chess project consist mainly of:
6+
The backend mainly consist of:
77
- Controllers
88
- Models
99
- Services
@@ -34,9 +34,11 @@ Local instances can be found here:
3434

3535
## Auto deployment
3636
The develop branches of [frontend](https://github.com/ccd-course/frontend_app) and [backend](https://github.com/ccd-course/chess_backend) are auto deployed on every commit:
37-
- [chess.valentinriess.com](https://chess.valentinriess.com)
38-
- [backend.chess.valentinriess.com](https://backend.chess.valentinriess.com)
37+
- [circularchess.net](https://circularchess.net)
38+
- [api.circularchess.net](https://api.circularchess.net)
3939

4040
## Documentation
4141
- [Generated JavaDocs](https://ccd-course.github.io/chess_backend/index.html)
42-
- [API Documentation](https://backend.chess.valentinriess.com/docs.html)
42+
- [API Documentation](https://api.circularchess.net/docs.html)
43+
- [Architecture diagram](https://plantuml-server.kkeisuke.dev/svg/TLF1Ri8m3BtdAwmUAy7k4q8mD3OEaoO6fuf3Q3sMBKsw96L24_y-ErsX7UnGjNf-UNxFSIS-I1VgKWjZ2uHaxgm9zwP8u5i0p6nPMOCcGF8WIuJruWpvH10Zmpr_WrO-e46tOKpRdJ8tNkrCNKLWYPyr-k0tGeWZFRcsTH4xD5rVqEtHSSzUqpkPVw0fcFUuMZt30B8PsNDMQtIUbPTOMQ-2TOU52UXUPOwUQMUSMIolgDBbP2t8X2ToeViA9KDi6E0ONRTUvyhXLdfi9jIrEwt36xrLBeEoXgkCJ7DIZ99h7rt7KwnNo21PgT7qv1QJsEueUZbXE1n3TXbYSmlAl6CUl3YdQSZNvjAbT-RJ7FWpWJxtz_8Q9jy4bMkFLElTT5C_PsvP_NO3ufpo4kNBgK0ZLqPSx58Zs2NxUkjpfxO8QJeQMQCFu50MupJzvpGjt-Ncih6Afiy9hbIZnLFgDkf_nDu8siGJMblwgNu0)
44+
- [sequence diagram](https://i.ibb.co/bF2JWFq/seq-chess-drawio-1.png)

pom.xml

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,36 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.6.0</version>
8+
<version>2.6.2</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.chess</groupId>
1212
<artifactId>backend</artifactId>
13-
<version>0.0.1-SNAPSHOT</version>
13+
<version>2.0.0</version>
1414
<name>backend</name>
1515
<description>chess controller service</description>
1616
<properties>
1717
<java.version>17</java.version>
18+
<log4j2.version>2.17.1</log4j2.version>
19+
<sonar.organization>ccd-course</sonar.organization>
20+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
1821
</properties>
1922
<dependencies>
23+
<dependency>
24+
<groupId>com.google.firebase</groupId>
25+
<artifactId>firebase-admin</artifactId>
26+
<version>8.1.0</version>
27+
</dependency>
28+
<dependency>
29+
<groupId>com.google.cloud</groupId>
30+
<artifactId>google-cloud-firestore</artifactId>
31+
<version>3.0.2</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.google.code.gson</groupId>
35+
<artifactId>gson</artifactId>
36+
<version>2.8.6</version>
37+
</dependency>
2038
<dependency>
2139
<groupId>org.springframework.boot</groupId>
2240
<artifactId>spring-boot-starter-data-mongodb</artifactId>
@@ -49,6 +67,19 @@
4967
<artifactId>springdoc-openapi-javadoc</artifactId>
5068
<version>1.5.13</version>
5169
</dependency>
70+
<dependency>
71+
<groupId>org.mockito</groupId>
72+
<artifactId>mockito-core</artifactId>
73+
<version>4.2.0</version>
74+
<scope>test</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>junit</groupId>
78+
<artifactId>junit</artifactId>
79+
<version>4.13.1</version>
80+
<scope>test</scope>
81+
</dependency>
82+
5283
</dependencies>
5384
<profiles>
5485
<profile>
@@ -101,7 +132,46 @@
101132
<target>16</target>
102133
</configuration>
103134
</plugin>
135+
<plugin>
136+
<groupId>org.jacoco</groupId>
137+
<artifactId>jacoco-maven-plugin</artifactId>
138+
<version>0.8.7</version>
139+
<executions>
140+
<execution>
141+
<id>prepare-agent</id>
142+
<goals>
143+
<goal>prepare-agent</goal>
144+
</goals>
145+
</execution>
146+
<execution>
147+
<id>report</id>
148+
<phase>prepare-package</phase>
149+
<goals>
150+
<goal>report</goal>
151+
</goals>
152+
</execution>
153+
<execution>
154+
<id>post-unit-test</id>
155+
<phase>test</phase>
156+
<goals>
157+
<goal>report</goal>
158+
</goals>
159+
<configuration>
160+
<dataFile>target/jacoco.exec</dataFile>
161+
<outputDirectory>target/jacoco-report</outputDirectory>
162+
</configuration>
163+
</execution>
164+
</executions>
165+
</plugin>
104166
</plugins>
105167
</build>
106-
168+
<reporting>
169+
<plugins>
170+
<plugin>
171+
<groupId>org.apache.maven.plugins</groupId>
172+
<artifactId>maven-pmd-plugin</artifactId>
173+
<version>3.15.0</version>
174+
</plugin>
175+
</plugins>
176+
</reporting>
107177
</project>

sonar-project.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sonar.organization=ccd-course
2+
sonar.projectKey=ccd-course_chess_backend
3+
4+
# relative paths to source directories. More details and properties are described
5+
# in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/
6+
sonar.sources=.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.chess.backend.domain.controllers.objects;
22

3+
/**
4+
* Interface of a NewPlayerObject
5+
*/
36
public interface INewPlayerObject {
47
String getPlayerName();
58
}

src/main/java/com/chess/backend/domain/controllers/objects/INewPlayersObject.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import com.chess.backend.restController.objects.NewPlayerObject;
44

5+
/**
6+
* Interface of a NewPlayersObject
7+
*/
58
public interface INewPlayersObject {
69
String[] getAllPlayerNames();
710

src/main/java/com/chess/backend/domain/models/IBoard.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
package com.chess.backend.domain.models;
22

33
import com.chess.backend.gamemodel.Moves;
4-
import com.chess.backend.gamemodel.Piece;
54
import com.chess.backend.gamemodel.Square;
65

6+
import java.util.ArrayList;
7+
8+
/**
9+
* Interface of Board class
10+
*/
711
public interface IBoard {
812
int getNumberOfPlayers();
913

10-
Square[][] getSquares();
11-
12-
Piece getTwoSquareMovedPawn();
13-
14-
Piece getTwoSquareMovedPawn2();
14+
ArrayList<ArrayList<Square>> getSquares();
1515

1616
boolean isBreakCastling();
1717

1818
Moves getMoves_history();
1919

2020
void setNumberOfPlayers(int numberOfPlayers);
2121

22-
void setSquares(Square[][] squares);
23-
24-
void setTwoSquareMovedPawn(Piece twoSquareMovedPawn);
22+
void setSquares(ArrayList<ArrayList<Square>> squares);
2523

26-
void setTwoSquareMovedPawn2(Piece twoSquareMovedPawn2);
2724

2825
void setBreakCastling(boolean breakCastling);
2926

src/main/java/com/chess/backend/domain/models/IGame.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import com.chess.backend.gamemodel.Moves;
55
import com.chess.backend.gamemodel.Player;
66

7+
import java.util.List;
8+
9+
/**
10+
* Interface of Game class
11+
*/
712
public interface IGame {
813
Chessboard getChessboard();
914

@@ -13,7 +18,7 @@ public interface IGame {
1318

1419
int getId();
1520

16-
Player[] getPlayers();
21+
List<Player> getPlayers();
1722

1823
void setChessboard(Chessboard chessboard);
1924

@@ -23,5 +28,5 @@ public interface IGame {
2328

2429
void setId(int id);
2530

26-
void setPlayers(Player[] players);
31+
void setPlayers(List<Player> players);
2732
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.chess.backend.domain.repository;
2+
3+
4+
import com.chess.backend.gamemodel.ChessGame;
5+
import com.chess.backend.repository.metadata.EventObject;
6+
7+
import java.util.List;
8+
9+
/**
10+
* Interface of GameRepository class
11+
*/
12+
public interface IGameRepository{
13+
ChessGame getGame(Integer gameId);
14+
void createNewGame(Integer gameId, ChessGame game, List<EventObject> events);
15+
void createNewGame(Integer gameId, ChessGame game);
16+
void updateGame(Integer gameId, ChessGame game, List<EventObject> events);
17+
void updateGame(Integer gameId, ChessGame game);
18+
19+
}

0 commit comments

Comments
 (0)