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

fix: cspell error when run locally #182

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
23 changes: 13 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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[@]}" &
Expand Down
13 changes: 12 additions & 1 deletion etc/cspell.config.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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,
ChiefHolland marked this conversation as resolved.
Show resolved Hide resolved
},
{
name: 'seiso global dictionary',
Expand Down