Skip to content

Commit 7f49e30

Browse files
Merge pull request #12 from Wassim-Rached/staging
Staging with docs andworkflows
2 parents ecc757b + 16b0ef3 commit 7f49e30

File tree

20 files changed

+1576
-132
lines changed

20 files changed

+1576
-132
lines changed

.deepsource.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version = 1
2+
3+
[[analyzers]]
4+
name = "java"
5+
enabled = true
6+
7+
[analyzers.meta]
8+
runtime_version = "21"
9+
10+
[[analyzers]]
11+
name = "test-coverage"
12+
enabled = false
13+
14+
[[analyzers]]
15+
name = "secrets"
16+
enabled = true
17+
18+
[[analyzers]]
19+
name = "shell"
20+
enabled = true
Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,55 @@
1-
2-
name: Build & Deploy QuizHub to Docker Hub
3-
run-name: Deploying QuizHub to Docker Hub
4-
concurrency: docker-build
5-
6-
on:
7-
workflow_dispatch:
8-
9-
jobs:
10-
build-deploy:
11-
name: Build and Deploy Spring boot for beginner
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v3
16-
17-
- name: Setup JDK 17
18-
uses: actions/setup-java@v3
19-
with:
20-
distribution: 'corretto'
21-
java-version: 17
22-
23-
- name: Unit Tests
24-
run: mvn -B test --file pom.xml
25-
26-
- name: Build the application
27-
run: |
28-
mvn clean
29-
mvn -B package --file pom.xml
30-
31-
- name: Build Docker Image
32-
uses: docker/build-push-action@v2
33-
with:
34-
context: .
35-
dockerfile: Dockerfile
36-
push: false
37-
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:latest
38-
39-
- name: Login to Docker Hub
40-
uses: docker/login-action@v1
41-
with:
42-
username: ${{ secrets.DOCKER_HUB_USERNAME }}
43-
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
44-
45-
- name: Push to Docker Hub
46-
uses: docker/build-push-action@v2
47-
with:
48-
context: .
49-
dockerfile: Dockerfile
50-
push: true
51-
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:latest
1+
name: Build & Deploy QuizHub Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseTag:
7+
description: 'Release Tag to Deploy'
8+
required: true
9+
default: 'latest'
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
build-deploy:
15+
name: Build & Deploy
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup JDK 21
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: 'corretto'
25+
java-version: 21
26+
27+
- name: Unit Tests
28+
run: mvn -B test --file pom.xml
29+
30+
- name: Build the application
31+
run: |
32+
mvn clean
33+
mvn -B package --file pom.xml
34+
35+
- name: Build Docker Image
36+
uses: docker/build-push-action@v2
37+
with:
38+
context: .
39+
dockerfile: Dockerfile
40+
push: false
41+
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:${{ github.event.release.tag_name || github.event.inputs.releaseTag }}
42+
43+
- name: Login to Docker Hub
44+
uses: docker/login-action@v1
45+
with:
46+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
47+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
48+
49+
- name: Push to Docker Hub
50+
uses: docker/build-push-action@v2
51+
with:
52+
context: .
53+
dockerfile: Dockerfile
54+
push: true
55+
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:${{ github.event.release.tag_name || github.event.inputs.releaseTag }}

.github/workflows/test.yml renamed to .github/workflows/continuous_delivery_staging.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
1-
name: Build & Deploy Spring app
1+
name: Build & Deploy QuizHub-staging Docker Image
22

33
on:
44
workflow_dispatch:
5+
push:
6+
branches:
7+
- staging
58

69
jobs:
710
build-deploy:
8-
name: Build and Deploy Spring boot for beginner
11+
name: Build & Deploy
912
runs-on: ubuntu-latest
1013
steps:
1114
- name: Checkout code
12-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1316

14-
- name: Setup JDK 17
15-
uses: actions/setup-java@v3
17+
- name: Setup JDK 21
18+
uses: actions/setup-java@v4
1619
with:
1720
distribution: 'corretto'
18-
java-version: 17
19-
20-
- name: Unit Tests
21-
run: mvn -B test --file pom.xml
21+
java-version: 21
2222

23+
# - name: Unit Tests
24+
# run: mvn -B test --file pom.xml
25+
#
2326
- name: Build the application
2427
run: |
2528
mvn clean
2629
mvn -B package --file pom.xml
27-
30+
2831
- name: Build Docker Image
2932
uses: docker/build-push-action@v2
3033
with:
3134
context: .
3235
dockerfile: Dockerfile
3336
push: false
34-
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:latest
35-
37+
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:staging
38+
3639
- name: Login to Docker Hub
3740
uses: docker/login-action@v1
3841
with:
@@ -45,4 +48,4 @@ jobs:
4548
context: .
4649
dockerfile: Dockerfile
4750
push: true
48-
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:latest
51+
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/quizhub:staging
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Continuous Integration
2+
run-name: CI Pipeline
3+
concurrency: CI-${{ github.repository }}-${{ github.ref }}
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- staging
9+
- dev
10+
11+
jobs:
12+
build-test:
13+
name: Build and Test
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup JDK 21
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'corretto'
23+
java-version: 21
24+
25+
- name: Unit Tests
26+
run: mvn -B test --file pom.xml
27+
28+
- name: Build the application
29+
run: |
30+
mvn clean
31+
mvn -B package --file pom.xml
32+
33+
- name: Upload test results
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: test-results
37+
path: target/

pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,45 @@
8282
<!-- <scope>test</scope> &lt;!&ndash; Make sure to include it as a test dependency &ndash;&gt;-->
8383
</dependency>
8484

85+
<dependency>
86+
<groupId>org.springframework.restdocs</groupId>
87+
<artifactId>spring-restdocs-mockmvc</artifactId>
88+
<version>3.0.1</version>
89+
<scope>test</scope>
90+
</dependency>
91+
8592
</dependencies>
8693

8794
<build>
8895
<plugins>
96+
97+
<plugin>
98+
<groupId>org.asciidoctor</groupId>
99+
<artifactId>asciidoctor-maven-plugin</artifactId>
100+
<version>2.2.1</version>
101+
<executions>
102+
<execution>
103+
<id>generate-docs</id>
104+
<phase>prepare-package</phase>
105+
<goals>
106+
<goal>process-asciidoc</goal>
107+
</goals>
108+
<configuration>
109+
<backend>html</backend>
110+
<doctype>book</doctype>
111+
<outputDirectory>./src/main/resources/static/docs</outputDirectory>
112+
</configuration>
113+
</execution>
114+
</executions>
115+
<dependencies>
116+
<dependency>
117+
<groupId>org.springframework.restdocs</groupId>
118+
<artifactId>spring-restdocs-asciidoctor</artifactId>
119+
<version>3.0.1</version>
120+
</dependency>
121+
</dependencies>
122+
</plugin>
123+
89124
<plugin>
90125
<groupId>org.springframework.boot</groupId>
91126
<artifactId>spring-boot-maven-plugin</artifactId>

src/main/asciidoc/docs.css

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
span{
2+
background: none !important;
3+
}
4+
5+
/* Override Bootstrap defaults */
6+
body {
7+
font-family: Arial, sans-serif;
8+
}
9+
10+
/* HTTP Request and Response Sections */
11+
.http-request, .http-response {
12+
background-color: #fff;
13+
border: 1px solid #ced4da; /* Light gray border */
14+
border-radius: 0.25rem;
15+
padding: 1rem;
16+
margin-bottom: 1rem;
17+
}
18+
19+
/* Code Blocks */
20+
pre {
21+
background-color: #f8f9fa; /* Light gray background */
22+
padding: 1rem;
23+
border-radius: 0.25rem;
24+
overflow-x: auto;
25+
border: 1px solid #ced4da; /* Light gray border */
26+
}
27+
28+
/* Tables */
29+
table {
30+
width: 100%;
31+
border-collapse: collapse;
32+
margin-bottom: 1rem;
33+
}
34+
35+
th, td {
36+
border: 1px solid #ced4da; /* Light gray border */
37+
padding: 0.75rem;
38+
}
39+
40+
th {
41+
background-color: #f2f2f2; /* Light gray background for table headers */
42+
}
43+
44+
/* Links */
45+
a {
46+
color: #007bff; /* Blue links */
47+
text-decoration: none;
48+
}
49+
50+
a:hover {
51+
text-decoration: underline;
52+
color: #0056b3; /* Darker blue on hover */
53+
}

src/main/asciidoc/index.adoc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
= QuizHub Backend Server API Documentation
2+
:toc: macro
3+
:toc-title: Table of Contents
4+
:doctype: book
5+
:icons: font
6+
:sectanchors:
7+
:sectlinks:
8+
:stylesheet: docs.css
9+
10+
Welcome to the QuizHub Backend Server API Documentation. This document provides comprehensive information about the various endpoints available in the QuizHub application.
11+
12+
== Overview
13+
14+
The QuizHub Backend Server provides RESTful APIs for managing quizzes, users, and scores. Below you will find the detailed documentation of the available endpoints.
15+
16+
== API Endpoints
17+
18+
=== Search Quizzes
19+
.Search for quizzes by title
20+
include::{snippets}/quiz/search-quizzes/http-request.adoc[]
21+
include::{snippets}/quiz/search-quizzes/http-response.adoc[]
22+
23+
=== Create Quiz
24+
.Create a new quiz
25+
include::{snippets}/quiz/create-quiz/http-request.adoc[]
26+
include::{snippets}/quiz/create-quiz/http-response.adoc[]
27+
28+
=== Start Quiz Attempt
29+
.Start a new quiz attempt
30+
include::{snippets}/quiz/start-quiz-attempt/http-request.adoc[]
31+
include::{snippets}/quiz/start-quiz-attempt/http-response.adoc[]
32+
33+
=== Submit Question Attempts
34+
.Submit answers for a quiz attempt
35+
include::{snippets}/quiz/submit-question-attempts/http-request.adoc[]
36+
include::{snippets}/quiz/submit-question-attempts/http-response.adoc[]
37+
38+
=== Get Quiz Attempt Taking
39+
.Get the details of an ongoing quiz attempt
40+
include::{snippets}/quiz/get-quiz-attempt-taking/http-request.adoc[]
41+
include::{snippets}/quiz/get-quiz-attempt-taking/http-response.adoc[]
42+
43+
=== Cancel Quiz Attempt
44+
.Cancel an ongoing quiz attempt
45+
include::{snippets}/quiz/cancel-quiz-attempt/http-request.adoc[]
46+
include::{snippets}/quiz/cancel-quiz-attempt/http-response.adoc[]
47+
48+
=== Finish Quiz Attempt
49+
.Finish and submit a quiz attempt
50+
include::{snippets}/quiz/finish-quiz-attempt/http-request.adoc[]
51+
include::{snippets}/quiz/finish-quiz-attempt/http-response.adoc[]
52+
53+
=== Get Quiz Attempt Result
54+
.Get the results of a completed quiz attempt
55+
include::{snippets}/quiz/get-quiz-attempt-result/http-request.adoc[]
56+
include::{snippets}/quiz/get-quiz-attempt-result/http-response.adoc[]

0 commit comments

Comments
 (0)