Desafio casa do código do curso dev eficiente #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- master | |
- main | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
branches: | |
- master | |
- main | |
- develop | |
- 'release/*' | |
- 'hotfix/*' | |
jobs: | |
build_and_test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
issues: read | |
checks: write | |
pull-requests: write | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Java 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: 'temurin' | |
- name: Use Gradle Cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build and test with Gradle wrapper | |
run: | | |
chmod +x gradlew | |
./gradlew clean build test jacocoTestReport | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
check_name: Tests Results | |
junit_files: '**/build/test-results/**/*.xml' | |
strategy: replace | |
- name: Add coverage to PR | |
id: jacoco | |
uses: madrapps/jacoco-report@v1.6.1 | |
with: | |
paths: ${{ github.workspace }}/build/reports/jacoco/test/*.xml, | |
token: ${{ secrets.GITHUB_TOKEN }} | |
min-coverage-overall: 80 | |
min-coverage-changed-files: 80 | |
debug-mode: false | |
title: Code Coverage | |
update-comment: true | |
- name: Report Coverage Metrics | |
run: | | |
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}" | |
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}" |