name: Build

on:
  push:
    paths-ignore:
    - README.md
    - '**/*.md'
  pull_request:
  schedule:
  - cron: "0 0 * * 0"

jobs:
  build:
    name: ${{ matrix.os }} with Java 11
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
    - name: Checkout master branch
      uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Set up JDK 11
      uses: actions/setup-java@v1
      with:
        java-version: 11
    - name: Cache Maven packages
      uses: actions/cache@v2
      with:
        path: ~/.m2
        key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-m2
    - name: Checkout Universal ctags
      uses: actions/checkout@v2
      with:
        repository: universal-ctags/ctags
        path: ctags
    - name: Install pre-requisites (Unix)
      if: runner.os == 'Linux' || runner.os == 'macOS'
      run: ./dev/before_install
    - name: Install Universal ctags (Windows)
      if: runner.os == 'Windows'
      run: choco install universal-ctags
    - name: Before build actions (Unix)
      if: runner.os == 'Linux' || runner.os == 'macOS'
      run: ./dev/before
    - name: Maven build
      shell: bash
      env:
        OPENGROK_PULL_REQUEST: ${{ github.head_ref }}
        OPENGROK_REPO_SLUG: ${{ github.repository }}
        OPENGROK_REF: ${{ github.ref }}
        OPENGROK_COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
        OPENGROK_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: ./dev/main
