name: Build Platform
concurrency: 
    group: ${{ github.workflow }}-${{ github.ref }}
    cancel-in-progress: true

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 0 # required for jgit timestamp provider to work
    - uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
    - run: echo "::add-matcher::.github/matcher.json"
    - name: Build with Maven
      uses: GabrielBB/xvfb-action@v1
      with:
       run: >- 
        mvn
        --batch-mode
        --global-toolchains ${{ github.workspace }}/.github/toolchains.xml
        -Pbuild-individual-bundles
        -Pbree-libs
        -Papi-check
        -Dmaven.test.failure.ignore=true
        -Dcompare-version-with-baselines.skip=false
        -Dproject.build.sourceEncoding=UTF-8
        -Dorg.slf4j.simpleLogger.showDateTime=true 
        -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss.SSS
        -DtrimStackTrace=false
        -Dmaven.compiler.failOnWarning=true
        -T1C
        clean verify
    - name: Upload Test Results
      uses: actions/upload-artifact@v3
      if: ${{ matrix.os != 'windows-latest'}} # currently disabled because of https://github.com/actions/upload-artifact/issues/240
      with:
        name: test-results-${{ matrix.os }}
        if-no-files-found: error
        path: '**/target/surefire-reports/*.xml'

