Add Java Code Sample in README.md #14
Workflow file for this run
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: Unit Tests for Bongabdo Library | |
# Trigger the workflow on pull request creation or push to main branch. | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Cache the JDK 17 | |
- name: Cache JDK 17 | |
uses: actions/cache@v3 | |
id: jdk-cache | |
with: | |
path: | | |
~/.sdkman/candidates/java | |
key: ${{ runner.os }}-jdk-17 | |
restore-keys: | | |
${{ runner.os }}-jdk- | |
# If JDK 17 is not found in cache, install it | |
- name: Set up JDK 17 | |
if: steps.jdk-cache.outputs.cache-hit != 'true' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
# Cache Gradle dependencies | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# Run unit tests only for the 'bongabdo' library module | |
- name: Run Bongabdo Unit Tests | |
run: ./gradlew :bongabdo:test | |
# Archive test results for inspection (optional) | |
- name: Archive test results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: bongabdo/build/test-results/test/ | |
# Publish test results to the pull request (optional) | |
- name: Publish Test Results | |
if: always() | |
uses: mikepenz/action-junit-report@v3 | |
with: | |
report_paths: '**/bongabdo/build/test-results/test/TEST-*.xml' | |
check_name: 'Unit Test Results for Bongabdo Library' | |
fail_on_failure: true |