name: CI

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

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        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 libedit-dev
          libgoogle-perftools-dev
          libgmp-dev
          libssl-dev
          unixodbc-dev
          zlib1g-dev libarchive-dev
          libossp-uuid-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
