name: compile_ubuntu

on: [push]

env:
  BUILD_TYPE: Release

permissions:
  contents: read

jobs:
  compile_latest:
    runs-on: ubuntu-24.04
    timeout-minutes: 30

    steps:
      - name: Checkout_git
        uses: actions/checkout@v4
        with:
          # We must fetch at least the immediate parents so that if this is
          # a pull request then we can checkout the head.
          fetch-depth: 15
      - name: install_packages
        run: |
             sudo apt-get update
             sudo apt-get install appstream cmake desktop-file-utils doxygen gettext gnuplot gnuplot-x11 graphviz libwxgtk3.2-dev libwxgtk-webview3.2-dev maxima maxima-share maxima-doc netcat-openbsd ninja-build pandoc xvfb at-spi2-core dpkg-dev po4a
      - name: configure
        run: |
             export CXXFLAGS="-Wall -Wextra -ansi"
             export LANG=en_US.UTF-8
             mkdir build
             touch build build/build.ninja
             cd build
             cmake -G "Ninja" -DCMAKE_BUILD_TYPE=debug -DWXM_UNIT_TESTS=YES ..
             cd ..
      - name: compile
        run: |
             cd build
             cmake --build .
             cd ..
      - name: git-diff
        # run git diff to see, if the configure/build process has changed the source files (po4a can do that)
        run: git diff --compact-summary
      - name: update-locale
        run: |
             cd build
             cmake --build . --target update-locale
             cd ..
      - name: create_packages
        run: |
             cd build
             cmake --build . --target package
             cd ..
      - name: run_tests
        run: |
             cd build
             export HOME=`pwd`
             export CTEST_OUTPUT_ON_FAILURE=1
             GDK_BACKEND=x11 xvfb-run -a ctest -j 1
             cd ..

  compile_without_webview:
    runs-on: ubuntu-24.04
    timeout-minutes: 30

    steps:
      - name: Checkout_git
        uses: actions/checkout@v4
        with:
          # We must fetch at least the immediate parents so that if this is
          # a pull request then we can checkout the head.
          fetch-depth: 15
      - name: install_packages
        run: |
             sudo apt-get update
             sudo apt-get install appstream cmake desktop-file-utils doxygen gettext gnuplot gnuplot-x11 graphviz libwxgtk3.2-dev maxima maxima-share maxima-doc netcat-openbsd ninja-build pandoc xvfb at-spi2-core po4a
      - name: configure
        run: |
             export CXXFLAGS="-Wall -Wextra -ansi"
             export LANG=en_US.UTF-8
             mkdir build
             touch build build/build.ninja
             cd build
             cmake -G "Ninja" -DCMAKE_BUILD_TYPE=debug -DWXM_UNIT_TESTS=YES -DWXM_DISABLE_WEBVIEW=ON ..
             cd ..
      - name: compile
        run: |
             cd build
             cmake --build .
             cd ..
      - name: update-locale
        run: |
             cd build
             cmake --build . --target update-locale
             cd ..
      - name: run_tests
        run: |
             cd build
             export HOME=`pwd`
             export CTEST_OUTPUT_ON_FAILURE=1
             GDK_BACKEND=x11 xvfb-run -a ctest -j 1
             cd ..

  compile_2004:
    runs-on: ubuntu-20.04
    timeout-minutes: 30

    steps:
      - name: Checkout_git
        uses: actions/checkout@v4
        with:
          # We must fetch at least the immediate parents so that if this is
          # a pull request then we can checkout the head.
          fetch-depth: 15
      - name: install_packages
        run: |
             sudo apt-get update
             sudo apt-get install cmake gettext libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev pandoc make po4a
      - name: configure
        run: |
             export CXXFLAGS="-Wall -Wextra"
             export LANG=en_US.UTF-8
             mkdir build
             cd build
             cmake ..
             cd ..
      - name: compile
        run: |
             cd build
             cmake --build .
             cd ..
      - name: git-diff
        # run git diff to see, if the configure/build process has changed the source files (po4a can do that)
        run: git diff --compact-summary

