name: Check formatting

# Controls when the action will run.
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  workflow_dispatch:

jobs:
  check_formatting:
    runs-on: ubuntu-20.04

    steps:
      - uses: actions/checkout@v3

      - name: Setup Go environment
        uses: actions/setup-go@v3
        with:
          go-version: '^1.15.5'

      - name: Install formatters
        run: |
          wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
          sudo apt-get install software-properties-common
          sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main'
          sudo apt-get install clang-format-13
          curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.42.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/bin/ktlint
          go install github.com/google/addlicense@latest
          go install github.com/bazelbuild/buildtools/buildifier@latest

      - name: Run format.sh and print changes
        run: |
          ./format.sh
          clang-format --version
          git diff

      - name: Check for changes
        run: "[ $(git status --porcelain | wc -l) -eq 0 ]"

name: Check formatting

# Controls when the action will run.
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  workflow_dispatch:

jobs:
  check_formatting:
    runs-on: ubuntu-20.04

    steps:
      - uses: actions/checkout@v3

      - name: Setup Go environment
        uses: actions/setup-go@v3
        with:
          go-version: '^1.19.2'

      - name: Install formatters
        run: |
          wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
          sudo apt-get install software-properties-common
          sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main'
          sudo apt-get install clang-format-13
          curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.42.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/bin/ktlint
          go install github.com/google/addlicense@latest
          go install github.com/bazelbuild/buildtools/buildifier@latest

      - name: Run format.sh and print changes
        run: |
          ./format.sh
          clang-format --version
          git diff

      - name: Check for changes
        run: "[ $(git status --porcelain | wc -l) -eq 0 ]"

Update Go version in format pipeline
ci: Update Go version in format pipeline
