-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4157026
commit 99100db
Showing
68 changed files
with
2,033 additions
and
1,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: CI Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
distribution: [ 'temurin' ] | ||
java: [ '17' ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Java 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
distribution: ${{ matrix.distribution }} | ||
cache: 'maven' | ||
|
||
- name: Grant execute permission for mvnw | ||
run: chmod +x mvnw | ||
|
||
- name: Build with Maven | ||
run: ./mvnw clean verify | ||
|
||
- if: ${{ github.ref == 'refs/heads/main' }} | ||
name: SonarQube Scan | ||
run: ./mvnw compile sonar:sonar -Dsonar.login=${{ secrets.SONAR_TOKEN }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- if: ${{ github.ref == 'refs/heads/main' }} | ||
name: Build and Publish Docker Image | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
./mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=${{ secrets.DOCKER_USERNAME }}/boot-api-archunit-sample | ||
docker push ${{ secrets.DOCKER_USERNAME }}/boot-api-archunit-sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,7 @@ build/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Misc ### | ||
*.log | ||
.DS_Store |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"generator-springboot": { | ||
"appName": "boot-api-archunit-sample", | ||
"packageName": "com.example.archunit", | ||
"databaseType": "postgresql", | ||
"dbMigrationTool": "flywaydb", | ||
"features": [], | ||
"buildTool": "maven", | ||
"packageFolder": "com/example/archunit", | ||
"flywayMigrationCounter": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM eclipse-temurin:17.0.9_9-jre-focal as builder | ||
WORKDIR application | ||
ARG JAR_FILE=target/boot-api-archunit-sample-0.0.1-SNAPSHOT.jar | ||
COPY ${JAR_FILE} application.jar | ||
RUN java -Djarmode=layertools -jar application.jar extract | ||
|
||
# the second stage of our build will copy the extracted layers | ||
FROM eclipse-temurin:17.0.9_9-jre-focal | ||
WORKDIR application | ||
COPY --from=builder application/dependencies/ ./ | ||
COPY --from=builder application/spring-boot-loader/ ./ | ||
COPY --from=builder application/snapshot-dependencies/ ./ | ||
COPY --from=builder application/application/ ./ | ||
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pipeline { | ||
agent any | ||
|
||
triggers { | ||
pollSCM('* * * * *') | ||
} | ||
|
||
environment { | ||
APPLICATION_NAME = 'boot-api-archunit-sample' | ||
} | ||
|
||
stages { | ||
stage('Build') { | ||
steps { | ||
sh './mvnw clean verify' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,33 @@ | ||
# API Example for Archunit | ||
# boot-api-archunit-sample | ||
|
||
![](../images/ArchUnit-Logo.png) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
### Format code | ||
|
||
ArchUnit is a Java-based library that allows developers to create unit tests for the architecture of their code. It provides a set of rules and assertions that can be used to validate the architecture of the code, ensuring that it follows best practices and meets certain architectural requirements. This allows developers to catch potential issues early on in the development process and improve the overall quality and maintainability of the code. | ||
```shell | ||
$ ./mvnw spotless:apply | ||
``` | ||
|
||
ArchUnit Implementation in a Spring Boot Project, read [more](https://www.archunit.org/motivation) for understanding concept. | ||
### Run tests | ||
|
||
## Credits | ||
```shell | ||
$ ./mvnw clean verify | ||
``` | ||
|
||
Shamelessly copied from [api-example-archunit](https://github.com/andres-sacco/api-example-archunit) | ||
### Run locally | ||
|
||
The idea behind this API is to show some of all possibles rules that you can validate in one particular project. For more information about this library and how you can use it check his [page](https://sacco-andres.medium.com/) | ||
```shell | ||
$ docker-compose -f docker/docker-compose.yml up -d | ||
$ ./mvnw spring-boot:run -Dspring-boot.run.profiles=local | ||
``` | ||
|
||
## Technologies | ||
### Using Testcontainers at Development Time | ||
You can run `TestApplication.java` from your IDE directly. | ||
You can also run the application using Maven as follows: | ||
|
||
Here are some of technologies that I used to develop this example: | ||
```shell | ||
./mvnw spring-boot:test-run | ||
``` | ||
|
||
* Spring Boot - 3.0.0 | ||
* Archunit - 1.0.0 | ||
* Junit5 | ||
|
||
### Useful Links | ||
* Swagger UI: http://localhost:8080/swagger-ui.html | ||
* Actuator Endpoint: http://localhost:8080/actuator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: '3.8' | ||
services: | ||
|
||
boot-api-archunit-sample: | ||
build: .. | ||
ports: | ||
- "18080:8080" | ||
- "18787:8787" | ||
restart: always | ||
depends_on: | ||
- postgresqldb | ||
environment: | ||
- SPRING_PROFILES_ACTIVE=docker | ||
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver | ||
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgresqldb:5432/appdb | ||
- SPRING_DATASOURCE_USERNAME=appuser | ||
- SPRING_DATASOURCE_PASSWORD=secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3.8' | ||
services: | ||
|
||
postgresqldb: | ||
image: postgres:16.0-alpine | ||
environment: | ||
- POSTGRES_USER=appuser | ||
- POSTGRES_PASSWORD=secret | ||
- POSTGRES_DB=appdb | ||
ports: | ||
- "5432:5432" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.addLombokGeneratedAnnotation = true |
Oops, something went wrong.