From 40f13c2a13cafc7cbd0649d97a3c38e3db37ab1c Mon Sep 17 00:00:00 2001 From: Ngo Bao Date: Fri, 16 Jan 2026 13:29:26 -0600 Subject: [PATCH 1/4] Added code coverage pipeline --- .github/ISSUE_TEMPLATE/bug_report.md | 5 +++++ .github/ISSUE_TEMPLATE/dev_task.md | 4 ++++ .github/ISSUE_TEMPLATE/user_story.md | 1 + .github/workflows/code_coverage.yml | 16 ++++++++++++++++ .github/workflows/docker-build.yml | 2 +- .github/workflows/format.yml | 2 +- .github/workflows/gradle.yml | 2 +- .github/workflows/unit-testing.yml | 2 +- 8 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/code_coverage.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 6eae019e..3d23fc76 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,16 +7,21 @@ assignees: '' --- **Describe the bug** + A clear and concise description of what the bug is. **To Reproduce** + Steps to reproduce the behavior: **Expected behavior** + A clear and concise description of what you expected to happen. **Screenshots** + If applicable, add screenshots to help explain your problem. **Additional context** + Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/dev_task.md b/.github/ISSUE_TEMPLATE/dev_task.md index 26ebb3fd..d8515fe5 100644 --- a/.github/ISSUE_TEMPLATE/dev_task.md +++ b/.github/ISSUE_TEMPLATE/dev_task.md @@ -9,15 +9,19 @@ assignees: '' # Dev task **Description** + Briefly describe the feature or improvement. **Related user story:** Please include link to the related user story here. **Motivation** + Why is this useful? What problem does it solve? **Estimate** + The estimation of how long will this user story take. **Additional context** + Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/user_story.md b/.github/ISSUE_TEMPLATE/user_story.md index c58922ed..0a6b1ecd 100644 --- a/.github/ISSUE_TEMPLATE/user_story.md +++ b/.github/ISSUE_TEMPLATE/user_story.md @@ -9,6 +9,7 @@ assignees: '' # User story ## Description + Please describe the user story here. **Estimate:** The estimation of how long this user story takes. diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml new file mode 100644 index 00000000..4017fd04 --- /dev/null +++ b/.github/workflows/code_coverage.yml @@ -0,0 +1,16 @@ +name: Workflow for Codecov example-java-gradle +on: [push, pull_request] +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up JDK 18 + uses: actions/setup-java@v1 + with: + java-version: 18 + - name: Install dependencies, run tests, and collect coverage + run: gradle build + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 \ No newline at end of file diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 0752b9ef..ee1b8749 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -2,7 +2,7 @@ name: Build Docker Image on: push: - branches: [ "main" ] + branches: [ "main" , "dev" ] pull_request: jobs: diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 028c4b60..37975364 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -6,7 +6,7 @@ permissions: on: push: - branches: [ "main" ] + branches: [ "main" , "dev"] pull_request: jobs: diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 15fc1bc3..b812414b 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -2,7 +2,7 @@ name: Gradle Build on: push: - branches: [ "main" ] + branches: [ "main" , "dev" ] pull_request: jobs: diff --git a/.github/workflows/unit-testing.yml b/.github/workflows/unit-testing.yml index 66c95640..98aa6215 100644 --- a/.github/workflows/unit-testing.yml +++ b/.github/workflows/unit-testing.yml @@ -2,7 +2,7 @@ name: Unit test on: push: - branches: [ "main" ] + branches: [ "main" , "dev" ] pull_request: jobs: From 402c7f55bd8ce8142628ed5e9fabe9614b20a0bd Mon Sep 17 00:00:00 2001 From: Ngo Bao Date: Fri, 16 Jan 2026 13:42:55 -0600 Subject: [PATCH 2/4] Added ci to block feature branch to main --- .github/workflows/code_coverage.yml | 22 ++++++++++++++++++---- .github/workflows/dev-to-main-only.yml | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/dev-to-main-only.yml diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 4017fd04..94bdc377 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -1,16 +1,30 @@ name: Workflow for Codecov example-java-gradle -on: [push, pull_request] + +on: + push: + branches: [ "main" , "dev" ] + pull_request: + +permissions: + contents: read + pull-requests: write # 👈 REQUIRED for PR comments + jobs: run: runs-on: ubuntu-latest + steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Set up JDK 18 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: temurin java-version: 18 + - name: Install dependencies, run tests, and collect coverage run: gradle build + - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 \ No newline at end of file + uses: codecov/codecov-action@v3 diff --git a/.github/workflows/dev-to-main-only.yml b/.github/workflows/dev-to-main-only.yml new file mode 100644 index 00000000..cc05da1f --- /dev/null +++ b/.github/workflows/dev-to-main-only.yml @@ -0,0 +1,23 @@ + +name: Allow only dev to merge into main + +on: + pull_request: + branches: + - main + +jobs: + validate-source-branch: + runs-on: ubuntu-latest + steps: + - name: Check source branch + run: | + echo "Base branch: ${{ github.event.pull_request.base.ref }}" + echo "Head branch: ${{ github.event.pull_request.head.ref }}" + + if [ "${{ github.event.pull_request.head.ref }}" != "dev" ]; then + echo "Only dev branch is allowed to merge into main" + exit 1 + fi + + echo "dev branch detected, merge allowed" From 150aadc14c252fbaf26a60dfe51c060f03fc2574 Mon Sep 17 00:00:00 2001 From: Ngo Bao Date: Fri, 16 Jan 2026 14:05:30 -0600 Subject: [PATCH 3/4] Updated gradle --- .github/workflows/code_coverage.yml | 4 ++-- build.gradle | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 94bdc377..76402ad7 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -17,11 +17,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up JDK 18 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: temurin - java-version: 18 + java-version: 21 - name: Install dependencies, run tests, and collect coverage run: gradle build diff --git a/build.gradle b/build.gradle index 1c932c8a..92caa0bf 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '4.0.1' id 'io.spring.dependency-management' version '1.1.7' + id 'jacoco' } group = 'com.backend' @@ -26,4 +27,18 @@ dependencies { tasks.named('test') { useJUnitPlatform() + finalizedBy jacocoTestReport +} + +jacoco { + toolVersion = "0.8.11" +} + +jacocoTestReport { + dependsOn test + reports { + xml.required = true // 👈 REQUIRED for Codecov + html.required = true + csv.required = false + } } From 411784f37366a9ae552d371861ddc4b6b98bf128 Mon Sep 17 00:00:00 2001 From: Ngo Bao Date: Sat, 17 Jan 2026 13:34:59 -0600 Subject: [PATCH 4/4] updated --- .github/workflows/code_coverage.yml | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 76402ad7..4f46ca61 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -7,7 +7,7 @@ on: permissions: contents: read - pull-requests: write # 👈 REQUIRED for PR comments + pull-requests: write jobs: run: diff --git a/build.gradle b/build.gradle index 92caa0bf..3587cd24 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ jacoco { jacocoTestReport { dependsOn test reports { - xml.required = true // 👈 REQUIRED for Codecov + xml.required = true html.required = true csv.required = false }