From 880ab7ed76077762b42a1464803511b750b73029 Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Mon, 17 Jun 2024 15:27:15 +0530 Subject: [PATCH] ci: add github action linters this commit add github action linters like golangci, codespell, markdownlint, misspell, govulncheck. Signed-off-by: subhamkrai --- .github/workflows/lint.yaml | 122 ++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..d721c052 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,122 @@ +name: Linter +on: + push: + tags: + - v* + branches: + - master + - release-* + pull_request: + branches: + - master + - release-* + +# cancel the in-progress workflow when PR is refreshed. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + codespell: + name: codespell + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: codespell + uses: codespell-project/actions-codespell@master + with: + # LICENSE: skip file because codespell wants to flag complies, which we may want to flag + # in other places, so ignore the file itself assuming it is correct + # crds.yaml, resources.yaml: CRD files are fully generated from content we control (should + # be flagged elsewhere) and content we don't control (can't fix easily), so ignore + skip: .git,*.png,*.jpg,*.svg,*.sum,./LICENSE,./deploy/examples/crds.yaml,./deploy/charts/rook-ceph/templates/resources.yaml + # aks: Amazon Kubernetes Service + # keyserver: flag to apt-key + # atleast: codespell wants to flag any 'AtLeast' method + # ser, ist: MIME types in pkg/operator/ceph/object/mime.go + # ba: daemon ID test in pkg/operator/k8sutil/name_test.go + # iam: Identity and Access Management, e.g., AWS IAM + # te: udev persistent naming test in pkg/daemon/ceph/osd/daemon_test.go + # parm: modinfo parameter + # assigment: inherited from K8s TopologySpreadConstraints dependency + # ro, RO: means read-only + ignore_words_list: aks,keyserver,atleast,ser,ist,ba,iam,te,parm,assigment,ro,RO,addin,NotIn + check_filenames: true + check_hidden: true + misspell: + name: misspell + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: misspell + uses: reviewdog/action-misspell@v1 + + golangci: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: "1.21" + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.55 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + args: --config=.golangci.yml + + # actions/setup-go already handles caching + skip-cache: true + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + govulncheck: + name: govulncheck + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - name: govulncheck + uses: golang/govulncheck-action@v1 + + + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: warning + check_together: 'yes' + disable_matcher: false + additional_files: build/reset build/sed-in-place + ignore: olm + format: gcc + + markdownlint: + name: markdownlint + runs-on: ubuntu-latest + steps: + - uses: DavidAnson/markdownlint-cli2-action@v16 + with: + globs: '**/*.md'