This repository was archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
chore: add build infrastructure and linting #2
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
# See https://golangci-lint.run/usage/configuration/ | ||
# Over time we should try tightening some of these. | ||
|
||
linters-settings: | ||
goimports: | ||
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr | ||
gomodguard: | ||
blocked: | ||
modules: | ||
- k8s.io/kubernetes: | ||
recommendations: | ||
- k8s.io/api | ||
- k8s.io/apimachinery | ||
- k8s.io/client-go | ||
- k8s.io/metrics | ||
- k8s.io/utils | ||
reason: >- | ||
Upstream does not support using k8s.io/kubernetes as a library, | ||
which can cause issues when upgrading. For more information, see | ||
https://github.com/kubernetes/kubernetes/issues/90358#issuecomment-617859364 | ||
versions: | ||
# Enforce that the we follow the Kubernetes version support strategy | ||
- k8s.io/api: | ||
version: "< 0.19 || > 0.20" | ||
reason: >- | ||
Coder commits to supporting the newest patch release of the | ||
two prior minor releases and current release. For details, see | ||
https://www.notion.so/Kubernetes-version-support-strategy-82ecd5c9761e411e9dab61a7a1484418 | ||
- k8s.io/apimachinery: | ||
version: "< 0.19 || > 0.20" | ||
reason: >- | ||
Coder commits to supporting the newest patch release of the | ||
two prior minor releases and current release. For details, see | ||
https://www.notion.so/Kubernetes-version-support-strategy-82ecd5c9761e411e9dab61a7a1484418 | ||
- k8s.io/client-go: | ||
version: "< 0.19 || > 0.20" | ||
reason: >- | ||
Coder commits to supporting the newest patch release of the | ||
two prior minor releases and current release. For details, see | ||
https://www.notion.so/Kubernetes-version-support-strategy-82ecd5c9761e411e9dab61a7a1484418 | ||
- k8s.io/metrics: | ||
version: "< 0.19 || > 0.20" | ||
reason: >- | ||
Coder commits to supporting the newest patch release of the | ||
two prior minor releases and current release. For details, see | ||
https://www.notion.so/Kubernetes-version-support-strategy-82ecd5c9761e411e9dab61a7a1484418 | ||
local_replace_directives: true | ||
importas: | ||
# For the most part, these come from come from k8s.io/client-go, | ||
# particularly clientset.go. Even the official Kubernetes codebase | ||
# has conflicts, though. | ||
admissionregistrationv1: k8s.io/client-go/kubernetes/typed/admissionregistration/v1 | ||
admissionregistrationv1beta1: k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1 | ||
appsv1: k8s.io/client-go/kubernetes/typed/apps/v1 | ||
appsv1beta1: k8s.io/client-go/kubernetes/typed/apps/v1beta1 | ||
appsv1beta2: k8s.io/client-go/kubernetes/typed/apps/v1beta2 | ||
authenticationv1: k8s.io/client-go/kubernetes/typed/authentication/v1 | ||
authenticationv1beta1: k8s.io/client-go/kubernetes/typed/authentication/v1beta1 | ||
authorizationv1: k8s.io/client-go/kubernetes/typed/authorization/v1 | ||
authorizationv1beta1: k8s.io/client-go/kubernetes/typed/authorization/v1beta1 | ||
autoscalingv1: k8s.io/client-go/kubernetes/typed/autoscaling/v1 | ||
autoscalingv2beta1: k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1 | ||
autoscalingv2beta2: k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2 | ||
batchv1: k8s.io/client-go/kubernetes/typed/batch/v1 | ||
batchv1beta1: k8s.io/client-go/kubernetes/typed/batch/v1beta1 | ||
certificatesv1: k8s.io/client-go/kubernetes/typed/certificates/v1 | ||
certificatesv1beta1: k8s.io/client-go/kubernetes/typed/certificates/v1beta1 | ||
coordinationv1: k8s.io/client-go/kubernetes/typed/coordination/v1 | ||
coordinationv1beta1: k8s.io/client-go/kubernetes/typed/coordination/v1beta1 | ||
corev1: k8s.io/api/core/v1 | ||
discovery: k8s.io/client-go/discovery | ||
discoveryv1: k8s.io/client-go/kubernetes/typed/discovery/v1 | ||
discoveryv1beta1: k8s.io/client-go/kubernetes/typed/discovery/v1beta1 | ||
eventsv1: k8s.io/client-go/kubernetes/typed/events/v1 | ||
eventsv1beta1: k8s.io/client-go/kubernetes/typed/events/v1beta1 | ||
extensionsv1beta1: k8s.io/client-go/kubernetes/typed/extensions/v1beta1 | ||
flowcontrol: k8s.io/client-go/util/flowcontrol | ||
flowcontrolv1alpha1: k8s.io/client-go/kubernetes/typed/flowcontrol/v1alpha1 | ||
flowcontrolv1beta1: k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1 | ||
internalv1alpha1: k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1 | ||
metav1: k8s.io/apimachinery/pkg/apis/meta/v1 | ||
networkingv1: k8s.io/client-go/kubernetes/typed/networking/v1 | ||
networkingv1beta1: k8s.io/client-go/kubernetes/typed/networking/v1beta1 | ||
nodev1: k8s.io/client-go/kubernetes/typed/node/v1 | ||
nodev1alpha1: k8s.io/client-go/kubernetes/typed/node/v1alpha1 | ||
nodev1beta1: k8s.io/client-go/kubernetes/typed/node/v1beta1 | ||
policyv1: k8s.io/client-go/kubernetes/typed/policy/v1 | ||
policyv1beta1: k8s.io/client-go/kubernetes/typed/policy/v1beta1 | ||
rbacv1: k8s.io/client-go/kubernetes/typed/rbac/v1 | ||
rbacv1alpha1: k8s.io/client-go/kubernetes/typed/rbac/v1alpha1 | ||
rbacv1beta1: k8s.io/client-go/kubernetes/typed/rbac/v1beta1 | ||
rest: k8s.io/client-go/rest | ||
schedulingv1: k8s.io/client-go/kubernetes/typed/scheduling/v1 | ||
schedulingv1alpha1: k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1 | ||
schedulingv1beta1: k8s.io/client-go/kubernetes/typed/scheduling/v1beta1 | ||
storagev1: k8s.io/client-go/kubernetes/typed/storage/v1 | ||
storagev1alpha1: k8s.io/client-go/kubernetes/typed/storage/v1alpha1 | ||
storagev1beta1: k8s.io/client-go/kubernetes/typed/storage/v1beta1 | ||
typedcorev1: k8s.io/client-go/kubernetes/typed/core/v1 | ||
revive: | ||
# see https://github.com/mgechev/revive#available-rules for details. | ||
ignore-generated-header: true | ||
severity: warning | ||
rules: | ||
- name: atomic | ||
- name: bare-return | ||
- name: blank-imports | ||
- name: bool-literal-in-expr | ||
- name: call-to-gc | ||
- name: confusing-naming | ||
- name: confusing-results | ||
- name: constant-logical-expr | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: deep-exit | ||
- name: defer | ||
- name: dot-imports | ||
- name: duplicated-imports | ||
- name: early-return | ||
- name: empty-block | ||
- name: empty-lines | ||
- name: error-naming | ||
- name: error-return | ||
- name: error-strings | ||
- name: errorf | ||
- name: exported | ||
- name: flag-parameter | ||
- name: get-return | ||
- name: identical-branches | ||
- name: if-return | ||
- name: import-shadowing | ||
- name: increment-decrement | ||
- name: indent-error-flow | ||
- name: modifies-parameter | ||
- name: modifies-value-receiver | ||
- name: package-comments | ||
- name: range | ||
- name: range-val-address | ||
- name: range-val-in-closure | ||
- name: receiver-naming | ||
- name: redefines-builtin-id | ||
- name: string-of-int | ||
- name: struct-tag | ||
- name: superfluous-else | ||
- name: time-naming | ||
- name: unconditional-recursion | ||
- name: unexported-naming | ||
- name: unexported-return | ||
- name: unhandled-error | ||
- name: unnecessary-stmt | ||
- name: unreachable-code | ||
- name: unused-parameter | ||
- name: unused-receiver | ||
- name: var-declaration | ||
- name: var-naming | ||
- name: waitgroup-by-value | ||
|
||
issues: | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
# We use assertions rather than explicitly checking errors in tests | ||
- errcheck | ||
|
||
fix: true | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
|
||
run: | ||
timeout: 5m | ||
|
||
# Over time, add more and more linters from | ||
# https://golangci-lint.run/usage/linters/ as the code improves. | ||
linters: | ||
disable-all: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is greenfield, why not enable all linters? |
||
enable: | ||
- bodyclose | ||
- deadcode | ||
- dogsled | ||
- errcheck | ||
- errorlint | ||
- exportloopref | ||
- forcetypeassert | ||
- gocyclo | ||
- goimports | ||
- gomodguard | ||
- gosec | ||
- gosimple | ||
- govet | ||
- importas | ||
- ineffassign | ||
- makezero | ||
- noctx | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- staticcheck | ||
- structcheck | ||
- typecheck | ||
- unconvert | ||
- unused | ||
- varcheck | ||
- wastedassign |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
PROJECT_ROOT := $(shell git rev-parse --show-toplevel) | ||
GO_FILES := $(shell $(PROJECT_ROOT)/scripts/depfind/go.sh) | ||
|
||
fmt/go: | ||
# Skip this step in CI, golangci-lint will check formatting | ||
ifndef CI | ||
@echo "--- goimports" | ||
git ls-files '*.go' | xargs -I % -n 16 -P 16 goimports -w -local=coder.com,cdr.dev,go.coder.com,github.com/cdr | ||
endif | ||
.PHONY: fmt/go | ||
|
||
fmt: fmt/go | ||
.PHONY: fmt | ||
|
||
lint/go: lint/golangci-lint | ||
.PHONY: lint/go | ||
|
||
lint/golangci-lint: | ||
@echo "--- golangci-lint" | ||
golangci-lint run | ||
.PHONY: lint/golangci-lint | ||
|
||
lint/shellcheck: $(shell scripts/depfind/sh.sh) | ||
@echo "--- shellcheck" | ||
shellcheck $^ | ||
.PHONY: lint/shellcheck | ||
|
||
lint: lint/go lint/shellcheck | ||
.PHONY: lint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
builtin set -euo pipefail | ||
PROJECT_ROOT="$(git rev-parse --show-toplevel)" | ||
|
||
builtin pushd "$PROJECT_ROOT" > /dev/null | ||
git ls-files --full-name -- \ | ||
'*.go' \ | ||
'*.sum' | \ | ||
xargs -IX echo "$PROJECT_ROOT/X" | ||
builtin popd > /dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
builtin set -euo pipefail | ||
PROJECT_ROOT="$(git rev-parse --show-toplevel)" | ||
|
||
builtin pushd "$PROJECT_ROOT" > /dev/null | ||
git ls-files --full-name -- \ | ||
'.husky' \ | ||
'*.sh' | \ | ||
xargs -IX echo "$PROJECT_ROOT/X" | ||
builtin popd > /dev/null |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is neat!