From fee80d597153138551ec8c266f6bd42ae950b684 Mon Sep 17 00:00:00 2001 From: Paul Gilber Date: Wed, 1 Nov 2023 06:04:18 +0000 Subject: [PATCH 1/7] update pull request template --- .github/pull_request_template.md | 17 ++++++++++------- README.md | 13 +++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 401f816..ad2df8c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,11 +2,14 @@ Creating a pull request template for your repository https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository --> +Brief description of why this PR is necessary and/or what this PR solves. + +- Fixes [ISSUE #1] +- Fixes [ISSUE #2] + Checklist: -* [ ] The title of the PR states what changed and the related issues number (used for the release note). -* [ ] I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue. -* [ ] Does this PR require documentation updates? -* [ ] I've updated documentation as required by this PR. -* [ ] I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged. -* [ ] My build is green. -* [ ] I have added a brief description of why this PR is necessary and/or what this PR solves. +* [ ] The title of this PR states what changed and the related issues number (used for the release note). +* [ ] The description of this PR includes a brief description of why this PR is necessary and/or what this PR solves. +* [ ] The description of this PR includes "Fixes [ISSUE #]" to automatically close associated issues. +* [ ] The changes in this PR are accompanied by documentation. +* [ ] The changes in this PR include unit and/or e2e tests. PRs without these are unlikely to be merged. diff --git a/README.md b/README.md index 52d53b7..8950f14 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,19 @@ This project was forked from: [arjungautam1/fullstack-backend](https://github.co See [repository configuration](docs/repository-configuration/README.md) +## Features +1. Provides consistent development environment across users using [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers). See [configuration](.devcontainer/devcontainer.json) + +2. Uses [git pre-commit hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to prevent Workflow failures caused by trivial errors like linter errors. This [pre-commit hook](.githooks/pre-commit) is shared across users through [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) using [postCreateCommand.sh](.devcontainer/postCreateCommand.sh) which sets hooks path to `.githooks` +```sh +# .devcontainer/postCreateCommand.sh +git config core.hooksPath .githooks +``` + +3. Uses [Docker Compose](https://docs.docker.com/compose/) to enable local deployment of the `application` (demoapp-backend) including all `dependencies` (mysql). See [compose.yaml](deploy/docker-compose/compose.yaml) + +4. Provides sample [pull request checklist](.github/pull_request_template.md) + ## Dependencies 1. MySQL database instance From 454128e8fa9f06a084acf2cefefa5881ddeb7e79 Mon Sep 17 00:00:00 2001 From: Paul Gilber Date: Wed, 1 Nov 2023 06:12:05 +0000 Subject: [PATCH 2/7] add link to sample pull request --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8950f14..3c98726 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ git config core.hooksPath .githooks 3. Uses [Docker Compose](https://docs.docker.com/compose/) to enable local deployment of the `application` (demoapp-backend) including all `dependencies` (mysql). See [compose.yaml](deploy/docker-compose/compose.yaml) -4. Provides sample [pull request checklist](.github/pull_request_template.md) +4. Provides [pull request checklist](.github/pull_request_template.md). See [sample pull request](https://github.com/paul-gilber/demoapp-backend/pull/34) ## Dependencies 1. MySQL database instance From 8fd2ad0e13de6f7d9903f080f1bb19277459e1c9 Mon Sep 17 00:00:00 2001 From: Paul Gilber Date: Wed, 1 Nov 2023 06:16:41 +0000 Subject: [PATCH 3/7] document support for multi-platform image builds --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3c98726..b4d19c7 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ git config core.hooksPath .githooks 4. Provides [pull request checklist](.github/pull_request_template.md). See [sample pull request](https://github.com/paul-gilber/demoapp-backend/pull/34) +5. Supports multi-platform container image builds using [Docker buildx bake](https://docs.docker.com/build/bake/). See [docker-bake.hcl](docker-bake.hcl) + ## Dependencies 1. MySQL database instance From 2eb515770ee524e6f0cea3461543dbc23e385fc6 Mon Sep 17 00:00:00 2001 From: Paul Gilber Date: Wed, 1 Nov 2023 06:19:54 +0000 Subject: [PATCH 4/7] document container structure test --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b4d19c7..688e30e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ git config core.hooksPath .githooks 5. Supports multi-platform container image builds using [Docker buildx bake](https://docs.docker.com/build/bake/). See [docker-bake.hcl](docker-bake.hcl) +6. Uses [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) for running metadata, command and file existence tests to ensure consistency of image builds. See [container-structure-test.yaml](container-structure-test.yaml) + ## Dependencies 1. MySQL database instance From b0faf1c2145e832e7dc6ab4a5ea363f071a4ab9b Mon Sep 17 00:00:00 2001 From: Paul Gilber Date: Wed, 1 Nov 2023 06:26:29 +0000 Subject: [PATCH 5/7] high level description of github actions workflows application --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 688e30e..4e4d347 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ git config core.hooksPath .githooks 6. Uses [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) for running metadata, command and file existence tests to ensure consistency of image builds. See [container-structure-test.yaml](container-structure-test.yaml) +7. Uses [GitHub Actions workflows](https://docs.github.com/en/actions/using-workflows/about-workflows) for automating builds, scans, tests, publishing of [GitHub Packages](https://github.com/features/packages), automatic pull request labeling, and release drafting (and versioning) + ## Dependencies 1. MySQL database instance From 873d63b6ab7e96cc383cd87c00b7bcdf626fbb02 Mon Sep 17 00:00:00 2001 From: Paul Gilber Date: Wed, 1 Nov 2023 06:57:42 +0000 Subject: [PATCH 6/7] listed all github workflows --- README.md | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e4d347..c86831e 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,6 @@ See [repository configuration](docs/repository-configuration/README.md) 1. Provides consistent development environment across users using [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers). See [configuration](.devcontainer/devcontainer.json) 2. Uses [git pre-commit hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to prevent Workflow failures caused by trivial errors like linter errors. This [pre-commit hook](.githooks/pre-commit) is shared across users through [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) using [postCreateCommand.sh](.devcontainer/postCreateCommand.sh) which sets hooks path to `.githooks` -```sh -# .devcontainer/postCreateCommand.sh -git config core.hooksPath .githooks -``` 3. Uses [Docker Compose](https://docs.docker.com/compose/) to enable local deployment of the `application` (demoapp-backend) including all `dependencies` (mysql). See [compose.yaml](deploy/docker-compose/compose.yaml) @@ -22,6 +18,44 @@ git config core.hooksPath .githooks 7. Uses [GitHub Actions workflows](https://docs.github.com/en/actions/using-workflows/about-workflows) for automating builds, scans, tests, publishing of [GitHub Packages](https://github.com/features/packages), automatic pull request labeling, and release drafting (and versioning) +## GitHub Actions workflows +The following workflows are included in this project: + +1. [Build](.github/workflows/build.yml) +- Builds application container image and pushes it to [Docker Hub](https://hub.docker.com/) +- Tests application container image with [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) +- Scans application container image with [Aqua Security Trivy](https://trivy.dev/#:~:text=Trivy%20is%20the%20most%20popular,Apache%2D2.0%20License) + +2. [Coverage reports with CodeCov](.github/workflows/code-scan-codecov.yml) + +[Codecov](https://about.codecov.io/) is the all-in-one code coverage reporting solution for any test suite — giving developers actionable insights to deploy reliable code with confidence. Trusted by over 29,000 organizations. + +3. [Code Analysis with CodeQL](.github/workflows/code-scan-codecov.yml) + +[CodeQL](https://codeql.github.com/docs/codeql-overview/about-codeql/) is the analysis engine used by developers to automate security checks, and by security researchers to perform variant analysis. + +4. [Code Analysis with SonarCloud](.github/workflows/code-scan-sonarcloud.yml) + +[SonarCloud](https://docs.sonarcloud.io/) is a cloud-based code analysis service designed to detect coding issues. + +5. [Pull Request Labeler](.github/workflows/labeler.yml) + +Automatically label new pull requests based on the paths of files being changed. + +6. [Release Drafter](.github/workflows/release-drafter.yml) + +Drafts your next release notes as pull requests are merged into `main`. +Release drafter recommends release version based on [release-drafter.yml](.github/release-drafter.yml#L22) +See [sample releases](https://github.com/paul-gilber/demoapp-backend/releases). + +7. [Publish Container Image to GitHub Packages](.github/workflows/release.yml) +``` +To create a release: +1. Create pre-release from draft. A corresponding tag is created by this step e.g. `v1.0.0`. Workflow is triggered when a tag starting with `v` is created. +2. Workflow builds and publishes release image to GitHub packages +3. Set pre-release as latest version +``` + ## Dependencies 1. MySQL database instance From cfd80632dbd2ff3f1c0b713b5a3117c8bc897eb8 Mon Sep 17 00:00:00 2001 From: Paul Gilber Date: Wed, 1 Nov 2023 07:22:20 +0000 Subject: [PATCH 7/7] fix commands --- .devcontainer/compose.yaml | 1 + README.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.devcontainer/compose.yaml b/.devcontainer/compose.yaml index 4fd5d3b..72237ef 100644 --- a/.devcontainer/compose.yaml +++ b/.devcontainer/compose.yaml @@ -10,6 +10,7 @@ services: environment: # Enable Docker BuildKit https://docs.docker.com/build/buildkit/ DOCKER_BUILDKIT: '1' + DOCKER_REGISTRY_URL: '' # Required for Maven build # Externalized Spring Configuration: https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/boot-features-external-config.html # Connect to MySQL: mysql --host=mysql --user=$SPRING_DATASOURCE_USERNAME --password=$SPRING_DATASOURCE_PASSWORD demoapp SPRING_DATASOURCE_USERNAME: root diff --git a/README.md b/README.md index c86831e..80b49ec 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ docker build -f Containerfile.multistage -t demoapp-backend:latest . ## Run Application from Visual Studio Code Dev Container ### Run Application using Java ```sh -java -jar target/demoapp-backend-0.0.1-SNAPSHOT.jar +java -jar target/demoapp-backend-1.0.0-SNAPSHOT.jar ``` ### Run Application using Docker Compose [Compose](https://docs.docker.com/compose/) is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration. @@ -169,5 +169,5 @@ docker compose --project-directory deploy/docker-compose down # remove container Run below command to run [test](container-structure-test.yaml) for `demoapp-backend` ```sh -container-structure-test test --image demoapp-backend --config container-structure-test.yaml +container-structure-test test --image demoapp-backend:latest --config container-structure-test.yaml ```