Skip to content

Commit

Permalink
gha: split lint jobs into multiple workflows
Browse files Browse the repository at this point in the history
To allow for filtering/skipping of these using built-in syntax rather
than a 3rd-party action; the latter still requires to run the job.

Signed-off-by: Ivo Jimenez <ivo@redpanda.com>
  • Loading branch information
ivotron committed Nov 9, 2023
1 parent 35b9cc3 commit 67b4808
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 126 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/lint-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint cpp

on:
push:
branches:
- 'dev'
paths:
- '**.h'
- '**.cc'
- '**.cpp'
- '**.proto'
- '**.java'
tags-ignore:
- '**'
pull_request:
paths:
- '**.h'
- '**.cc'
- '**.cpp'
- '**.proto'
- '**.java'

jobs:
cpp:
name: Lint files with clang-format
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Run clang-format
run: |
docker run \
-v $PWD:/redpanda ubuntu \
bash -c "cd /redpanda && \
apt update && \
apt install -y wget git lsb-release wget software-properties-common gnupg && \
wget https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh 16 && \
apt-get install -y clang-format-16 && \
find . -type f -regex '.*\.\(cpp\|h\|hpp\|cc\|proto\|java\)' | xargs -n1 clang-format-16 -i -style=file -fallback-style=none"
git diff --exit-code
65 changes: 65 additions & 0 deletions .github/workflows/lint-golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Lint golang

on:
push:
branches:
- 'dev'
paths:
- 'src/go/**'
tags-ignore:
- '**'
pull_request:
paths:
- 'src/go/**'

jobs:
go:
name: Lint go files
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v3
with:
go-version: stable

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m
working-directory: src/go/rpk/

- name: Install gofumpt
env:
GOFUMPT_VER: 0.5.0
run: |
mkdir -v -p "$HOME/.local/bin"
wget -O "$HOME/.local/bin/gofumpt" "https://github.com/mvdan/gofumpt/releases/download/v${GOFUMPT_VER}/gofumpt_v${GOFUMPT_VER}_linux_amd64"
chmod 0700 "$HOME/.local/bin/gofumpt"
- name: Run gofumpt
run: |
find src/go -type f -not -name 'zz*' -name '*.go' | xargs -n1 "$HOME/.local/bin/gofumpt" -w -lang=1.20
git diff --exit-code
- name: go mod tidy (cluster-to-redpanda-migration)
working-directory: src/go/cluster-to-redpanda-migration
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum
- name: go mod tidy (k8s)
working-directory: src/go/k8s
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum
- name: go mod tidy (rpk)
working-directory: src/go/rpk
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum
28 changes: 28 additions & 0 deletions .github/workflows/lint-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint python

on:
push:
branches:
- 'dev'
paths:
- '**.py'
tags-ignore:
- '**'
pull_request:
paths:
- '**.py'

jobs:
py:
name: Lint python files
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Install yapf
run: pip install yapf==0.40.1

- name: Run yapf
run: find . -type f -name '*.py' | xargs -n8 yapf -d
33 changes: 33 additions & 0 deletions .github/workflows/lint-sh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint sh

on:
push:
branches:
- 'dev'
paths:
- '**.sh'
tags-ignore:
- '**'
pull_request:
paths:
- '**.sh'

jobs:
sh:
name: Lint shell scripts
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Install shfmt
env:
SHFMT_VER: 3.6.0
run: |
mkdir -v -p "$HOME/.local/bin"
wget -O "$HOME/.local/bin/shfmt" "https://github.com/mvdan/sh/releases/download/v${SHFMT_VER}/shfmt_v${SHFMT_VER}_linux_amd64"
chmod 0700 "$HOME/.local/bin/shfmt"
- name: Run shfmt
run: shfmt -i 2 -ci -s -d .
126 changes: 0 additions & 126 deletions .github/workflows/lint.yml

This file was deleted.

0 comments on commit 67b4808

Please sign in to comment.