name: github/style

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
permissions:  # added using https://github.com/step-security/secure-repo
  contents: read

jobs:
  style:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
    - name: Install dependencies
      run: |
        sudo apt install clang-format-11 codespell wget git python3-pip
        python3 -m pip install --upgrade pip
        pip install pipenv
        make setup-dev
        wget -P /tmp/ https://raw.githubusercontent.com/torvalds/linux/184b8f7f91ca7938c09533df83ce84817e682975/scripts/checkpatch.pl && chmod a+x /tmp/checkpatch.pl
        wget -P /tmp/ https://raw.githubusercontent.com/torvalds/linux/184b8f7f91ca7938c09533df83ce84817e682975/scripts/spelling.txt
        wget -P /tmp/ https://raw.githubusercontent.com/torvalds/linux/184b8f7f91ca7938c09533df83ce84817e682975/scripts/const_structs.checkpatch
    - name: Style check
      run: |
        make style CLANGFORMAT=clang-format-11 CHECKPATCH=/tmp/checkpatch.pl
