|
1 | 1 | # Java Demo App
|
2 | 2 |
|
3 |
| -**The App** |
| 3 | +## The App |
4 | 4 |
|
5 | 5 | This is a simple Sales Manager Java App that stores sales items in a table presented in a web app.
|
6 | 6 |
|
7 |
| -This demo repo is designed to help understand some of **CI/CD** (Continuous Integration/Continuous Delivery) principles and best practices. |
| 7 | +This demo repo is designed to help understand some of **CI/CD** ([Continuous Integration](https://docs.github.com/en/enterprise-cloud@latest/actions/automating-builds-and-tests/about-continuous-integration)/[Continuous Delivery](https://docs.github.com/en/enterprise-cloud@latest/actions/deployment/about-deployments/about-continuous-deployment)) principles and best practices. |
8 | 8 |
|
9 |
| -**The Settings** |
| 9 | +## The Setting |
10 | 10 |
|
11 | 11 | **Java** (Spring Boot framework) with **MVC** (Model View Controller) and **OOP** (Object Oriented Programming) design patterns.
|
| 12 | +Backend Database is Oracle XE 11g PDB (but can be used with other versions). |
12 | 13 |
|
13 | 14 | *CI/CD Pipeline*
|
14 | 15 | [GitHub Actions](https://docs.github.com/en/enterprise-cloud@latest/actions) as the main CI/CD pipeline orchestrator
|
15 | 16 |
|
16 | 17 | **Tools used to optimize the pipeline (See the `.github/workflows/ci.yml` for more detailed configuration).**
|
17 | 18 | - [Caching Dependencies to Speed Up Workflows](https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
|
18 |
| - - Reusing Docker Layer Caching from pervious docker builds with [action-docker-layer-caching](https://github.com/satackey/action-docker-layer-caching) or [build-push-action](https://github.com/docker/build-push-action) actions. |
19 |
| - - Using the [Metrix Strategy] to Run Unit Tests In Parallel(https://docs.github.com/en/enterprise-cloud@latest/actions/using-jobs/using-a-matrix-for-your-jobs) to scale-out resources and reduce significant testing time. |
| 19 | + - Reusing **Docker Layer Caching** from pervious docker builds with [action-docker-layer-caching](https://github.com/satackey/action-docker-layer-caching) or [build-push-action](https://github.com/docker/build-push-action) actions. |
| 20 | + - Using the [Metrix Strategy](https://docs.github.com/en/enterprise-cloud@latest/actions/using-jobs/using-a-matrix-for-your-jobs) to run unit tests in parallel to scale-out resources and reduce significant testing time. |
| 21 | + - Using the [Split Test Action](https://github.com/marketplace/actions/split-tests) to help splitting tests by previous testing time runs or line count (or other strategies) across multiple runners. |
| 22 | + - [GitHub Advanced Security](https://docs.github.com/en/enterprise-cloud@latest/get-started/learning-about-github/about-github-advanced-security) - Code Scanning using the [CodeQL analysis](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages) to scan for vulnerabilities. |
| 23 | + - [Liquibase Quality Checks](https://www.liquibase.com/quality-checks) - To help enforce Database schema changes best practices set by your DBA team, including naming conventions, grants & revokes, rollback scripts and security risks. |
20 | 24 |
|
21 | 25 | # CI/CD Diagram
|
22 | 26 | ```mermaid
|
@@ -49,27 +53,33 @@ stateDiagram
|
49 | 53 | ```
|
50 | 54 |
|
51 | 55 | *Building and Testing*
|
52 |
| - - [Maven](https://maven.apache.org/) as the project management for Building and Testing the application. |
53 |
| -The user input data from the app's view is stored in an Oracle (PDB) Database. |
54 |
| - |
| 56 | +[Maven](https://maven.apache.org/) is used as the project management for Building and Testing the application. |
| 57 | +To build the application, you can run: |
| 58 | +``` |
| 59 | +mvn clean package |
| 60 | +``` |
| 61 | +It will generate a JAR file in the `target` folder with the following format `salesmanager-x.x.x-SNAPSHOT.jar`. </br> |
| 62 | +To run the application, you can deploy the JAR file. For example: |
| 63 | +``` |
| 64 | +java -jar target/salesmanager-0.0.6-SNAPSHOT.jar |
| 65 | +``` |
55 | 66 |
|
56 | 67 | # How to Demo
|
57 |
| -For easy demos, an H2 database (Oracle Mode) is setup by default in the `src/main/resources/application.properties` file. </br> |
58 |
| -You can easily use a [GitHub codespaces](https://docs.github.com/en/enterprise-cloud@latest/codespaces) with this repository. </br> |
59 |
| -To set up your codespace, simply go to this repo [main page](https://github.com/octodemo/java-springboot-demo) --> Click **Code** --> Codespaces '+'. </br> |
| 68 | +For easy demos without the need to stand up an Oracle database, an lightweight local [H2 database](https://www.h2database.com/html/main.html) (Oracle Mode) is setup by default in the `src/main/resources/application.properties` file. </br> |
60 | 69 | You can run the `./build_and_run_app.sh` helper shell script and interact with the web app on `localhost:8086`.
|
| 70 | +> You can easily use a [GitHub codespaces](https://docs.github.com/en/enterprise-cloud@latest/codespaces) with this repository. To set up your codespace, simply go to this repo [main page](https://github.com/octodemo/java-springboot-demo) --> Click **Code** --> Codespaces '+'. </br> |
61 | 71 |
|
62 | 72 |
|
63 |
| -Running the CI workflow |
| 73 | +# Running the CI workflow |
64 | 74 | 1. In order to run the workflow, you will need to [fork](https://docs.github.com/en/enterprise-cloud@latest/get-started/quickstart/fork-a-repo) this repo. </br>
|
65 | 75 | 2. Then, make sure to save the following environment variables in your repository secrets so you can successfully run the Database schema mirgations scripts (using [Liquibase](https://www.liquibase.com/) as the schema migration tool) on application startup and when running the tests. </br>
|
66 | 76 |
|
67 |
| -Repository Secrets |
| 77 | +**Repository Secrets** |
68 | 78 | `LIQUIBASE_COMMAND_URL`
|
69 | 79 | `LIQUIBASE_COMMAND_USERNAME`
|
70 | 80 | `LIQUIBASE_COMMAND_PASSWORD`
|
71 | 81 |
|
72 |
| -If you are going to use the same [dockerised service container](https://hub.docker.com/r/gvenzl/oracle-xe) in the CI job for dev, then the default values should be: </br> |
| 82 | +### If you are going to use the same [dockerised service container](https://hub.docker.com/r/gvenzl/oracle-xe) in the CI job for dev, then the default values should be: </br> |
73 | 83 | `LIQUIBASE_COMMAND_URL` = `jdbc:oracle:thin:@oracle:1521/xe` </br>
|
74 | 84 | `LIQUIBASE_COMMAND_USERNAME` = `SYSTEM` </br>
|
75 | 85 | `LIQUIBASE_COMMAND_PASSWORD` = `ORACLE`
|
|
0 commit comments