name: ubuntu-build
on: [push, pull_request]
jobs:
  check-lines:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Check lines
      run: find "Content/" \( -iname \*.h -o -iname \*.java -o -iname \*.kt \) -exec python3 Scripts/CheckLines.py {} +
  compile-cpp:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        cpp-version: [c++11, c++14, c++17, c++20]
    steps:
    - uses: actions/checkout@v2
    - name: Check version
      run: |
        g++-10 --version
    - name: Replace pragma once
      run: find "Content/C++/" -name "*.h" -exec python3 Scripts/ReplacePragmas.py {} +
    - name: Compile
      run: find "Content/C++/" -name "*.h" -exec Scripts/Compile.sh "g++-10 -std=${{ matrix.cpp-version }} -Wall -Wextra -pedantic-errors -Werror -fsyntax-only" {} +
  compile-java:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        java-version: ['8', '11']
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-java@v1
      with:
        java-version: ${{ matrix.java-version }}
    - name: Check version
      run: javac -version
    - name: Compile
      run: find "Content/Java/" -name "*.java" -exec Scripts/Compile.sh javac {} +
  compile-kotlin:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: |
        sudo snap install --classic kotlin
        kotlinc -version
    - name: Compile
      run: find "Content/Kotlin/" -name "*.kt" -exec Scripts/Compile.sh kotlinc {} +
  fuzz-tests-cpp:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Check version
      run: |
        g++-10 --version
    - name: Replace pragma once
      run: find "Content/C++/" -name "*.h" -exec python3 Scripts/ReplacePragmas.py {} +
    - name: Run fuzz tests
      run: find "Tests/C++/" -name "*FuzzTest.cpp" -exec Scripts/RunCppTests.sh "g++-10 -std=c++11 -O2 -Wall -Wextra -pedantic-errors" {} +
  stress-tests-cpp:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Check version
      run: |
        g++-10 --version
    - name: Replace pragma once
      run: find "Content/C++/" -name "*.h" -exec python3 Scripts/ReplacePragmas.py {} +
    - name: Run stress tests
      run: find "Tests/C++/" -name "*StressTest.cpp" -exec Scripts/RunCppTests.sh "g++-10 -std=c++11 -O2 -Wall -Wextra -pedantic-errors" {} +
