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

feat(lint): add pre-commit linting setup #573

Closed
wants to merge 8 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 6 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't how YAML should start

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact it is, see section 2.2 of the YAML specification: https://yaml.org/spec/1.2.2/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only mandatory to have them if you use directives in the YAML document. Directives are optional for usage, please see section 3.2.3.4 of the YAML specification. Please see examples in section 6.8.1 to have a better understanding.

Copy link
Contributor Author

@rriski rriski Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed its not mandatory and we can choose to leave it out. But stating "this isn't how YAML should start" isn't constructive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can choose to leave it out

If we choose not to, then we also need to add directives. I think leaving it out is the best option, WDYT?

version: 2

updates:
- package-ecosystem: github-actions
directory: /
Expand All @@ -10,18 +12,10 @@ updates:
interval: daily
ignore:
- dependency-name: k8s.io/api
update-types:
- version-update:semver-major
- version-update:semver-minor
update-types: [version-update:semver-major, version-update:semver-minor]
- dependency-name: k8s.io/apimachinery
update-types:
- version-update:semver-major
- version-update:semver-minor
update-types: [version-update:semver-major, version-update:semver-minor]
- dependency-name: k8s.io/client-go
update-types:
- version-update:semver-major
- version-update:semver-minor
update-types: [version-update:semver-major, version-update:semver-minor]
- dependency-name: sigs.k8s.io/controller-runtime
update-types:
- version-update:semver-major
- version-update:semver-minor
update-types: [version-update:semver-major, version-update:semver-minor]
1 change: 1 addition & 0 deletions .github/sync.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
aiven/aiven-charts:
- source: charts/aiven-operator/
dest: charts/aiven-operator/
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/force-sync-charts.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: force sync charts

on:
Expand All @@ -12,4 +13,4 @@ jobs:
- uses: BetaHuhn/repo-file-sync-action@v1
with:
GH_PAT: ${{ secrets.AIVEN_CI_PAT__VALID_WHILE_ALEKS_IS_EMPLOYED }}
COMMIT_PREFIX: "chore:"
COMMIT_PREFIX: 'chore:'
3 changes: 2 additions & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: generate files

on:
Expand Down Expand Up @@ -25,4 +26,4 @@ jobs:
run: make generate
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore(userconfigs): generate files"
commit_message: 'chore(userconfigs): generate files'
29 changes: 10 additions & 19 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
---
name: lint

on:
push:
branches:
- main
branches: [main]
pull_request:
branches:
- main
branches: [main]

jobs:
commitlint:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
- uses: actions/setup-go@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
golang_ci_linter:
name: golang_ci_linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
go-version: 1.21.x
- name: Install dependencies
run: go get .
- uses: pre-commit/[email protected]
codeql_analysis:
runs-on: ubuntu-latest
permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: pages

on:
workflow_dispatch: {}
push:
tags:
- v*
tags: [v*]

jobs:
release_pages:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: release

on:
push:
tags:
- v*
tags: [v*]

jobs:
build_default_release_manifest:
Expand Down Expand Up @@ -55,9 +55,7 @@ jobs:
build-args: |
VERSION=${{ steps.action_vars.outputs.tag }}
sync-charts:
needs:
- build_default_release_manifest
- build_and_push_docker_image
needs: [build_default_release_manifest, build_and_push_docker_image]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: tests

on:
Expand All @@ -8,8 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
k8s-version:
- 1.24.10
k8s-version: [1.24.10]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand Down
20 changes: 6 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
---
issues:
exclude-rules:
- path: _test\.go
linters:
- dupl
- gosec
- goconst
- golint
linters: [dupl, gosec, goconst, golint]
text: underscore
- linters:
- gomnd
text: "mnd: Magic number: 0644"
- linters: [gomnd]
text: 'mnd: Magic number: 0644'

linters:
disable-all: true
enable:
- deadcode
- errcheck
- gofmt
- gosimple
Expand All @@ -24,14 +19,11 @@ linters:
- staticcheck
- unconvert
- unused
- varcheck
- vet
- goimports
- gomnd

run:
timeout: 10m
skip-dirs:
- hack
skip-files:
- api/v1alpha1/zz_generated.deepcopy.go
skip-dirs: [hack]
skip-files: [api/v1alpha1/zz_generated.deepcopy.go]
15 changes: 15 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// mkdocs code blocks inside admonitions trip this rule
"code-block-style": false,
// allow inline html
"no-inline-html": false,
// allow using **emphasis** as heading
"no-emphasis-as-heading": false,
// don't care about line length
"line-length": false,
// mkdocs admonitions and links aren't supported https://github.com/DavidAnson/markdownlint/issues/207
"link-fragments": false,
// mkdocs renders link titles from YAML frontmatter and renders the content
// title from the first title specified with "#"
"single-title": false
}
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: fix-byte-order-marker
- id: pretty-format-json
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.10.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/lyz-code/yamlfix
rev: 1.16.0
hooks:
- id: yamlfix
exclude: |
(?x)^(
charts/(aiven-operator|aiven-operator-crds)/templates/.*.yaml|
charts/aiven-operator-crds/values.yaml
)$
args: [--config-file, yamlfix.toml]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.38.0
hooks:
- id: markdownlint
args: [--fix]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: golangci-lint-full
39 changes: 22 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

## v0.16.1 - 2023-12-15

- Check VPC for running services before deletion. Prevents VPC from hanging in the DELETING state
- Check VPC for running services before deletion. Prevents VPC from hanging in the DELETING state
- Expose `KAFKA_SCHEMA_REGISTRY_URI` and `KAFKA_REST_URI` to `Kafka` secret
- Expose `CONNECTIONPOOL_NAME` in `ConnectionPool` secret
- Fix `CONNECTIONPOOL_PORT` exposes service port instead of pool port
- Fix `CONNECTIONPOOL_PORT` exposes service port instead of pool port
- Fix `SERVICEUSER_PORT` when `sasl` is the only authentication method
- Change `PostgreSQL` field `userConfig.pg_qualstats.enabled`: deprecated
- Change `PostgreSQL` field `userConfig.pg_qualstats.min_err_estimate_num`: deprecated
Expand All @@ -21,7 +21,7 @@
## v0.16.0 - 2023-12-07

- Set conditions on errors: `Preconditions`, `CreateOrUpdate`, `Delete`. Thanks to @atarax
- Fix object updates lost when reconciler exits before the object is committed
- Fix object updates lost when reconciler exits before the object is committed
- Add `Kafka` field `userConfig.kafka.transaction_partition_verification_enable`, type `boolean`: Enable
verification that checks that the partition has been added to the transaction before writing transactional
records to the partition
Expand Down Expand Up @@ -53,7 +53,7 @@

- Upgrade to Go 1.21
- Add option to orphan resources. Thanks to @atarax
- Fix `ServiceIntegration`: do not send empty user config to the API
- Fix `ServiceIntegration`: do not send empty user config to the API
- Add a format for `string` type fields to the documentation
- Generate CRDs changelog
- Add `Clickhouse` field `userConfig.private_access.clickhouse_mysql`, type `boolean`: Allow clients
Expand Down Expand Up @@ -110,7 +110,7 @@
- Add `Kafka` spec property `scheduled_rebalance_max_delay_ms`
- Mark deprecated `Kafka` spec property `remote_log_storage_system_enable`
- Add `KafkaConnect` spec property `scheduled_rebalance_max_delay_ms`
- Add `OpenSearch` spec property `openid`
- Add `OpenSearch` spec property `openid`
- Use updated go client with enhanced retries

## v0.12.3 - 2023-07-13
Expand Down Expand Up @@ -139,7 +139,6 @@
- Add `OpenSearch.spec.userConfig.idp_pemtrustedcas_content` option.
Specifies the PEM-encoded root certificate authority (CA) content for the SAML identity provider (IdP) server verification.


## v0.11.0 - 2023-04-25

- Add `ServiceIntegration` kind `SourceProjectName` and `DestinationProjectName` fields
Expand All @@ -158,16 +157,16 @@
- Add `minumim`, `maximum` validations for `number` type
- Move helm charts to the operator repository
- Add helm charts generator
- Remove `ip_filter` backward compatability
- Remove `ip_filter` backward compatibility
- Fix deletion errors omitted
- Add service integration `clickhouseKafka.tables.data_format-property` enum `RawBLOB` value
- Update OpenSearch `userConfig.opensearch.email_sender_username` validation pattern
- Add Kafka `log_cleaner_min_cleanable_ratio` minimum and maximum validation rules
- Remove Kafka version `3.2`, reached EOL
- Remove PostgreSQL version `10`, reached EOL
- Explicitly delete `ProjectVPC` by `ID` to avoid conflicts
- Explicitly delete `ProjectVPC` by `ID` to avoid conflicts
- Speed up `ProjectVPC` deletion by exiting on `DELETING` status
- Fix missing RBAC permissions to update finalizers for various controllers
- Fix missing RBAC permissions to update finalizers for various controllers
- Refactor `ClickhouseUser` controller
- Mark `ClickhouseUser.spec.project` and `ClickhouseUser.spec.serviceName` as immutable
- Remove deprecated service integration type `signalfx`
Expand Down Expand Up @@ -206,7 +205,7 @@ as native [CRD validation rules](https://kubernetes.io/blog/2022/09/23/crd-valid

- Add Cassandra Kind
- Add Grafana Kind
- Recreate Kafka ACL if modified.
- Recreate Kafka ACL if modified.
Note: Modification of ACL created prior to v0.5.1 won't delete existing instance at Aiven.
It must be deleted manually.
- Fix MySQL webhook
Expand All @@ -216,7 +215,7 @@ as native [CRD validation rules](https://kubernetes.io/blog/2022/09/23/crd-valid
- Remove `never` from choices of maintenance dow
- Add `development` flag to configure logger's behavior
- Add user config generator (see `make generate-user-configs`)
- Add `genericServiceHandler` to generalize service management
- Add `genericServiceHandler` to generalize service management
- Add MySQL Kind

## v0.5.2 - 2022-12-09
Expand Down Expand Up @@ -246,23 +245,29 @@ as native [CRD validation rules](https://kubernetes.io/blog/2022/09/23/crd-valid
## v0.2.0 - 2021-11-17

features:
* add Redis CRD

- add Redis CRD

improvements:
* watch CRDs to reconcile token secrets

- watch CRDs to reconcile token secrets

fixes:
* fix RBACs of KafkaACL CRD

- fix RBACs of KafkaACL CRD

## v0.1.1 - 2021-09-13

improvements:
* update helm installation docs

- update helm installation docs

fixes:
* fix typo in a kafka-connector kuttl test

- fix typo in a kafka-connector kuttl test

## v0.1.0 - 2021-09-10

features:
* initial release

- initial release
8 changes: 4 additions & 4 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
<[email protected]>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -116,13 +116,13 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
Loading