image: ubuntu:18.04
pipelines:
  pull-requests:
    '**':
      - step:
          script:
            - apt-get update
            - apt-get -y upgrade

            # Install Fast Downward dependencies.
            - apt-get -y install cmake g++ make mercurial python

            # Install dependencies for running code tests.
            - apt-get -y install clang-5.0 clang-tidy-5.0 python3 python-pip valgrind wget
            - pip install -U pyflakes pytest

            # Print information about environment.
            - g++ --version
            - python --version
            - python -c "import multiprocessing; print 'CPUs:', multiprocessing.cpu_count()"

            # Set up uncrustify.
            - wget https://github.com/uncrustify/uncrustify/archive/uncrustify-0.67.tar.gz
            - tar -xzvf uncrustify-0.67.tar.gz
            - cd uncrustify-uncrustify-0.67
            - mkdir build
            - cd build
            - cmake ../
            - make -j8
            - mv uncrustify ../../
            - cd ../../
            - rm -rf uncrustify-0.67.tar.gz uncrustify-uncrustify-0.67

            # Set up VAL.
            - apt-get -y install g++ git make flex bison
            - git clone https://github.com/KCL-Planning/VAL.git
            - cd VAL
            - git checkout a5565396007eee73ac36527fbf904142b3077c74
            - make clean  # Remove old build artifacts and binaries.
            - sed -i 's/-Werror //g' Makefile  # Ignore warnings.
            - make -j8
            - mv validate ../
            - cd ../
            - rm -rf VAL

            - export PATH="$(pwd):$PATH"  # Add uncrustify and VAL to PATH.
            - export CXXFLAGS="-Werror"  # Treat compilation warnings as errors.

            - ./misc/run-all-tests
