name: TinyCC build

on:
  push:
    branches:
    - 'dev'
    - 'stable'
    - 'container-*'
  schedule:
    - cron: '0 18 * * 1,3,5' # Three-weekly at 18:00 UTC on Monday, Wednesday, and Friday
  pull_request:
    branches:
    - 'dev'
    - 'stable'
    - 'release-*'

jobs:
  build:
    name: ubuntu-tcc-test
    runs-on: ubuntu-latest
    steps:
    - name: Checkout TinyCC repository
      run: |
          git clone https://repo.or.cz/tinycc.git
          cd tinycc
          git checkout mob

    - name: Compiling and installing TinyCC
      working-directory: tinycc
      run: |
          ./configure --prefix=/usr
          make
          sudo make install

    - uses: actions/checkout@v2
      with:
          submodules: recursive
    - name: Checkout our Testsuite Binaries
      uses: actions/checkout@v2
      with:
          repository: rizinorg/rizin-testbins
          path: test/bins

    - name: Configure, build and install
      env:
          CC: tcc
      run: |
          ./configure --prefix=/usr --with-compiler=tcc
          make
          sudo make install

    - name: Install test dependencies
      run: |
          sudo apt-get --assume-yes install python3-wheel python3-setuptools
          python3 -m pip install --user 'git+https://github.com/rizinorg/rz-pipe#egg=rzpipe&subdirectory=python'

    - name: Run tests
      env:
        PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig
      run: |
        rizin -v
        rz-test -v
        cd test
        rz-test -L -o results.json || true
