Skip to content

Build and Test

Build and Test #304

Workflow file for this run

name: Build and Test
on:
push:
branches:
- 'main'
- 'renovate/*'
tags:
- 'v*' # For v1.0, v0.1.0, etc
pull_request:
branches:
- 'main'
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
concurrency:
group: ${{ format('{0}-{1}', github.job, github.ref) }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
java: [ 21 ]
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Cache Gradle Dependencies
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Common Setup
uses: ./.github/actions/common-setup
with:
java-version: ${{ matrix.java }}
- name: Retrieve Project Name
run: echo "PROJECT_NAME=$(${{github.workspace}}/gradlew -q printProjectName)" >> $GITHUB_OUTPUT
id: project_name
- name: Get Project Name
run: echo "PROJECT_NAME=${{steps.project_name.outputs.PROJECT_NAME}}" >> $GITHUB_ENV
- name: Build with Gradle
run: ./gradlew assemble publish --info
- name: Upload Build Results
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: Build Results (Java ${{ matrix.java }} on ${{ matrix.os }})
path: ${{ github.workspace }}/repo/
outputs:
project_name: ${{ steps.project_name.outputs.PROJECT_NAME }}
test:
name: Run unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [ 21 ]
needs:
- build
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Cache Gradle Dependencies
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Common Setup
uses: ./.github/actions/common-setup
with:
java-version: ${{ matrix.java }}
- name: Test with Gradle
run: ./gradlew assemble check --info
- name: Upload Test Results
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: Test Reports (Java ${{ matrix.java }} on ${{ matrix.os }})
path: ${{ github.workspace }}/build/reports/