Skip to content

Commit

Permalink
Merge branch 'main' into feat/salacious
Browse files Browse the repository at this point in the history
  • Loading branch information
seanctech committed Feb 22, 2024
2 parents 7ae118c + b470999 commit 112923c
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
repos:
- repo: https://github.com/seisollc/goat
rev: f3aef1cd302f8dd0061a9e687f75af80f61977e2 # frozen: v2023.09.04
rev: afb50287a9742825ad0b2215f1f22d99363e0b05 # frozen: v2024.01.03
hooks:
- id: seiso-lint
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
2 changes: 1 addition & 1 deletion Task/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tasks:
var: TOOLS
split: ','
as: tool
cmd: apt-get install -y --no-install-recommends {{.tool}}
cmd: sudo apt-get install -y --no-install-recommends {{.tool}}

runner-curl-install:
desc: Install something on a GitHub Actions runner via curl
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023.11.01
2024.01.04
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ inputs:
default: "true"
runs:
using: "docker"
image: "docker://docker.io/seiso/goat:2023.11.01"
image: "docker://docker.io/seiso/goat:2024.01.04"
66 changes: 52 additions & 14 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ function setup_environment() {
elif [[ -n "${GITHUB_WORKSPACE:+x}" ]]; then
# GitHub Actions
RELATIVE_PATH="${GITHUB_WORKSPACE}"
elif [[ -n "${BITBUCKET_CLONE_DIR:+x}" ]]; then
# Bitbucket Pipelines
RELATIVE_PATH="${BITBUCKET_CLONE_DIR}"
elif [[ -d "/src/.git" ]]; then
# Pre-commit
RELATIVE_PATH="/src"
Expand All @@ -66,7 +69,15 @@ function setup_environment() {
exit 1
fi

export REPO_DICTIONARY="${RELATIVE_PATH}/.github/etc/dictionary.txt"
if [[ -r "${RELATIVE_PATH}/.github/etc/dictionary.txt" ]]; then
# GitHub
export REPO_DICTIONARY="${RELATIVE_PATH}/.github/etc/dictionary.txt"
elif [[ -r "${RELATIVE_PATH}/dictionary.txt" ]]; then
export REPO_DICTIONARY="${RELATIVE_PATH}/dictionary.txt"
else
feedback ERROR "Unable to find the dictionary file"
exit 1
fi

if [[ -n ${JSCPD_CONFIG:+x} ]]; then
feedback WARNING "JSCPD_CONFIG is set; not auto ignoring the goat submodule..."
Expand Down Expand Up @@ -125,15 +136,23 @@ function setup_environment() {
}

function check_environment() {
# Check the GITHUB_BASE_REF (PRs only)
if [[ ${GITHUB_ACTIONS:-false} == "true" && -n ${GITHUB_BASE_REF:+x} ]]; then
# Check PRs for the main branch
local wrong_destination_branch="false"

if [[ -n ${BITBUCKET_PR_DESTINATION_BRANCH:+x} && "${BITBUCKET_PR_DESTINATION_BRANCH}" != "main" ]]; then
wrong_destination_branch="true"
elif [[ ${GITHUB_ACTIONS:-false} == "true" && -n ${GITHUB_BASE_REF:+x} ]]; then
mainline="${GITHUB_BASE_REF##*/}"
if [[ ${mainline} != "main" ]]; then
feedback ERROR "Base branch name is not main"
exit 1
wrong_destination_branch="true"
fi
fi

if [[ "${wrong_destination_branch}" == "true" ]]; then
feedback ERROR "Base branch name is not main"
exit 1
fi

# Ensure there is a repo dictionary
if [[ ! -r "${REPO_DICTIONARY}" ]]; then
feedback ERROR "Unable to read a repo dictionary at ${REPO_DICTIONARY}; does it exist?"
Expand Down Expand Up @@ -213,8 +232,13 @@ function get_files_matching_filetype() {
fi
fi
if [ "$linter_name" == "actionlint" ]; then
local action_path="${GITHUB_WORKSPACE:-.}/.github/workflows/"
if [[ "${file}" != "${action_path}"* ]]; then
if [[ -n "${GITHUB_WORKSPACE:+x}" ]]; then
local action_path="${GITHUB_WORKSPACE:-.}/.github/workflows/"
if [[ "${file}" != "${action_path}"* ]]; then
continue
fi
else
# Skip actionlint if not running in a GitHub Action
continue
fi
fi
Expand Down Expand Up @@ -303,15 +327,29 @@ function lint_files() {
function seiso_lint() {
echo -e "\nRunning Seiso Linter\n--------------------------\n"

if [[ -n ${GITHUB_WORKSPACE:-} ]]; then
echo "Setting ${GITHUB_WORKSPACE} as safe directory"
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
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
local safe_directory="${BITBUCKET_CLONE_DIR}"
else
feedback WARNING "Unable to identify a directory to set as safe, skipping that step..."
local skip_safe="true"
fi

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
if [[ -d "${GITHUB_WORKSPACE:-.}/.github/linters" ]]; then
cp -p "${GITHUB_WORKSPACE:-.}/.github/linters/"* "${GITHUB_WORKSPACE:-.}/.github/linters/".* /etc/opt/goat/ 2>/dev/null || true
elif [[ -d "${BITBUCKET_CLONE_DIR:-.}/linters" ]]; then
cp -p "${BITBUCKET_CLONE_DIR:-.}/linters/"* "${BITBUCKET_CLONE_DIR:-.}/linters/".* /etc/opt/goat/ 2>/dev/null || true
fi

excluded=()
Expand Down Expand Up @@ -348,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,
},
{
name: 'seiso global dictionary',
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2023.11.01
current_version = 2024.01.04
parse = (?P<year>2[0-1]\d{2})\.(?P<month>(0\d|1[0-2]))(.(?P<increment>\d{2}))?
serialize = {year}.{month}.{increment}
commit = True
Expand Down

0 comments on commit 112923c

Please sign in to comment.