From 843cd94cc2ffead6d2016496221f6cdc5a96ac9b Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 19 Apr 2024 02:22:45 -0700 Subject: [PATCH] Add codespell support (config, workflow to detect/not fix) and make it fix few typos (#2296) * Add github action to codespell master on push and PRs * Add codespell config with few custom skips * [DATALAD RUNCMD] Do interactive fixing of leftover ambigous typos === Do not change lines below === { "chain": [], "cmd": "codespell -w -i 3 -C 2 ./pkg/common/git/git.go", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ * exclude pkg/runner/hashfiles/index.js * [DATALAD RUNCMD] run codespell throughout fixing typos automagically === Do not change lines below === { "chain": [], "cmd": "codespell -w", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .codespellrc | 6 ++++++ .github/workflows/codespell.yml | 23 +++++++++++++++++++++++ pkg/common/git/git.go | 2 +- pkg/container/docker_network.go | 2 +- pkg/runner/run_context.go | 4 ++-- 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .codespellrc create mode 100644 .github/workflows/codespell.yml diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..4857dfe --- /dev/null +++ b/.codespellrc @@ -0,0 +1,6 @@ +[codespell] +# Ref: https://github.com/codespell-project/codespell#using-a-config-file +skip = .git*,go.sum,package-lock.json,*.min.*,.codespellrc,testdata,./pkg/runner/hashfiles/index.js +check-hidden = true +ignore-regex = .*Te\{0\}st.* +# ignore-words-list = diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..eeacead --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,23 @@ +# Codespell configuration is within .codespellrc +--- +name: Codespell + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Codespell + uses: codespell-project/actions-codespell@v2 diff --git a/pkg/common/git/git.go b/pkg/common/git/git.go index 9aa58fa..706f9ca 100644 --- a/pkg/common/git/git.go +++ b/pkg/common/git/git.go @@ -126,7 +126,7 @@ func FindGitRef(ctx context.Context, file string) (string, error) { * it means we checked out a branch * * If a branches matches first we must continue and check all tags (all references) - * in case we match with a tag later in the interation + * in case we match with a tag later in the iteration */ if r.Hash().String() == ref { if r.Name().IsTag() { diff --git a/pkg/container/docker_network.go b/pkg/container/docker_network.go index 6c2676f..df37609 100644 --- a/pkg/container/docker_network.go +++ b/pkg/container/docker_network.go @@ -50,7 +50,7 @@ func NewDockerNetworkRemoveExecutor(name string) common.Executor { } defer cli.Close() - // Make shure that all network of the specified name are removed + // Make sure that all network of the specified name are removed // cli.NetworkRemove refuses to remove a network if there are duplicates networks, err := cli.NetworkList(ctx, types.NetworkListOptions{}) if err != nil { diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index ba4835b..30f3694 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -118,7 +118,7 @@ func getDockerDaemonSocketMountPath(daemonPath string) string { return daemonPath } -// Returns the binds and mounts for the container, resolving paths as appopriate +// Returns the binds and mounts for the container, resolving paths as appropriate func (rc *RunContext) GetBindsAndMounts() ([]string, map[string]string) { name := rc.jobContainerName() @@ -1026,7 +1026,7 @@ func (rc *RunContext) handleServiceCredentials(ctx context.Context, creds map[st return } -// GetServiceBindsAndMounts returns the binds and mounts for the service container, resolving paths as appopriate +// GetServiceBindsAndMounts returns the binds and mounts for the service container, resolving paths as appropriate func (rc *RunContext) GetServiceBindsAndMounts(svcVolumes []string) ([]string, map[string]string) { if rc.Config.ContainerDaemonSocket == "" { rc.Config.ContainerDaemonSocket = "/var/run/docker.sock"