bld/.github/workflows/bld.yml
2026-06-25 15:53:14 -07:00

164 lines
4.6 KiB
YAML

name: bld-ci
on: [ push, pull_request, workflow_dispatch ]
env:
REPORTS_DIR: "build/test-results/test/"
DB_NAME: unittests
DB_USER: unittests
DB_PASSWORD: password
# Test flags for DB runs
DB_TEST_FLAGS: >-
-Dtest.postgres=true
-Dtest.mysql=true
-Dtest.mariadb=true
-Dtest.oracle=true
-Dtest.oracle-free=true
-DtestsBadgeUrl=https://rife2.com/tests-badge/update/com.uwyn.rife2/bld
-DtestsBadgeApiKey=${{ secrets.TESTS_BADGE_API_KEY }}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
java-version: [ 17, 22, 24, 26 ]
include:
- os: ubuntu-latest
run-db-tests: true
bld-cmd: ./bld
# Only ubuntu gets DB services
POSTGRES_IMAGE: "postgres:15"
MYSQL_IMAGE: "mysql:8"
MARIADB_IMAGE: "mariadb:10.9"
ORACLE_XE_IMAGE: "gvenzl/oracle-xe:18-slim"
ORACLE_FREE_IMAGE: "gvenzl/oracle-free:latest"
- os: macos-latest
run-db-tests: false
bld-cmd: ./bld
- os: windows-latest
run-db-tests: false
bld-cmd: .\bld.bat
# Only define services when run-db-tests is true
# GitHub skips this whole block if matrix doesn't define the images
services:
oracle:
image: ${{ matrix.ORACLE_XE_IMAGE }}
env:
ORACLE_RANDOM_PASSWORD: true
APP_USER: ${{ env.DB_USER }}
APP_USER_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 1521:1521
options: >-
--health-cmd healthcheck.sh
--health-interval 10s
--health-timeout 5s
--health-retries 10
oracle-free:
image: ${{ matrix.ORACLE_FREE_IMAGE }}
env:
ORACLE_RANDOM_PASSWORD: true
APP_USER: ${{ env.DB_USER }}
APP_USER_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 1522:1521
options: >-
--health-cmd healthcheck.sh
--health-interval 10s
--health-timeout 5s
--health-retries 10
mysql:
image: ${{ matrix.MYSQL_IMAGE }}
env:
MYSQL_DATABASE: ${{ env.DB_NAME }}
MYSQL_USER: ${{ env.DB_USER }}
MYSQL_PASSWORD: ${{ env.DB_PASSWORD }}
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
mariadb:
image: ${{ matrix.MARIADB_IMAGE }}
env:
MARIADB_DATABASE: ${{ env.DB_NAME }}
MARIADB_USER: ${{ env.DB_USER }}
MARIADB_PASSWORD: ${{ env.DB_PASSWORD }}
MARIADB_ROOT_PASSWORD: root
ports:
- 3307:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
postgres:
image: ${{ matrix.POSTGRES_IMAGE }}
env:
POSTGRES_DB: ${{ env.DB_NAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
POSTGRES_USER: ${{ env.DB_USER }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
MYSQL_DATABASE: ${{ env.DB_NAME }}
MYSQL_USER: root
MYSQL_PASSWORD: root
steps:
- name: Configure git line endings for Windows
if: runner.os == 'Windows'
run: git config --global core.autocrlf input
- name: Checkout source repository
uses: actions/checkout@v4
with:
clean: true
submodules: "true"
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: "corretto"
java-version: ${{ matrix.java-version }}
check-latest: true
- name: Cache bld dependencies
uses: actions/cache@v4
with:
path: lib
key: ${{ runner.os }}-bld-java${{ matrix.java-version }}-lib
- name: Compile source
run: ${{ matrix.bld-cmd }} clean compile
- name: Run tests
id: tests
run: >-
${{ matrix.bld-cmd }} test
--reports-dir=${{ env.REPORTS_DIR }}
${{ matrix.run-db-tests && env.DB_TEST_FLAGS || '' }}
- name: Run reporter
if: always() && steps.tests.outcome == 'failure'
run: ${{ matrix.bld-cmd }} --offline reporter --all