From a4e7fb7060c08176d94b3ba116fa0428c7d6ce28 Mon Sep 17 00:00:00 2001 From: Vara Bonthu Date: Mon, 20 May 2024 14:41:55 -0700 Subject: [PATCH] feat: GitHub workflow Codespell (#256) Signed-off-by: Vara Bonthu --- .github/workflows/codespell.yaml | 27 +++++++++++++++++++ .pre-commit-config.yaml | 11 ++++++++ api/v1alpha1/localbuild_types.go | 2 +- examples/basic/README.md | 2 +- examples/ref-implementation/README.md | 2 +- examples/terraform-integrations/README.md | 2 +- pkg/cmd/create/root.go | 2 +- pkg/cmd/helpers/validation.go | 4 +-- pkg/controllers/localbuild/argo_test.go | 2 +- .../idpbuilder.cnoe.io_localbuilds.yaml | 2 +- pkg/k8s/client.go | 2 +- pkg/kind/cluster.go | 2 +- pkg/runtime/finch.go | 4 +-- pkg/runtime/provider.go | 2 +- pkg/util/util_test.go | 2 +- 15 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/codespell.yaml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/codespell.yaml b/.github/workflows/codespell.yaml new file mode 100644 index 00000000..1a2b741f --- /dev/null +++ b/.github/workflows/codespell.yaml @@ -0,0 +1,27 @@ +--- +name: Codespell + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Codespell + uses: codespell-project/actions-codespell@v2 + with: + check_filenames: true + # When using this Action in other repos, the --skip option below can be removed + skip: "*.excalidraw,*.git,*.png,*.jpg,*.svg,go.mod,go.sum" + continue-on-error: true # The PR checks will not fail, but the possible spelling issues will still be reported for review and correction \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b54b89b9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +# For more information, visit: https://pre-commit.com +# To run locally: +# 1. Install pre-commit: pip install pre-commit +# 2. Run pre-commit checks on all files: pre-commit run --all-files + +repos: + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + args: ["--skip=*.excalidraw,*.git,*.png,*.jpg,*.svg,go.sum,go.mod"] \ No newline at end of file diff --git a/api/v1alpha1/localbuild_types.go b/api/v1alpha1/localbuild_types.go index 99f9ce22..bd08f86a 100644 --- a/api/v1alpha1/localbuild_types.go +++ b/api/v1alpha1/localbuild_types.go @@ -20,7 +20,7 @@ const ( ) // ArgoPackageConfigSpec Allows for configuration of the ArgoCD Installation. -// If no fields are specified then the binary embedded resources will be used to intall ArgoCD. +// If no fields are specified then the binary embedded resources will be used to install ArgoCD. type ArgoPackageConfigSpec struct { // Enabled controls whether to install ArgoCD. Enabled bool `json:"enabled,omitempty"` diff --git a/examples/basic/README.md b/examples/basic/README.md index e2f8f699..112b6615 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -10,7 +10,7 @@ The [package1 directory](./package1) is an example of a custom package that you This configuration instructs idpbuilder to: 1. Create a Gitea repository. -2. Sync the contents of the [manifests](./package1/manifests) directory to the repostiory. +2. Sync the contents of the [manifests](./package1/manifests) directory to the repository. 3. Replace the `spec.Source(s).repoURL` field with the Gitea repository URL. ### Remote manifests diff --git a/examples/ref-implementation/README.md b/examples/ref-implementation/README.md index c1738e4f..7045274b 100644 --- a/examples/ref-implementation/README.md +++ b/examples/ref-implementation/README.md @@ -117,7 +117,7 @@ You can click on the ArgoCD Application name to see more details. In this example, we will deploy a simple Apache Spark job through Argo Workflows. -Click on the `Create...` button on the left, then select the `Basic Argo Workflow witha Spark Job` template. +Click on the `Create...` button on the left, then select the `Basic Argo Workflow with a Spark Job` template. ![img.png](images/backstage-templates-spark.png) diff --git a/examples/terraform-integrations/README.md b/examples/terraform-integrations/README.md index f027455e..298fdbfc 100644 --- a/examples/terraform-integrations/README.md +++ b/examples/terraform-integrations/README.md @@ -13,6 +13,6 @@ idpbuilder create \ As you see above, this add-on to `idpbuilder` has a dependency to the [reference implementation](../ref-implementation/). This command primarily does the following: -1. Installs `fluxcd` source respository controller as an `argo` application. +1. Installs `fluxcd` source repository controller as an `argo` application. 2. Installs `tofu-controller` for managing the lifecycle of terraform deployments from your Kubernetes cluster for operations such as create, delete and update. 3. Finally, this stack add-on goes together with the work done under [backstage-terraform-integrations](https://github.com/cnoe-io/backstage-terraform-integrations/). Once the add-on is enabled, the user will need to follow the setup discussed in the [backstage-terraform-integrations](https://github.com/cnoe-io/backstage-terraform-integrations/) repo for the remainder of the configuration, and terraform integrations should work. \ No newline at end of file diff --git a/pkg/cmd/create/root.go b/pkg/cmd/create/root.go index 2fcd9641..333627ef 100644 --- a/pkg/cmd/create/root.go +++ b/pkg/cmd/create/root.go @@ -160,7 +160,7 @@ func getPackageCustomFile(input string) (v1alpha1.PackageCustomization, error) { // the format should be `:` s := strings.Split(input, ":") if len(s) != 2 { - return v1alpha1.PackageCustomization{}, fmt.Errorf("ensure %s is formated as :", input) + return v1alpha1.PackageCustomization{}, fmt.Errorf("ensure %s is formatted as :", input) } paths, err := helpers.GetAbsFilePaths([]string{s[1]}, false) diff --git a/pkg/cmd/helpers/validation.go b/pkg/cmd/helpers/validation.go index ef77e7d5..5e398873 100644 --- a/pkg/cmd/helpers/validation.go +++ b/pkg/cmd/helpers/validation.go @@ -24,10 +24,10 @@ func ValidateKubernetesYamlFile(absPath string) error { for i := range n { obj := n[i] if obj.IsNilOrEmpty() { - return fmt.Errorf("given file %s contains an invalid kubenretes manifest", absPath) + return fmt.Errorf("given file %s contains an invalid kubernetes manifest", absPath) } if obj.GetKind() == "" || obj.GetApiVersion() == "" { - return fmt.Errorf("given file %s contains an invalid kubenretes manifest", absPath) + return fmt.Errorf("given file %s contains an invalid kubernetes manifest", absPath) } } diff --git a/pkg/controllers/localbuild/argo_test.go b/pkg/controllers/localbuild/argo_test.go index 449895c5..ae68a32a 100644 --- a/pkg/controllers/localbuild/argo_test.go +++ b/pkg/controllers/localbuild/argo_test.go @@ -30,7 +30,7 @@ func TestGetRawInstallResources(t *testing.T) { resourcePrefix := "# UCP ARGO INSTALL RESOURCES\n" checkPrefix := resources[1][0:len(resourcePrefix)] if resourcePrefix != string(checkPrefix) { - t.Fatalf("GetRawInstallResources() exptected 1 resource with prefix %q, got %q", resourcePrefix, checkPrefix) + t.Fatalf("GetRawInstallResources() expected 1 resource with prefix %q, got %q", resourcePrefix, checkPrefix) } } diff --git a/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml b/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml index d19ea371..6ac9b1be 100644 --- a/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml +++ b/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml @@ -42,7 +42,7 @@ spec: argoPackageConfigs: description: |- ArgoPackageConfigSpec Allows for configuration of the ArgoCD Installation. - If no fields are specified then the binary embedded resources will be used to intall ArgoCD. + If no fields are specified then the binary embedded resources will be used to install ArgoCD. properties: enabled: description: Enabled controls whether to install ArgoCD. diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index 7ef9f863..5e28dff8 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -37,7 +37,7 @@ func EnsureObject(ctx context.Context, kubeClient client.Client, obj client.Obje return err } - // hacky way to restore the GVK for the object after create corrupts it. didnt dig. not sure why? + // hacky way to restore the GVK for the object after create corrupts it. didn't dig. not sure why? obj.GetObjectKind().SetGroupVersionKind(curObj.GroupVersionKind()) return nil } diff --git a/pkg/kind/cluster.go b/pkg/kind/cluster.go index fb6ca98a..e41e9daf 100644 --- a/pkg/kind/cluster.go +++ b/pkg/kind/cluster.go @@ -182,7 +182,7 @@ func (c *Cluster) Reconcile(ctx context.Context, recreate bool) error { } if !rightPort { - return fmt.Errorf("cant serve port %s. cluster %s is already running on a different port", c.cfg.Port, c.name) + return fmt.Errorf("can't serve port %s. cluster %s is already running on a different port", c.cfg.Port, c.name) } // reuse if there is no port conflict diff --git a/pkg/runtime/finch.go b/pkg/runtime/finch.go index ef49749e..7f6341af 100644 --- a/pkg/runtime/finch.go +++ b/pkg/runtime/finch.go @@ -11,7 +11,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" ) -type Conainer struct { +type Container struct { NetworkSettings NetworkSettings `json:"NetworkSettings"` State State `json:"State"` } @@ -59,7 +59,7 @@ func (f *FinchRuntime) ContainerWithPort(ctx context.Context, name string, port return false, err } - var containers []Conainer + var containers []Container err = json.Unmarshal(stdout.Bytes(), &containers) if err != nil { return false, fmt.Errorf("%v: %s", err, stderr.String()) diff --git a/pkg/runtime/provider.go b/pkg/runtime/provider.go index fb9189c6..d3100001 100644 --- a/pkg/runtime/provider.go +++ b/pkg/runtime/provider.go @@ -12,6 +12,6 @@ type IRuntime interface { // get runtime name Name() string - // checks whether the container has the followin + // checks whether the container has the following ContainerWithPort(ctx context.Context, name, port string) (bool, error) } diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index bfa76ab5..32cb85c9 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -33,7 +33,7 @@ func TestGeneratePassword(t *testing.T) { } } if counts[0] != passwordLength { - t.Fatalf("password legnth incorrect") + t.Fatalf("password length incorrect") } if counts[1] < numSpecialChars { t.Fatalf("min number of special chars not generated")