name: Make check

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

env:
  LIBLOUIS_VERSION: 3.21.0

jobs:
  build:
    name: Build with liblouis master

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: sudo apt-get update -qq && sudo apt-get install -y texinfo libxml2-dev libxml2 openjdk-8-jdk
    - name: Fetch and build liblouis
      run: |
        wget https://github.com/liblouis/liblouis/archive/master.tar.gz
        tar -xf master.tar.gz
        ( cd liblouis-* && ./autogen.sh && ./configure && make && sudo make install )
        sudo ldconfig
    - name: Autogen && configure
      run: |
        ./autogen.sh
        ./configure
    - name: make
      run: make
    - name: make check
      run: make check
    - name: Store the test suite log
      if: ${{ always() }} # store the test suite log even if the tests failed
      uses: actions/upload-artifact@v2
      with:
        name: test-suite-liblouis-master.log
        path: tests/test-suite.log

  build-stable:
    name: Build with liblouis stable

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: sudo apt-get update -qq && sudo apt-get install -y texinfo libxml2-dev libxml2 openjdk-8-jdk
    - name: Fetch and build liblouis
      run: |
        wget https://github.com/liblouis/liblouis/releases/download/v${LIBLOUIS_VERSION}/liblouis-${LIBLOUIS_VERSION}.tar.gz
        tar -xf liblouis-*.tar.gz
        ( cd liblouis-${LIBLOUIS_VERSION} && ./configure && make && sudo make install )
        sudo ldconfig
    - name: Autogen && configure
      run: |
        ./autogen.sh
        ./configure
    - name: make
      run: make
    - name: make check
      run: make check
    - name: Store the test suite log
      if: ${{ always() }} # store the test suite log even if the tests failed
      uses: actions/upload-artifact@v2
      with:
        name: test-suite-liblouis-stable.log
        path: tests/test-suite.log

