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 Bash CI #4

Merged
merged 4 commits into from
May 5, 2023
Merged

Add Bash CI #4

merged 4 commits into from
May 5, 2023

Conversation

bateller
Copy link
Member

@bateller bateller commented May 5, 2023

No description provided.

@github-actions
Copy link

github-actions bot commented May 5, 2023

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:

----------

In bashrc_snippet.sh line 1:
# Configuration variables
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In bashrc_snippet.sh line 18:
    local current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
          ^------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 21:
      local user_name=$(git config user.name)
            ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 22:
      local user_email=$(git config user.email)
            ^--------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 31:
      local commits_ahead=$(git rev-list --count --left-only HEAD...@'{u}' 2>/dev/null)
            ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 38:
      local commits_behind=$(git rev-list --count --right-only HEAD...@'{u}' 2>/dev/null)
            ^------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 45:
      local files_diff_count=$(git diff --name-only "$current_branch" "origin/$current_branch" 2>/dev/null | wc -l | tr -d '[:space:]')
            ^--------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 56:
      local untracked_files=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d '[:space:]')
            ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt -s' returned error 1 finding the following formatting issues:

----------
--- bashrc_snippet.sh.orig
+++ bashrc_snippet.sh
@@ -8,62 +8,62 @@
 GIT_SHOW_UNTRACKED_FILES=true
 
 is_git_repository() {
-  git rev-parse --is-inside-work-tree >/dev/null 2>&1 && [ -d .git ]
+	git rev-parse --is-inside-work-tree >/dev/null 2>&1 && [ -d .git ]
 }
 
 get_git_info() {
-  local output=""
+	local output=""
 
-  if is_git_repository; then
-    local current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
+	if is_git_repository; then
+		local current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
 
-    if [ "$GIT_SHOW_USER_INFO" = true ]; then
-      local user_name=$(git config user.name)
-      local user_email=$(git config user.email)
-      output+="($user_name <$user_email>) "
-    fi
+		if [ "$GIT_SHOW_USER_INFO" = true ]; then
+			local user_name=$(git config user.name)
+			local user_email=$(git config user.email)
+			output+="($user_name <$user_email>) "
+		fi
 
-    if [ "$GIT_SHOW_BRANCH" = true ]; then
-      output+="$current_branch "
-    fi
+		if [ "$GIT_SHOW_BRANCH" = true ]; then
+			output+="$current_branch "
+		fi
 
-    if [ "$GIT_SHOW_COMMITS" = true ]; then
-      local commits_ahead=$(git rev-list --count --left-only HEAD...@'{u}' 2>/dev/null)
-      if [ "$commits_ahead" != "0" ]; then
-        output+="↑$commits_ahead "
-      fi
-    fi
+		if [ "$GIT_SHOW_COMMITS" = true ]; then
+			local commits_ahead=$(git rev-list --count --left-only HEAD...@'{u}' 2>/dev/null)
+			if [ "$commits_ahead" != "0" ]; then
+				output+="↑$commits_ahead "
+			fi
+		fi
 
-    if [ "$GIT_SHOW_STAGED_COMMITS" = true ]; then
-      local commits_behind=$(git rev-list --count --right-only HEAD...@'{u}' 2>/dev/null)
-      if [ "$commits_behind" != "0" ]; then
-        output+="↓$commits_behind "
-      fi
-    fi
+		if [ "$GIT_SHOW_STAGED_COMMITS" = true ]; then
+			local commits_behind=$(git rev-list --count --right-only HEAD...@'{u}' 2>/dev/null)
+			if [ "$commits_behind" != "0" ]; then
+				output+="↓$commits_behind "
+			fi
+		fi
 
-    if [ "$GIT_SHOW_FILES_DIFF_COUNT" = true ]; then
-      local files_diff_count=$(git diff --name-only "$current_branch" "origin/$current_branch" 2>/dev/null | wc -l | tr -d '[:space:]')
-      if [ "$files_diff_count" != "0" ]; then
-        output+="Δ$files_diff_count "
-      fi
-    fi
+		if [ "$GIT_SHOW_FILES_DIFF_COUNT" = true ]; then
+			local files_diff_count=$(git diff --name-only "$current_branch" "origin/$current_branch" 2>/dev/null | wc -l | tr -d '[:space:]')
+			if [ "$files_diff_count" != "0" ]; then
+				output+="Δ$files_diff_count "
+			fi
+		fi
 
-    if [ "$GIT_SHOW_UNCOMMITTED_CHANGES" = true ]; then
-      git diff --quiet 2>/dev/null || output+="+ "
-    fi
+		if [ "$GIT_SHOW_UNCOMMITTED_CHANGES" = true ]; then
+			git diff --quiet 2>/dev/null || output+="+ "
+		fi
 
-    if [ "$GIT_SHOW_UNTRACKED_FILES" = true ]; then
-      local untracked_files=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d '[:space:]')
-      if [ "$untracked_files" != "0" ]; then
-        output+="✚$untracked_files "
-      fi
-    fi
+		if [ "$GIT_SHOW_UNTRACKED_FILES" = true ]; then
+			local untracked_files=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d '[:space:]')
+			if [ "$untracked_files" != "0" ]; then
+				output+="✚$untracked_files "
+			fi
+		fi
 
-  else
-    output="Not a Git repository"
-  fi
+	else
+		output="Not a Git repository"
+	fi
 
-  iterm2_set_user_var gitInfo "$output"
+	iterm2_set_user_var gitInfo "$output"
 }
 
 # Call get_git_info when the shell prompt is displayed
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -s -w filename


@github-actions
Copy link

github-actions bot commented May 5, 2023

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:

----------

In bashrc_snippet.sh line 1:
# Configuration variables
^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In bashrc_snippet.sh line 18:
    local current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
          ^------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 21:
      local user_name=$(git config user.name)
            ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 22:
      local user_email=$(git config user.email)
            ^--------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 31:
      local commits_ahead=$(git rev-list --count --left-only HEAD...@'{u}' 2>/dev/null)
            ^-----------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 38:
      local commits_behind=$(git rev-list --count --right-only HEAD...@'{u}' 2>/dev/null)
            ^------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 45:
      local files_diff_count=$(git diff --name-only "$current_branch" "origin/$current_branch" 2>/dev/null | wc -l | tr -d '[:space:]')
            ^--------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.


In bashrc_snippet.sh line 56:
      local untracked_files=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d '[:space:]')
            ^-------------^ SC2155 (warning): Declare and assign separately to avoid masking return values.

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt -s' returned error 1 finding the following formatting issues:

----------
--- bashrc_snippet.sh.orig
+++ bashrc_snippet.sh
@@ -8,62 +8,62 @@
 GIT_SHOW_UNTRACKED_FILES=true
 
 is_git_repository() {
-  git rev-parse --is-inside-work-tree >/dev/null 2>&1 && [ -d .git ]
+	git rev-parse --is-inside-work-tree >/dev/null 2>&1 && [ -d .git ]
 }
 
 get_git_info() {
-  local output=""
+	local output=""
 
-  if is_git_repository; then
-    local current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
+	if is_git_repository; then
+		local current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)
 
-    if [ "$GIT_SHOW_USER_INFO" = true ]; then
-      local user_name=$(git config user.name)
-      local user_email=$(git config user.email)
-      output+="($user_name <$user_email>) "
-    fi
+		if [ "$GIT_SHOW_USER_INFO" = true ]; then
+			local user_name=$(git config user.name)
+			local user_email=$(git config user.email)
+			output+="($user_name <$user_email>) "
+		fi
 
-    if [ "$GIT_SHOW_BRANCH" = true ]; then
-      output+="$current_branch "
-    fi
+		if [ "$GIT_SHOW_BRANCH" = true ]; then
+			output+="$current_branch "
+		fi
 
-    if [ "$GIT_SHOW_COMMITS" = true ]; then
-      local commits_ahead=$(git rev-list --count --left-only HEAD...@'{u}' 2>/dev/null)
-      if [ "$commits_ahead" != "0" ]; then
-        output+="↑$commits_ahead "
-      fi
-    fi
+		if [ "$GIT_SHOW_COMMITS" = true ]; then
+			local commits_ahead=$(git rev-list --count --left-only HEAD...@'{u}' 2>/dev/null)
+			if [ "$commits_ahead" != "0" ]; then
+				output+="↑$commits_ahead "
+			fi
+		fi
 
-    if [ "$GIT_SHOW_STAGED_COMMITS" = true ]; then
-      local commits_behind=$(git rev-list --count --right-only HEAD...@'{u}' 2>/dev/null)
-      if [ "$commits_behind" != "0" ]; then
-        output+="↓$commits_behind "
-      fi
-    fi
+		if [ "$GIT_SHOW_STAGED_COMMITS" = true ]; then
+			local commits_behind=$(git rev-list --count --right-only HEAD...@'{u}' 2>/dev/null)
+			if [ "$commits_behind" != "0" ]; then
+				output+="↓$commits_behind "
+			fi
+		fi
 
-    if [ "$GIT_SHOW_FILES_DIFF_COUNT" = true ]; then
-      local files_diff_count=$(git diff --name-only "$current_branch" "origin/$current_branch" 2>/dev/null | wc -l | tr -d '[:space:]')
-      if [ "$files_diff_count" != "0" ]; then
-        output+="Δ$files_diff_count "
-      fi
-    fi
+		if [ "$GIT_SHOW_FILES_DIFF_COUNT" = true ]; then
+			local files_diff_count=$(git diff --name-only "$current_branch" "origin/$current_branch" 2>/dev/null | wc -l | tr -d '[:space:]')
+			if [ "$files_diff_count" != "0" ]; then
+				output+="Δ$files_diff_count "
+			fi
+		fi
 
-    if [ "$GIT_SHOW_UNCOMMITTED_CHANGES" = true ]; then
-      git diff --quiet 2>/dev/null || output+="+ "
-    fi
+		if [ "$GIT_SHOW_UNCOMMITTED_CHANGES" = true ]; then
+			git diff --quiet 2>/dev/null || output+="+ "
+		fi
 
-    if [ "$GIT_SHOW_UNTRACKED_FILES" = true ]; then
-      local untracked_files=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d '[:space:]')
-      if [ "$untracked_files" != "0" ]; then
-        output+="✚$untracked_files "
-      fi
-    fi
+		if [ "$GIT_SHOW_UNTRACKED_FILES" = true ]; then
+			local untracked_files=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d '[:space:]')
+			if [ "$untracked_files" != "0" ]; then
+				output+="✚$untracked_files "
+			fi
+		fi
 
-  else
-    output="Not a Git repository"
-  fi
+	else
+		output="Not a Git repository"
+	fi
 
-  iterm2_set_user_var gitInfo "$output"
+	iterm2_set_user_var gitInfo "$output"
 }
 
 # Call get_git_info when the shell prompt is displayed
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -s -w filename


@bateller bateller merged commit 3c11b5f into main May 5, 2023
1 check passed
@bateller bateller deleted the github_actions branch May 5, 2023 22:57
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.

None yet

1 participant