Skip to content

Commit

Permalink
Add pre-commit and CI static checks
Browse files Browse the repository at this point in the history
Signed-off-by: Tomek Urbaszek <tomasz.urbaszek@polidea.com>
  • Loading branch information
turbaszek committed Aug 24, 2020
1 parent b6c60a0 commit 25595ec
Show file tree
Hide file tree
Showing 50 changed files with 194 additions and 110 deletions.
8 changes: 4 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
"-v", "keda-gomodcache:/go/pkg",
// Cache vscode exentsions installs and homedir
"-v", "keda-vscodecache:/root/.vscode-server",

// Mount docker socket for docker builds
"-v", "/var/run/docker.sock:/var/run/docker.sock",

"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
],

// Use 'settings' to set *default* container specific settings.json values on container create.
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"go.gopath": "/go"
},
Expand All @@ -31,4 +31,4 @@
"extensions": [
"ms-vscode.go"
]
}
}
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence
* @ahmelsayed @zroubalik
* @ahmelsayed @zroubalik
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ A clear and concise description of what the bug is.
- **KEDA Version:** *Please elaborate*
- **Platform & Version:** *Please elaborate*
- **Kubernetes Version:** *Please elaborate*
- **Scaler(s):** *Please elaborate*
- **Scaler(s):** *Please elaborate*
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Suggest_scaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ A clear and concise description of what scaler you'd like to use and how you'd w

- **Scaler Source:** *Please elaborate*
- **How do you want to scale:** *Please elaborate*
- **Authentication:** *Please elaborate*
- **Authentication:** *Please elaborate*
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: Ask a question or get support
url: https://github.com/kedacore/keda/discussions/new
about: Ask a question or request support for using KEDA
about: Ask a question or request support for using KEDA
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Thank you for contributing!
Read more about how you can contribute in our contribution guide:
https://github.com/kedacore/keda/blob/master/CONTRIBUTING.md
-->
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Code Quality
on:
push:
branches:
- master
- v2
pull_request:
branches:
- master
- v2
jobs:
statics:
name: Static checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: actions/setup-go@v2-beta
with:
go-version: 1.15
- name: install go-lint
run: |
go get -u golang.org/x/lint/golint
export PATH=$PATH:$(go list -f {{.Target}} golang.org/x/lint/golint)
- uses: pre-commit/action@v1.0.1
2 changes: 1 addition & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Verify Generated clientset is up to date
run: make clientset-verify

- name: Build
run: make build

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,4 @@ vendor
cover.out

# GO debug binary
cmd/manager/debug.test
cmd/manager/debug.test
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
default_stages: [commit, push]
minimum_pre_commit_version: "1.20.0"
repos:
- repo: git://github.com/dnephin/pre-commit-golang
rev: master
hooks:
- id: go-fmt
- id: go-lint
exclude: |
(?x)(
.*zz_generated.*|
^api/v1alpha1/condition_types\.go$|
^api/v1alpha1/groupversion_info\.go$|
^api/v1alpha1/gvkr_types\.go$|
^api/v1alpha1/scaledjob_types\.go$|
^api/v1alpha1/scaledobject_types\.go$|
^api/v1alpha1/triggerauthentication_types\.go$|
^controllers/scaledjob_controller\.go$|
^controllers/scaledobject_controller\.go$|
^controllers/util/status\.go$|
^controllers/util/string_lists\.go$|
^hack/tools\.go$|
^pkg/scalers/artemis_scaler\.go$|
^pkg/scalers/azure/azure_aad_podidentity\.go$|
^pkg/scalers/azure/azure_eventhub\.go$|
^pkg/scalers/azure/azure_monitor\.go$|
^pkg/scalers/azure/azure_queue\.go$|
^pkg/scalers/azure/azure_storage\.go$|
^pkg/scalers/azure_eventhub_scaler\.go$|
^pkg/scalers/azure_queue_scaler\.go$|
^pkg/scalers/azure_servicebus_scaler\.go$|
^pkg/scalers/cron_scaler\.go$|
^pkg/scalers/external_scaler\.go$|
^pkg/scalers/kafka_scram_client\.go$|
^pkg/scalers/liiklus_scaler\.go$|
^pkg/scalers/postgresql_scaler\.go$|
^pkg/scalers/rabbitmq_scaler\.go$|
^pkg/scalers/rabbitmq_scaler_test\.go$|
^pkg/scalers/scaler\.go$|
^pkg/scaling/executor/scale_executor\.go$|
^pkg/scaling/resolver/hashicorpvault_handler\.go$|
^pkg/scaling/resolver/scale_resolvers\.go$|
^pkg/util/gvkr\.go$|
^pkg/util/k8sversion\.go$|
^pkg/util/normalize_string\.go$|
^version/version\.go$
)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: trailing-whitespace
- id: detect-private-key
- id: end-of-file-fixer
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@ git add -A
git commit -sm "one commit on <branch-name>"
git push --force
```

## Code quality

This project is using [pre-commits](https://pre-commit.com) to ensure the
quality of the code. To install pre-commits just do:
```bash
pip install pre-commit
# or
brew install pre-commit
```
then from project directory run `pre-commit install`. For more installation options
visit the [pre-commits](https://pre-commit.com).
2 changes: 1 addition & 1 deletion Dockerfile.adapter
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ COPY --from=builder /workspace/bin/keda-adapter .
USER nonroot:nonroot


ENTRYPOINT ["/keda-adapter", "--secure-port=6443", "--logtostderr=true", "--v=0"]
ENTRYPOINT ["/keda-adapter", "--secure-port=6443", "--logtostderr=true", "--v=0"]
2 changes: 1 addition & 1 deletion GOVERNANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ maintainers over the course of a one week voting period. At the end of the week,
votes are counted and a pull request is made on the repo adding the new
maintainer to the [MAINTAINERS](MAINTAINERS.md) file.

Individuals interested in becoming maintainers may submit an [issue](https://github.com/kedacore/keda/issues/new)
Individuals interested in becoming maintainers may submit an [issue](https://github.com/kedacore/keda/issues/new)
stating their interest. Existing maintainers can choose if they would
like to nominate these individuals to be a maintainer following the process
above.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
| -------------------- | --------------------------------------------- | ----------- |
| Aarthi Saravanakumar | [Aarthisk](https://github.com/Aarthisk) | Microsoft |
| Yaron Schneider | [yaron2](https://github.com/yaron2) | Microsoft |
| Ben Browning | [bbrowning](https://github.com/bbrowning) | Red Hat |
| Ben Browning | [bbrowning](https://github.com/bbrowning) | Red Hat |
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ Make sure to remove previous KEDA (including CRD) from the cluster. Switch to th
<a href="https://bestpractices.coreinfrastructure.org/projects/3791"><img src="https://bestpractices.coreinfrastructure.org/projects/3791/badge"></a>
<a href="https://twitter.com/kedaorg"><img src="https://img.shields.io/twitter/follow/kedaorg?style=social" alt="Twitter"></a></p>

KEDA allows for fine grained autoscaling (including to/from zero) for event driven Kubernetes workloads. KEDA serves
as a Kubernetes Metrics Server and allows users to define autoscaling rules using a dedicated Kubernetes custom
KEDA allows for fine grained autoscaling (including to/from zero) for event driven Kubernetes workloads. KEDA serves
as a Kubernetes Metrics Server and allows users to define autoscaling rules using a dedicated Kubernetes custom
resource definition.

KEDA can run on both the cloud and the edge, integrates natively with Kubernetes components such as the Horizontal
KEDA can run on both the cloud and the edge, integrates natively with Kubernetes components such as the Horizontal
Pod Autoscaler, and has no external dependencies.

We are a Cloud Native Computing Foundation (CNCF) sandbox project.
<img src="https://raw.githubusercontent.com/kedacore/keda/master/images/logo-cncf.svg" height="75px">

## Getting started

* [QuickStart - RabbitMQ and Go](https://github.com/kedacore/sample-go-rabbitmq)
Expand Down Expand Up @@ -66,13 +66,13 @@ If interested in contributing or participating in the direction of KEDA, you can
* **Zoom link:** [https://zoom.us/j/150360492 ](https://zoom.us/j/150360492 )
* **Meeting agenda:** [https://hackmd.io/s/r127ErYiN](https://hackmd.io/s/r127ErYiN)

Just want to learn or chat about KEDA? Feel free to join the conversation in
Just want to learn or chat about KEDA? Feel free to join the conversation in
**[#KEDA](https://kubernetes.slack.com/messages/CKZJ36A5D)** on the **[Kubernetes Slack](https://slack.k8s.io/)**!

## Building: Quick start with [Visual Studio Code Remote - Containers](https://code.visualstudio.com/docs/remote/containers)

This helps you pull and build quickly - dev containers launch the project inside a container with all the tooling
required for a consistent and seamless developer experience.
This helps you pull and build quickly - dev containers launch the project inside a container with all the tooling
required for a consistent and seamless developer experience.

This means you don't have to install and configure your dev environment as the container handles this for you.

Expand All @@ -90,11 +90,11 @@ code .
Once VSCode launches run `CTRL+SHIFT+P -> Remote-Containers: Reopen in container` and then use the integrated
terminal to run:

```bash
```bash
make build
```

> Note: The first time you run the container it will take some time to build and install the tooling. The image
> Note: The first time you run the container it will take some time to build and install the tooling. The image
> will be cached so this is only required the first time.
## Building: Locally directly
Expand Down Expand Up @@ -124,8 +124,8 @@ go env -w GOPROXY=https://proxy.golang.org,direct GOSUMDB=sum.golang.org
```

## Deploying: Custom KEDA locally outside cluster
The Operator SDK framework allows you to run the operator/controller locally outside the cluster without a need of building an image. This should help during development/debugging of KEDA Operator or Scalers.
> Note: This approach works only on Linux or macOS.
The Operator SDK framework allows you to run the operator/controller locally outside the cluster without a need of building an image. This should help during development/debugging of KEDA Operator or Scalers.
> Note: This approach works only on Linux or macOS.
To be KEDA to be fully operational we need to deploy Metrics Server first.

Expand All @@ -140,11 +140,11 @@ To be KEDA to be fully operational we need to deploy Metrics Server first.
3. Run the operator locally with the default Kubernetes config file present at `$HOME/.kube/config` and change the operator log level via `--zap-log-level=` if needed
```bash
make run ARGS="--zap-log-level=debug"
```
```

## Deploying: Custom KEDA as an image

If you want to change KEDA's behaviour, or if you have created a new scaler (more docs on this to come) and you want
If you want to change KEDA's behaviour, or if you have created a new scaler (more docs on this to come) and you want
to deploy it as part of KEDA. Do the following:
1. Make your change in the code.
Expand All @@ -156,7 +156,7 @@ to deploy it as part of KEDA. Do the following:
```bash
IMAGE_REPO=johndoe make deploy
```
4. Once the keda pods are up, check the logs to verify everything running ok, eg:
4. Once the keda pods are up, check the logs to verify everything running ok, eg:
```bash
kubectl get pods --no-headers -n keda | awk '{print $1}' | grep keda-operator | xargs kubectl -n keda logs -f
Expand Down
10 changes: 5 additions & 5 deletions RELEASE-PROCESS.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Process

The release process of a new version of KEDA involves the following:
The release process of a new version of KEDA involves the following:

## 0. Prerequisites

Expand All @@ -10,13 +10,13 @@ The next version will thus be 1.2.0

## 1. Changelog

Provide a new section in `CHANGELOG.md` for the new version that is being released along with the new features, patches and deprecations it introduces.
Provide a new section in `CHANGELOG.md` for the new version that is being released along with the new features, patches and deprecations it introduces.

It should not include every single change but solely what matters to our customers, for example issue template that has changed is not important.

## 2. Create KEDA release on GitHub

Creating a new release in the releases page (https://github.com/kedacore/keda/release) will trigger a GitHub workflow which will create a new image with the latest code and tagged with the next version (in this example 1.2.0).
Creating a new release in the releases page (https://github.com/kedacore/keda/release) will trigger a GitHub workflow which will create a new image with the latest code and tagged with the next version (in this example 1.2.0).

KEDA Deployment YAML file (eg. keda-1.2.0.yaml) is also automatically created and attached to the Release as part of the workflow.

Expand All @@ -30,14 +30,14 @@ See [docs](https://github.com/kedacore/keda-docs#publishing-a-new-version).

## 4. Update Helm Charts

a). Update the version and appVersion here: https://github.com/kedacore/charts/blob/master/keda/Chart.yaml
a). Update the version and appVersion here: https://github.com/kedacore/charts/blob/master/keda/Chart.yaml
b). In the image section update the keda and metricsAdapter to point to the docker images from step 1 https://github.com/kedacore/charts/blob/master/keda/values.yaml

Then run the commands here: https://github.com/kedacore/charts

-- To deploy KEDA through Azure Functions Core Tools --

Update the following file:
Update the following file:
https://github.com/Azure/azure-functions-core-tools/blob/dev/src/Azure.Functions.Cli/StaticResources/keda.yaml
[Search for 1.1.0 etc. and replace it]

Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/scaledjob_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

- op: add
path: /spec/validation/openAPIV3Schema/properties/spec/properties/jobTargetRef/properties/template/properties/spec/properties/initContainers/items/properties/ports/items/required/-
value: protocol
value: protocol
1 change: 0 additions & 1 deletion config/general/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
resources:
- namespace.yaml
- service_account.yaml

2 changes: 1 addition & 1 deletion config/metrics-server/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ rules:
resources:
- '*'
verbs:
- '*'
- '*'
2 changes: 1 addition & 1 deletion config/metrics-server/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: horizontal-pod-autoscaler
namespace: kube-system
namespace: kube-system
2 changes: 1 addition & 1 deletion config/metrics-server/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ spec:
port: 80
targetPort: 8080
selector:
app: keda-metrics-apiserver
app: keda-metrics-apiserver
2 changes: 1 addition & 1 deletion config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ commonLabels:

resources:
- role.yaml
- role_binding.yaml
- role_binding.yaml
10 changes: 5 additions & 5 deletions config/samples/keda_v1alpha1_scaledjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ metadata:
name: scaledjob-sample
spec:
jobTargetRef:
parallelism: 1
completions: 1
activeDeadlineSeconds: 600
backoffLimit: 6
parallelism: 1
completions: 1
activeDeadlineSeconds: 600
backoffLimit: 6
template:
## template
pollingInterval: 30
Expand All @@ -17,4 +17,4 @@ spec:
triggers:
- type: example-trigger
metadata:
property: examle-property
property: examle-property
2 changes: 1 addition & 1 deletion config/samples/keda_v1alpha1_scaledobject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ spec:
triggers:
- type: example-trigger
metadata:
property: examle-property
property: examle-property
Loading

0 comments on commit 25595ec

Please sign in to comment.