name: ci

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
      # Checkout Repository
      - name: Checkout
        uses: actions/checkout@v2

      # Install Tools
      - name: Install Tools
        run: |
          sudo apt-get install wget build-essential python3 ninja-build
          sudo apt-get install verilator libevent-dev libjson-c-dev
          pip3 install setuptools
          pip3 install requests
          pip3 install pexpect
          pip3 install meson

      # Install (n)Migen / LiteX / Cores
      - name: Install LiteX
        run: |
          python3 litex_setup.py --config=full --init --install --user

      # Install GCC Toolchains
      - name: Install GCC Toolchains
        run: |
          python3 litex_setup.py --gcc=openrisc
          sudo mkdir /usr/local/openrisc
          sudo cp -r $PWD/../openrisc-*/* /usr/local/openrisc

      # Install Project
      - name: Install Project
        run: python3 setup.py develop --user

      # Test
      - name: Run Tests
        run: |
          export PATH=/usr/local/riscv/bin:$PATH
          export PATH=/usr/local/openrisc/bin:$PATH
          python3 -m unittest test.test_cpu.TestCPU.test_mor1kx
          python3 -m unittest test.test_cpu.TestCPU.test_marocchino