Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add makefile lint target #5636

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ header:
- LICENSE
- NOTICE
- open_source_licenses.txt
- dashboard/src/setupProxy.js
- "**/*.css"
- "**/*.dccache"
- "**/*.html"
Expand Down
10 changes: 5 additions & 5 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
extends: default
ignore: |
# Ignore folders
chart/kubeapps/
integration/charts/simplechart/
dashboard/node_modules/
devel/
**/chart/kubeapps/
**/integration/charts/simplechart/
**/dashboard/node_modules/
**/devel/
# Ignore files
cmd/kubeapps-apis/plugins/fluxv2/packages/v1alpha1/testdata/charts/single-package-template.yaml
**/cmd/kubeapps-apis/plugins/fluxv2/packages/v1alpha1/testdata/charts/single-package-template.yaml
rules:
line-length: disable
comments: disable
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ fmt:
vet:
$(GO) vet $(GO_PACKAGES)

.PHONY: default all test-all test test-dashboard fmt vet
lint:
./script/linters/license-linter.sh
./script/linters/yaml-linter.sh
./script/linters/golang-linter.sh

.PHONY: default all test-all test test-dashboard fmt vet lint install-tools
14 changes: 14 additions & 0 deletions script/linters/golang-linter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Copyright 2022 the Kubeapps contributors.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

command -v golangci-lint > /dev/null 2>&1 || { echo "golangci-lint must be installed -> https://github.com/golangci/golangci-lint"; exit 1; }

PROJECT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null && pwd)
TIMEOUT="10m"

golangci-lint run --timeout=${TIMEOUT} "${PROJECT_DIR}/cmd/..."
golangci-lint run --timeout=${TIMEOUT} "${PROJECT_DIR}/pkg/..."
12 changes: 12 additions & 0 deletions script/linters/license-linter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Copyright 2022 the Kubeapps contributors.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

command -v license-eye > /dev/null 2>&1 || { echo "license-eye must be installed -> https://github.com/apache/skywalking-eyes"; exit 1; }

PROJECT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null && pwd)

license-eye -c "${PROJECT_DIR}/.licenserc.yaml" header check
14 changes: 14 additions & 0 deletions script/linters/yaml-linter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Copyright 2022 the Kubeapps contributors.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

command -v yamllint > /dev/null 2>&1 || { echo "yamllint must be installed -> https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint"; exit 1; }

PROJECT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null && pwd)

[ -f "${PROJECT_DIR}/.yamllint.yml" ] || exit 1;

yamllint -c "${PROJECT_DIR}/.yamllint.yml" "${PROJECT_DIR}"