name: 32-bit Oracle

on:
  schedule:
  - cron:  '0 0 * * 0'
  workflow_dispatch:

jobs:
  trick_32bit_oracle:
    runs-on: ubuntu-latest
    container: docker://oraclelinux:8
    steps:
    - name: Add dnf repo
      run: dnf -y install epel-release && dnf -y update
    - name: Install other dependencies
      run: >
        dnf install -y tar bison clang clang-devel cmake diffutils
        expat-devel.i686 expat.i686 flex gcc gcc-c++ git glibc-devel.i686
        glibc.i686 glibc.x86_64 gsl-devel gsl-devel.i686 java-11-openjdk
        java-11-openjdk-devel libstdc++-devel libstdc++-devel.i686 libxml2-devel
        libxml2-devel.i686 llvm llvm-devel llvm-static make maven ncurses-devel
        ncurses-devel.i686 openmotif openmotif-devel perl perl-Digest-MD5
        python2-devel python3-devel python3-libs.i686 swig tar udunits2
        udunits2-devel wget which zip zlib-devel zlib-devel.i686
    - name: Symlink python
      run: |
        ln -s /lib/libpython3.6m.so.1.0 /lib/libpython3.6m.so
    - name: Install Udunits (32 bit)
      run: |
        cd /
        curl --retry 4 -O https://artifacts.unidata.ucar.edu/repository/downloads-udunits/current/udunits-2.2.28.tar.gz
        tar xfvz udunits-2.2.28.tar.gz
        rm -rf udunits-2.2.28.tar.gz
        cd udunits-2.2.28
        export CFLAGS="-m32"
        export CXXFLAGS="-m32"
        export MAKEFLAGS=-j`nproc`
        ./configure
        make
        make install
        cd /
        rm -rf udunit-2.2.28
    - name: Install GTest 
      run: |
        dnf config-manager --enable ol8_codeready_builder
        dnf install -y gtest-devel
    - name: Install GTest (32 bit)
      run: |
        wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz
        tar xfvz release-1.8.0.tar.gz
        cd googletest-release-1.8.0/googletest
        export CFLAGS="-m32"
        export CXXFLAGS="-m32"
        export MAKEFLAGS=-j`nproc`
        cmake .
        make
        make install
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Build Trick
      run: |
        export CFLAGS="-m32"
        export CXXFLAGS="-m32"
        export MAKEFLAGS=-j`nproc`
        export JAVA_HOME=$(dirname $(dirname $(readlink -f `which java`)))
        ./configure --without-hdf5 --enable-32bit
        make
    - name: Run tests
      run: |
        cd share/trick/trickops/
        python3 -m venv .venv && . .venv/bin/activate && pip3 install -r requirements.txt
        cd ../../../
        export CFLAGS="-m32"
        export CXXFLAGS="-m32"
        export MAKEFLAGS=-j`nproc`
        make test32
