diff --git a/.github/workflows/merged_master.yml b/.github/workflows/merged_master.yml new file mode 100644 index 0000000..e3faa84 --- /dev/null +++ b/.github/workflows/merged_master.yml @@ -0,0 +1,47 @@ +name: maven build + +on: + pull_request: + types: [closed] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - 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/ 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 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