Skip to content

Commit

Permalink
chore(gha): fix tests triggers (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmorano authored Jul 30, 2024
1 parent c4b4e71 commit 2ee5db1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ jobs:
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
fi
;;
push) # main branch should always trigger the job
push) # main and develop branches should always trigger the job
BRANCH_NAME=${GITHUB_REF#refs/heads/}
if [ "${BRANCH_NAME}" == "main" ]
if [[ "${BRANCH_NAME}" == "main" ]] \
|| [[ "${BRANCH_NAME}" == "develop" ]]
then
echo "SERVICE_CHANGED=true" | tee -a "$GITHUB_OUTPUT"
else
Expand All @@ -49,28 +50,28 @@ jobs:
esac
- name: Setup JDK 21
if: steps.metadata.outputs.SERVICE_CHANGED == true
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'corretto'
cache: gradle

- name: Run tests
if: steps.metadata.outputs.SERVICE_CHANGED == true
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
working-directory: ./backend-services/${{ matrix.service }}
run: ./gradlew test

- name: Generate JaCoCo Badge
if: steps.metadata.outputs.SERVICE_CHANGED == true
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
badges-directory: ./backend-services/${{ matrix.service }}/build/reports/jacoco/test/html/badges
jacoco-csv-file: ./backend-services/${{ matrix.service }}/build/reports/jacoco/test/jacocoTestReport.csv

- name: Log coverage percentage
if: steps.metadata.outputs.SERVICE_CHANGED == true
if: steps.metadata.outputs.SERVICE_CHANGED == 'true'
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
Expand Down

0 comments on commit 2ee5db1

Please sign in to comment.