name: CI

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          submodules: true

      - name: Install build dependencies
        run: >-
          sudo apt-get update && sudo apt-get install -y build-essential cmake ninja-build pkg-config
          ncurses-dev libreadline-dev libedit-dev
          libgoogle-perftools-dev libunwind-dev
          libgmp-dev
          libssl-dev
          unixodbc-dev
          zlib1g-dev libarchive-dev
          libossp-uuid-dev
          libxext-dev libice-dev libjpeg-dev libxinerama-dev libxft-dev
          libxpm-dev libxt-dev
          libdb-dev
          libpcre2-dev
          libyaml-dev
          default-jdk junit4

      - name: Configure project
        run: cmake -B build -G Ninja

      - name: Build project
        run: cmake --build build

      - name: Run tests
        run: cmake --build build --target test
        env:
          CTEST_PARALLEL_LEVEL: 4
          CTEST_OUTPUT_ON_FAILURE: y
