<commit_before>name: "Simulator"

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  test:
    name: Test
    runs-on: macos-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Installing tools on MacOS
    #  if: matrix.os == 'macOS-latest'
      run: brew install boost ninja

    - name: Build simulator
      run: |
        mkdir build
        cd build
        cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DCMAKE_BUILD_TYPE=Release -DENABLE_IPO=1
        ninja mipt-mips unit-tests mipt-v cachesim

    - name: Run
      working-directory: build
      run: |
        ./unit-tests
        ./mipt-mips -b ../tests/mips/mips-fib.bin -n 5000000 --mars
        ./mipt-v    -b ../tests/mips/mips-fib.bin -n 500000 --mars
        ./cachesim  -t ../tests/mem_trace.json -s 32768 -w 32

  profile:
    name: Profile
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Install Ninja
      run: sudo apt-get install ninja-build

    - name: Build simulator
      run: |
        mkdir build
        cd build
        CC=gcc-10 CXX=g++-10 cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DCMAKE_BUILD_TYPE=Release -DENABLE_IPO=1 -DENABLE_PROFILE=1
        ninja mipt-mips
        
    - name: Run
      working-directory: build
      run: ./mipt-mips -b ../tests/mips/mips-fib.bin -n 5000000 --mars

    - name: Dump profile
      working-directory: build
      run: gprof ./mipt-mips gmon.out -p | head -
        
  analyze:
    name: Analyze
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Initialize CodeQL
      uses: github/codeql-action/init@v1
      with:
        languages: 'cpp'

    - name: Install packages
      run: sudo apt-get install ninja-build clang++-10 clang-tidy-10

    - name: Build simulator
      run: |
        mkdir build
        cd build
        CC=clang-10 CXX=clang++-10 cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=1 -DENABLE_ASAN=0 -DENABLE_UBSAN=0
        ninja mipt-mips unit-tests
        
    - name: Run
      working-directory: build
      run: ./unit-tests

    - name: Codecov
      uses: codecov/codecov-action@v1.0.15
    
    - name: Clang-Tidy
      working-directory: build
      run: run-clang-tidy-10.py -header-filter='.*' 2> /dev/null

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v1

  gdb:
    name: GDB Integration
    runs-on: ubuntu-latest
    env:
      GDB_VER: gdb-10.1
      GDB_DIR: ${{ github.workspace }}/$GDB_VER

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Install packages
      run: sudo apt-get install ninja-build

    - name: Download GDB
      run: |
         mkdir gdb_build
         wget http://ftp.gnu.org/gnu/gdb/$GDB_VER.tar.gz
         tar -xzf $GDB_VER.tar.gz

    - name: Prepare GDB
      env:
        GDB_BUILD: ${{ github.workspace }}/gdb_build
      run: |
          cd $GDB_BUILD && ${{ github.workspace }}/$GDB_VER/configure --target=mipsel-unknown-linux --with-system-zlib --with-python=no
          cd $GDB_BUILD && make configure-gdb CFLAGS='-w -O0' CXXFLAGS='-w -O0' MAKEINFO=true > /dev/null
          cd $GDB_BUILD && mkdir opcodes      && cd opcodes      && ${{ github.workspace }}/$GDB_VER/opcodes/configure --target=mipsel-unknown-linux && make libopcodes.a
          cd $GDB_BUILD && mkdir libdecnumber && cd libdecnumber && ${{ github.workspace }}/$GDB_VER/libdecnumber/configure && make libdecnumber.a
          cd $GDB_BUILD && mkdir readline     && cd readline     && ${{ github.workspace }}/$GDB_VER/readline/configure && cd readline && make libreadline.a
          cd $GDB_BUILD && mkdir libctf       && cd libctf       && ${{ github.workspace }}/$GDB_VER/libctf/configure --with-system-zlib && make ctf-error.h && make libctf.la
          #                                                                                             w/a for GDB 10.1, remove once updated ^~~~~~~~~~~~~~~^

    - name: Build simulator
      run: |
        mkdir build
        cd build
        CC=gcc-10 CXX=g++-10 cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DGDB_SOURCE_PATH=../$GDB_VER -DGDB_BUILD_PATH=../gdb_build<commit_msg>Run tests on Ubuntu and Mac OS<commit_after>name: "Simulator"

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  test:
    name: Test
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.platform }}

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Installing tools on MacOS
      if: matrix.os == 'macos-latest'
      run: brew install boost ninja
    
    - name: Install tools on Ubuntu
      if: matrix.os == 'ubuntu-latest'
      run: sudo apt-get install ninja-build

    - name: Create CMake dir
      run: mkdir build

    - name: Build simulator
      working-directory: build
      run: |       
        cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DCMAKE_BUILD_TYPE=Release -DENABLE_IPO=1
        ninja mipt-mips unit-tests mipt-v cachesim

    - name: Unit tests
      working-directory: build
      run: ./unit-tests
  
    - name: Integration
      working-directory: build
      run:
        ./mipt-mips -b ../tests/mips/mips-fib.bin -n 5000000 --mars
        ./mipt-v    -b ../tests/mips/mips-fib.bin -n 500000 --mars
        ./cachesim  -t ../tests/mem_trace.json -s 32768 -w 32

  profile:
    name: Profile
    runs-on: ubuntu-latest
    needs: [test]
    env:
      CC: gcc-10
      CXX: g++-10
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Install Ninja
      run: sudo apt-get install ninja-build

    - name: Create CMake dir
      run: mkdir build

    - name: Build simulator
      working-directory: build
      run: |
        cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DCMAKE_BUILD_TYPE=Release -DENABLE_IPO=1 -DENABLE_PROFILE=1
        ninja mipt-mips
        
    - name: Run
      working-directory: build
      run: ./mipt-mips -b ../tests/mips/mips-fib.bin -n 5000000 --mars

    - name: Dump profile
      working-directory: build
      run: gprof ./mipt-mips gmon.out -p | head -
        
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    needs: [test]

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Initialize CodeQL
      uses: github/codeql-action/init@v1
      with:
        languages: 'cpp'

    - name: Install packages
      run: sudo apt-get install ninja-build clang++-10 clang-tidy-10

    - name: Create CMake dir
      run: mkdir build

    - name: Build simulator
      working-directory: build
      run: |
        CC=clang-10 CXX=clang++-10 cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=1 -DENABLE_ASAN=0 -DENABLE_UBSAN=0
        ninja unit-tests
        
    - name: Run
      working-directory: build
      run: ./unit-tests

    - name: Codecov
      uses: codecov/codecov-action@v1.0.15
    
    - name: Clang-Tidy
      working-directory: build
      run: run-clang-tidy-10.py -header-filter='.*' 2> /dev/null

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v1

  gdb:
    name: GDB Integration
    runs-on: ubuntu-latest
    needs: [test]
    env:
      CC: gcc-10
      CXX: g++-10
      GDB_VER: gdb-10.1
      GDB_DIR: ${{ github.workspace }}/$GDB_VER

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: 'true'

    - name: Install packages
      run: sudo apt-get install ninja-build

    - name: Create CMake dir
      run: mkdir build gdb_build

    - name: Download GDB
      run: |
         wget http://ftp.gnu.org/gnu/gdb/$GDB_VER.tar.gz
         tar -xzf $GDB_VER.tar.gz

    - name: Prepare GDB
      env:
        GDB_BUILD: ${{ github.workspace }}/gdb_build
      run: |
          cd $GDB_BUILD && ${{ github.workspace }}/$GDB_VER/configure --target=mipsel-unknown-linux --with-system-zlib --with-python=no
          cd $GDB_BUILD && make configure-gdb CFLAGS='-w -O0' CXXFLAGS='-w -O0' MAKEINFO=true > /dev/null
          cd $GDB_BUILD && mkdir opcodes      && cd opcodes      && ${{ github.workspace }}/$GDB_VER/opcodes/configure --target=mipsel-unknown-linux && make libopcodes.a
          cd $GDB_BUILD && mkdir libdecnumber && cd libdecnumber && ${{ github.workspace }}/$GDB_VER/libdecnumber/configure && make libdecnumber.a
          cd $GDB_BUILD && mkdir readline     && cd readline     && ${{ github.workspace }}/$GDB_VER/readline/configure && cd readline && make libreadline.a
          cd $GDB_BUILD && mkdir libctf       && cd libctf       && ${{ github.workspace }}/$GDB_VER/libctf/configure --with-system-zlib && make ctf-error.h && make libctf.la
          #                                                                                             w/a for GDB 10.1, remove once updated ^~~~~~~~~~~~~~~^

    - name: Build simulator
      working-directory: build
      run: |
        cd build
        cmake ../simulator -G Ninja -D Boost_INCLUDE_DIR=$BOOST_ROOT_1_72_0/include -DGDB_SOURCE_PATH=../$GDB_VER -DGDB_BUILD_PATH=../gdb_build
{'fraction_non_alphanumeric': 0.116716021648116, 'fraction_numerical': 0.01756356581231492, 'mean_word_length': 1.9905343511450382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5876134', 'n_tokens_mistral': 3551, 'n_tokens_neox': 3288, 'n_words': 788}