• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Check formatting
2
3# Controls when the action will run.
4on:
5  push:
6    branches: [ main ]
7  pull_request:
8    branches: [ main ]
9
10  workflow_dispatch:
11
12jobs:
13  check_formatting:
14    runs-on: ubuntu-20.04
15
16    steps:
17      - uses: actions/checkout@v2
18
19      - name: Setup Go environment
20        uses: actions/setup-go@v2
21        with:
22          go-version: '^1.15.5'
23
24      - name: Install formatters
25        run: |
26          wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
27          sudo apt-get install software-properties-common
28          sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main'
29          sudo apt-get install clang-format-13
30          curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.42.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/bin/ktlint
31          go get -u github.com/google/addlicense
32          go get github.com/bazelbuild/buildtools/buildifier
33
34      - name: Run format.sh and print changes
35        run: |
36          ./format.sh
37          clang-format --version
38          git diff
39
40      - name: Check for changes
41        run: "[ $(git status --porcelain | wc -l) -eq 0 ]"
42