Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
#	docker-compose.yaml
#	src/main/java/com/ak/spring/controller/PersonController.java
#	src/main/java/com/ak/spring/controller/PlayerController.java
#	src/main/java/com/ak/spring/data/entity/AbstractRevisionable.java
#	src/main/java/com/ak/spring/data/entity/Player.java
#	src/main/java/com/ak/spring/security/PersonDetailsService.java
#	src/main/java/module-info.java
#	src/test/java/com/ak/spring/security/PersonDetailsServiceTest.java
#	src/test/java/com/ak/spring/security/PersonRepositoryTest.java
#	src/test/java/com/ak/spring/security/PlayerRepositoryTest.java
  • Loading branch information
ak-git committed Dec 3, 2023
2 parents af02346 + 00df27f commit 0483f00
Show file tree
Hide file tree
Showing 37 changed files with 45 additions and 1,756 deletions.
8 changes: 0 additions & 8 deletions .deepsource.toml

This file was deleted.

18 changes: 10 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 19
java-version: 20
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.5
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
Expand All @@ -31,13 +35,11 @@ jobs:
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: gradle build jacocoTestReport sonar --info
- name: Set current date as env variable
run: echo "RELEASE_DATE=$(date +%s)" >> $GITHUB_ENV
- name: Echo current date
run: echo ${{ env.RELEASE_DATE }}
- name: Login to Docker Hub
run: docker login -u a002k -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build the Docker image
run: docker build -t a002k/simple-spring-app:${{ env.RELEASE_DATE }} -t a002k/simple-spring-app:latest .
- name: Build and tag the Docker image
run: |
COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
docker build -t a002k/simple-spring-app:$COMMIT_SHA .
- name: Push the Docker image
run: docker push a002k/simple-spring-app --all-tags
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/dataSources.local.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM openjdk:19
FROM openjdk:20

# Create a new app directory for my application files
RUN mkdir /app

ENV JAR_TO_COPY=SimpleSpringApp-2023.03.04.jar
ENV JAR_TO_COPY=SimpleSpringApp-2023.12.03.jar
# Copy the app files from host machine to image filesystem
COPY build/libs/${JAR_TO_COPY} /app

Expand Down
60 changes: 0 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,6 @@ up: `docker-compose up -d`

down: `docker-compose down`

## User management

### List all users

`$ curl localhost:8080/controller/persons/ -u admin:maddog -c cookie.txt`

### Find user by name

`$ curl localhost:8080/controller/persons/admin -c cookie.txt`

`$ curl localhost:8080/controller/persons/user -c cookie.txt`

### Create new user

Find **XSRF-TOKEN** in `cookie.txt`

`$ curl -X POST localhost:8080/controller/persons/
-H "Content-type:application/json"
-H "Cookie: XSRF-TOKEN=8a2cecc9-a7ea-4ef5-9b19-8caea71c68cc" -H "X-XSRF-TOKEN:8a2cecc9-a7ea-4ef5-9b19-8caea71c68cc" -u admin:password
-d "Doo"`

### Delete user

`curl -X DELETE localhost:8080/controller/persons/user1
-H "Cookie: XSRF-TOKEN=fabe1658-6e15-4cbf-b0bd-538bafad6cd8" -H "X-XSRF-TOKEN:fabe1658-6e15-4cbf-b0bd-538bafad6cd8" -u admin:password`

## Player management

### List all players

`$ curl localhost:8080/controller/players/ -u user:password -c cookie.txt`

### Create new player

Find **XSRF-TOKEN** in `cookie.txt`

`$ curl -X POST localhost:8080/controller/players/
-H "Content-type:application/json"
-H "Cookie: XSRF-TOKEN=f9923651-c287-4f19-a1d0-6bbad646ff01" -H "X-XSRF-TOKEN:f9923651-c287-4f19-a1d0-6bbad646ff01" -u user:password
-d {\"lastName\":\"Doo\"}`

### Update player

`$ curl -X PUT localhost:8080/controller/players/ddba8655-4c9b-4760-81c0-e32448866550 -H "Content-type:application/json"
-H "Cookie: XSRF-TOKEN=f9923651-c287-4f19-a1d0-6bbad646ff01" -H "X-XSRF-TOKEN:f9923651-c287-4f19-a1d0-6bbad646ff01" -u user:password
-d {\"lastName\":\"Doo2\"}`

### Find player by id

`$ curl localhost:8080/controller/players/ddba8655-4c9b-4760-81c0-e32448866550 -u user:password`

### History for player by id

`$ curl localhost:8080/controller/players/history/ddba8655-4c9b-4760-81c0-e32448866550 -u admin:maddog`

### Delete player by id

`curl -X DELETE localhost:8080/controller/players/ddba8655-4c9b-4760-81c0-e32448866550
-H "Cookie: XSRF-TOKEN=f9923651-c287-4f19-a1d0-6bbad646ff01" -H "X-XSRF-TOKEN:f9923651-c287-4f19-a1d0-6bbad646ff01" -u user:password`

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/53ba623ba8c3475693088b60067b1a7b)](https://app.codacy.com/gh/ak-git/SimpleSpringApp?utm_source=github.com&utm_medium=referral&utm_content=ak-git/SimpleSpringApp&utm_campaign=Badge_Grade_Settings)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ak-git_SimpleSpringApp&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=ak-git_SimpleSpringApp)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=ak-git_SimpleSpringApp&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=ak-git_SimpleSpringApp)
Expand Down
57 changes: 22 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import com.github.spotbugs.snom.Confidence

plugins {
id "org.javamodularity.moduleplugin" version '1.8.12'
id 'java'
id 'java-library'
id 'idea'
id "org.sonarqube" version '4.0.0.2929'
id "org.sonarqube" version '4.4.1.3373'
id 'jacoco'
id "application"
id "com.github.spotbugs" version '5.0.13'
id 'org.springframework.boot' version '2.7.9'
id 'io.spring.dependency-management' version '1.1.0'
id "com.github.spotbugs" version '6.0.1'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'

id 'com.github.ben-manes.versions' version '0.50.0'
id 'nebula.lint' version '19.0.1'
}

spotbugs {
reportLevel = 'high'
reportLevel = Confidence.valueOf('HIGH')
}

spotbugsMain {
reports {
html {
stylesheet = 'fancy-hist.xsl'
}
tasks.spotbugsMain {
reports.create("html") {
required = true
setStylesheet("fancy-hist.xsl")
}
}

Expand All @@ -34,24 +37,22 @@ sonar {
}

jacoco {
toolVersion = "0.8.8"
toolVersion = "0.8.9"
}

ext {
javaVersion = JavaVersion.VERSION_19
h2 = 'com.h2database:h2:2.1.214'
postgres = 'org.postgresql:postgresql:42.5.0'
javaVersion = JavaVersion.VERSION_20
}

wrapper {
description 'Setup the Gradle wrapper'
gradleVersion = "8.0.2"
gradleVersion = "8.5"
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}

allprojects {
group = 'com.ak'
version = '2023.03.04'
version = '2023.12.03'
apply plugin: 'idea'

apply plugin: 'java'
Expand All @@ -77,16 +78,11 @@ allprojects {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly h2
runtimeOnly postgres
testImplementation 'org.springframework.security:spring-security-test'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation 'org.yaml:snakeyaml:2.2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.assertj:assertj-core:3.24.2'
}

test {
Expand All @@ -103,13 +99,4 @@ configurations {
configureEach {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}

application {
mainModule = 'com.ak.spring'
mainClass = 'com.ak.spring.Application'
}
71 changes: 2 additions & 69 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,83 +1,16 @@
version: "3.9"
services:
db:
container_name: db
image: postgres:14.5
environment:
POSTGRES_DB: "db"
POSTGRES_USER: ${POSTGRES_USER:-admin}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-maddog}
PGDATA: "/var/lib/postgresql/data/pgdata"
volumes:
- ./data:/var/lib/postgresql/data
networks:
- db-net
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U admin -d db" ]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
deploy:
resources:
limits:
cpus: '1'
memory: 4G

pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-maddog}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- ./data/pgadmin:/var/lib/pgadmin
ports:
- ${PGADMIN_PORT:-5050}:80
depends_on:
- db
networks:
- db-net
restart: unless-stopped

adminer:
image: adminer
restart: unless-stopped
depends_on:
- db
ports:
- "5051:8080"
networks:
- db-net

elephants:
container_name: elephants
image: a002k/elephants
ports:
- "80:80"
depends_on:
- simple-spring-app
networks:
- db-net
restart: on-failure

simple-spring-app:
container_name: simple-spring-app
image: a002k/simple-spring-app
build:
context: .
ports:
- "8080:8080"
depends_on:
- db
networks:
- db-net
restart: on-failure
environment:
- WAIT_HOSTS=db:5432, pgadmin:80, adminer:8080, elephants:80
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/db
- SPRING_DATASOURCE_USERNAME=admin
- SPRING_DATASOURCE_PASSWORD=maddog
- SPRING_PROFILES_ACTIVE=production

networks:
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 0483f00

Please sign in to comment.