From a54429854c853bd22a69589d96794208860df434 Mon Sep 17 00:00:00 2001 From: Jon Zeolla Date: Thu, 11 Jan 2024 06:03:05 -0500 Subject: [PATCH] fix: cspell error --- README.md | 5 +++++ entrypoint.sh | 23 +++++++++++++---------- etc/cspell.config.js | 13 ++++++++++++- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 311cb844..941c928b 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,11 @@ jobs: - textlint - yamllint +#### Supported Pipelines + +- GitHub Actions +- Bitbucket Pipelines + #### Debugging To debug an issue with the goat, configure the log level to either `ERROR`, `WARN`, `INFO`, or `DEBUG`. diff --git a/entrypoint.sh b/entrypoint.sh index c038db02..ba806079 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -59,7 +59,7 @@ function setup_environment() { # GitHub Actions RELATIVE_PATH="${GITHUB_WORKSPACE}" elif [[ -n "${BITBUCKET_CLONE_DIR:+x}" ]]; then - # BitBucket Pipelines + # Bitbucket Pipelines RELATIVE_PATH="${BITBUCKET_CLONE_DIR}" elif [[ -d "/src/.git" ]]; then # Pre-commit @@ -327,19 +327,22 @@ function lint_files() { function seiso_lint() { echo -e "\nRunning Seiso Linter\n--------------------------\n" + local skip_safe="false" if [[ -n ${GITHUB_WORKSPACE:+x} ]]; then # GitHub Actions local safe_directory="${GITHUB_WORKSPACE}" elif [[ -n ${BITBUCKET_CLONE_DIR:+x} ]]; then - # BitBucket Pipelines + # Bitbucket Pipelines local safe_directory="${BITBUCKET_CLONE_DIR}" else - feedback ERROR "Unable to identify a directory to set as safe" - exit 1 + feedback WARNING "Unable to identify a directory to set as safe, skipping that step..." + local skip_safe="true" fi - echo "Setting ${safe_directory} as safe directory" - git config --global --add safe.directory "${safe_directory}" + if [[ "${skip_safe}" == "false" ]]; then + feedback INFO "Setting ${safe_directory} as safe directory" + git config --global --add safe.directory "${safe_directory}" + fi # When run in a pipeline, move per-repo configurations into the right location at runtime so the goat finds them, overwriting the defaults. # This will handle hidden and non-hidden files, as well as sym links @@ -383,14 +386,14 @@ function seiso_lint() { linter[logfile]="/opt/goat/log/${linter[name]}.log" if [[ -v VALIDATE_PYTHON_MYPY && "${VALIDATE_PYTHON_MYPY,,}" == "false" && "${linter[name]}" == "mypy" ]]; then - echo "mypy linter has been disabled" + feedback WARNING "mypy linter has been disabled" linter_skipped+=("${linter[name]}") continue fi - echo "===============================" >>"${linter[logfile]}" - echo "Running linter: ${linter[name]}" - echo "${linter[name]^^}" >>"${linter[logfile]}" + feedback INFO "===============================" >>"${linter[logfile]}" + feedback INFO "Running linter: ${linter[name]}" + feedback INFO "${linter[name]^^}" >>"${linter[logfile]}" # The string "linter" gets dereferenced back into a variable on the receiving end lint_files linter "${linter_filetypes[@]}" & diff --git a/etc/cspell.config.js b/etc/cspell.config.js index 20b0556e..b0e7a08c 100644 --- a/etc/cspell.config.js +++ b/etc/cspell.config.js @@ -1,5 +1,16 @@ 'use strict' +let per_repo_dictionary_file; + +if (process.env.GITHUB_WORKSPACE) { + per_repo_dictionary_file = `${process.env.GITHUB_WORKSPACE}/.github/etc/dictionary.txt`; +} else if (process.env.BITBUCKET_CLONE_DIR) { + per_repo_dictionary_file = `${process.env.BITBUCKET_CLONE_DIR}/dictionary.txt`; +} else { + /** Assume it's running local and use .github **/ + per_repo_dictionary_file = '/goat/.github/etc/dictionary.txt'; +} + /** @type { import("@cspell/cspell-types").CSpellUserSettings } */ const cspell = { language: 'en', @@ -28,7 +39,7 @@ const cspell = { dictionaryDefinitions: [ { name: 'per-repository dictionary', - path: `${process.env.GITHUB_WORKSPACE ? process.env.GITHUB_WORKSPACE : '.'}/.github/etc/dictionary.txt` + path: per_repo_dictionary_file, }, { name: 'seiso global dictionary',