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

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 0 # required for jgit timestamp provider to work
    - name: checkout equinox.binaries
      uses: actions/checkout@v3
      with:
       fetch-depth: 1 # only shallow here, we don't have jgit timestamps
       repository: eclipse-equinox/equinox.binaries
       path: rt.equinox.binaries
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
    - name: Build with Maven
      uses: GabrielBB/xvfb-action@v1
      with:
       run: >- 
        mvn
        --batch-mode
        --global-toolchains ${{ github.workspace }}/.github/workflows/toolchains.xml
        --threads 1C
        -Pbuild-individual-bundles
        -Pbree-libs
        -Papi-check
        -Dcompare-version-with-baselines.skip=false
        -Dproject.build.sourceEncoding=UTF-8
        -Dmaven.test.failure.ignore=true
        -Drt.equinox.binaries.loc=${{ github.workspace }}/rt.equinox.binaries
        clean verify
    - name: Upload Test Results
      uses: actions/upload-artifact@v3
      with:
        name: test-results
        if-no-files-found: error
        path: '**/target/surefire-reports/*.xml'

