name: CI
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
jobs:
  build-clang:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v2
    - name: apt-get
      run: sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install build-essential libstdc++-10-dev cmake clang libssl-dev zlib1g-dev libxxhash-dev libtbb-dev git bsdmainutils dwarfdump libc6-dev:i386 lib32gcc-10-dev libstdc++-10-dev-arm64-cross gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1
    - name: make
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
        make CC=clang CXX=clang++ DEBUG=1 -j$(nproc)
    - name: make test
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
        make test -j$(nproc)
  build-gcc11:
    runs-on: ubuntu-20.04
    container: gcc:11.1.0
    steps:
    - uses: actions/checkout@v2
    - name: apt-get
      run: dpkg --add-architecture i386 && apt-get update && apt-get install -y sudo libssl-dev zlib1g-dev libxxhash-dev cmake clang dwarfdump bsdextrautils libgcc-9-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev:i386 lib32gcc-10-dev qemu-user
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1
    - name: make
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
        make CC=gcc CXX=g++ DEBUG=1 -j$(nproc)
    - name: make test
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
        make test -j$(nproc)
  build-macos:
    runs-on: macos-11
    steps:
    - uses: actions/checkout@v2
    - name: brew
      run: brew install xxhash
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1
    - name: make
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
        make DEBUG=1 -j$(sysctl -n hw.logicalcpu)
    - name: make test
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
        make test -j$(sysctl -n hw.logicalcpu)
