name: Compiler - Compliance

on:
  workflow_call:
  workflow_dispatch:

jobs:
  FormattingAndLinting:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3
      - name: Format with clang-format (Cpp)
        run: |
          sudo apt install moreutils
          cd compilers/concrete-compiler/compiler
          ./scripts/format_cpp.sh
      - name: Format with cmake-format (Cmake)
        run: |
          pip3 install cmakelang
          cd compilers/concrete-compiler/compiler
          ./scripts/format_cmake.sh
      - name: Format with black (Python)
        run: |
          cd compilers/concrete-compiler/compiler
          pip install -r lib/Bindings/Python/requirements_dev.txt
          make check-python-format
      - name: Lint with pylint (Python)
        run: |
          cd compilers/concrete-compiler/compiler
          # compiler requirements to lint
          pip install numpy
          make python-lint
      - name: Format with rustfmt (Rust)
        run: |
          cd compilers/concrete-compiler/compiler
          make check-rust-format

  CheckLicense:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3
      - name: Check if sources include the license header
        run: .github/workflows/scripts/check_for_license.sh
