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

Add spell checking to linter step #8001

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

mook-as
Copy link
Contributor

@mook-as mook-as commented Dec 23, 2024

Note that this is currently only enabled on Linux, because:

This is written in TypeScript instead of pure shell because it involves reading YAML and writing JSON (in INPUTS); I didn't want to deal with that in shell. If you think it's better, I can rewrite this in go and do a go run … instead?

Note that this is currently only enabled on Linux, because:
- check-spelling does not support Windows
- on macOS, check-spelling fails to ignore long words listed in expect.txt
  (check-spelling/check-spelling#84)

Signed-off-by: Mark Yen <mark.yen@suse.com>
@jandubois
Copy link
Member

This is written in TypeScript instead of pure shell because it involves reading YAML and writing JSON (in INPUTS); I didn't want to deal with that in shell. If you think it's better, I can rewrite this in go and do a go run … instead?

I don't really care for the rancher-desktop repo, because we already have a lot of the build scripts written in TypeScript.

But for TwoCows, and especially for rancher-desktop-daemon I would like to use only bash and Go.

I think for trivial YAML and JSON operations we can use yq and jq instead of jumping immediately to Go, but let's discuss this as a group, as I know there are different opinions about the readability of yq/jq scripts.

In this particular case I think this is just a readable as the TypeScript code:

cat spelling.sh
yq -o=json '.jobs.spelling.steps[] | select(.id == "spelling").with |
            del(.experimental_apply_changes_via_bot, .use_sarif) | tojson' \
  .github/workflows/spelling.ymleval "INPUT=$(./spelling.sh)"echo $INPUT
{
  "suppress_push_for_open_pull_request": 1,
  "checkout": true,
  "check_file_names": 1,
  "spell_check_this": "rancher-sandbox/rancher-desktop@main",
  "post_comment": 0,
  "use_magic_file": 1,
  "report-timing": 1,
  "warnings": "bad-regex,binary-file,deprecated-feature,large-file,limited-references,no-newline-at-eof,noisy-file,non-alpha-in-dictionary,token-is-substring,unexpected-line-ending,whitespace-in-dictionary,minified-file,unsupported-configuration,no-files-to-check",
  "extra_dictionary_limit": 20,
  "extra_dictionaries": "cspell:software-terms/dict/softwareTerms.txt cspell:k8s/dict/k8s.txt cspell:node/dict/node.txt cspell:aws/aws.txt cspell:golang/dict/go.txt cspell:php/dict/php.txt cspell:python/src/python/python-lib.txt cspell:typescript/dict/typescript.txt cspell:npm/dict/npm.txt cspell:shell/dict/shell-all-words.txt cspell:html/dict/html.txt cspell:filetypes/filetypes.txt cspell:fullstack/dict/fullstack.txt cspell:python/src/common/extra.txt cspell:java/src/java.txt cspell:dotnet/dict/dotnet.txt cspell:css/dict/css.txt cspell:django/dict/django.txt cspell:docker/src/docker-words.txt cspell:cpp/src/stdlib-cmath.txt cspell:python/src/python/python.txt cspell:powershell/dict/powershell.txt"
}

@mook-as
Copy link
Contributor Author

mook-as commented Jan 7, 2025

Ah, I didn't trust yq to be installed (just jq), hence not wanting to touch YAML. GitHub-hosted Windows runners don't have it, for example (but since this currently doesn't work on Windows anyway that might not be an issue?)

@jandubois
Copy link
Member

We install yq on Windows for smoke tests:

- name: "Windows: Install yq"
if: runner.os == 'Windows'
run: |
set -o xtrace
bindir="$HOME/bin"
if [[ ! "$PATH" =~ "$bindir" ]]; then
bindir=/usr/bin
fi
if ! command -v yq; then
mkdir -p "$bindir"
curl --location --output "$bindir/yq.exe" \
https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_windows_amd64.exe
chmod a+x "$bindir/yq.exe"
fi
shell: bash

I think that should just be moved to our setup-environment action in https://github.com/rancher-sandbox/rancher-desktop/blob/main/.github/actions/setup-environment/action.yaml.

@mook-as mook-as requested a review from jandubois January 7, 2025 17:55
Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

Tested on openSUSE Tumbleweed.

sudo zipper in perl-App-cpanminus
export PERL5LIB=/home/jan/perl5/lib/perl5
yarn lint:spelling

@jandubois jandubois merged commit 5fb8e4a into rancher-sandbox:main Jan 7, 2025
20 checks passed
@mook-as mook-as deleted the lint/spellcheck branch January 7, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants