From 786ec55c203b16a899b69f175313dedcb2c3cd8e Mon Sep 17 00:00:00 2001 From: Luis Date: Wed, 11 Jun 2025 17:35:06 -0300 Subject: [PATCH 1/3] Add GitHub workflows for PR and master builds --- .github/workflows/merged_master.yml | 19 +++++++++++++++++++ .github/workflows/pull_request.yml | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/merged_master.yml create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/merged_master.yml b/.github/workflows/merged_master.yml new file mode 100644 index 0000000..fbff78d --- /dev/null +++ b/.github/workflows/merged_master.yml @@ -0,0 +1,19 @@ +name: Master Merge Build + +on: + pull_request: + types: [closed] + +jobs: + build: + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Build and Test + run: ./mvnw -B verify diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..233631e --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,18 @@ +name: PR Build + +on: + pull_request: + branches: ['**'] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Build and Test + run: ./mvnw -B verify From 4b5d84270a3ea7c59f5a580fb8efccd6445e3b19 Mon Sep 17 00:00:00 2001 From: Luis Date: Wed, 11 Jun 2025 17:39:30 -0300 Subject: [PATCH 2/3] Update merged_master.yml --- .github/workflows/merged_master.yml | 48 +++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/.github/workflows/merged_master.yml b/.github/workflows/merged_master.yml index fbff78d..e3faa84 100644 --- a/.github/workflows/merged_master.yml +++ b/.github/workflows/merged_master.yml @@ -1,4 +1,4 @@ -name: Master Merge Build +name: maven build on: pull_request: @@ -6,14 +6,42 @@ on: jobs: build: - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master' + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' - - name: Build and Test - run: ./mvnw -B verify + - uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'zulu' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Generate JaCoCo Badge + uses: cicirello/jacoco-badge-generator@v2 + with: + generate-branches-badge: true + + - name: Log coverage percentage + run: | + echo "coverage = ${{ steps.jacoco.outputs.coverage }}" + echo "branch coverage = ${{ steps.jacoco.outputs.branches }}" + + - name: Commit the badge (if it changed) + run: | + if [[ `git status --porcelain` ]]; then + git config --global user.name 'Luis' + git config --global user.email 'lpenap@users.noreply.github.com' + git add -A + git commit -m "Autogenerated JaCoCo coverage badge" + git push + fi + + - name: Upload JaCoCo coverage report + uses: actions/upload-artifact@v4 + with: + name: jacoco-report + path: target/site/jacoco/ From faaaaadd93796b1795e768f603a9db02c5c9ef9e Mon Sep 17 00:00:00 2001 From: Luis Date: Wed, 11 Jun 2025 17:43:49 -0300 Subject: [PATCH 3/3] Add JaCoCo config for coverage badge generation in github action --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3f9bdd6..ae836ae 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ - report + generate-code-coverage-report test report